multilevel-models

Fit multilevel regression models with ICC diagnostics and centering strategies.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/Yuuqq/claude-social-science-skills --skill multilevel-models
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: multilevel-models
Source: https://github.com/Yuuqq/claude-social-science-skills/tree/main/social-science-skills/multilevel-models
Command: npx skills add https://github.com/Yuuqq/claude-social-science-skills --skill multilevel-models

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, pandas, statsmodels, scipy, matplotlib, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

Multilevel modeling fixes biased standard errors and pseudoreplication that happen when hierarchical social science data (e.g., students within schools, repeated measures within people) are analyzed with single-level regression.

Core Features & Use Cases

  • ICC diagnostics & model selection: Estimate intraclass correlation to decide whether multilevel structure is warranted, then compare random-intercept and random-slope specifications.
  • Hierarchical effects with centering: Build random intercepts/slopes, handle contextual effects via group-mean and grand-mean centering, and interpret coefficients correctly.
  • Flexible outcomes & Bayesian estimation: Fit GLMMs for binary/count outcomes and use Bayesian multilevel workflows (e.g., via bambi/PyMC) for complex random-effect structures and better uncertainty reporting.

Quick Start

Use the multilevel-models skill to analyze a dataset where students are nested within schools by estimating ICC, fitting a random-intercept model, and extending to a random-slope model when the relationship plausibly varies across schools.

Frequently Asked Questions about multilevel-models

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why do my standard errors become biased when running regression on nested data?

Single-level regression on nested data causes pseudoreplication, underestimating standard errors and inflating significance. Multilevel modeling fixes this by fitting mixed-effects models that account for hierarchical clustering and report valid uncertainty.

How do I decide if I need a random intercept or random slope model?

Compute ICC diagnostics to estimate intraclass correlation and confirm a multilevel structure is warranted. Then compare random-intercept and random-slope specifications to test whether relationships plausibly vary across grouping clusters.

What is the best way to center predictors for contextual effects in mixed models?

Apply group-mean centering to separate within-group effects from between-group effects, and use grand-mean centering for contextual interpretation. This ensures correct coefficient interpretation in hierarchical regression models.

Can I fit a Bayesian multilevel model for non-normal outcomes using statsmodels?

Statsmodels fits frequentist GLMMs for binary or count outcomes, while Bayesian multilevel estimation uses bambi and PyMC for complex random-effect structures and better uncertainty reporting.

How do I handle repeated measures clustering within people for social science research?

Fit mixed-effects regression models that treat repeated measures as nested within individuals. Estimate random intercepts and slopes to account for correlation and avoid biased standard errors in longitudinal data.