/alterlab-social-science-workflow:alterlab-missing-datafrom alterlab-social-science-workflow
Forces explicit MCAR/MAR/MNAR mechanism statement, then applies MICE with Rubin's-rules pooling or FIML. Warns against single imputation. Uses statsmodels or R mice via Rscript.
Ships in alterlab-social-science-workflow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Skill type: ANALYSIS MODULE. Missing data is not a nuisance to delete or fill with a mean. The discipline: state the missingness mechanism, then use a method whose uncertainty is honest — multiple imputation with Rubin's-rules pooling, or FIML. The dangerous shortcut is single imputation, which treats guessed values as observed and understates standard errors.
STATE THE MECHANISM (MCAR / MAR / MNAR). MULTIPLY IMPUTE AND POOL BY RUBIN'S RULES —
SINGLE IMPUTATION FAKES CERTAINTY IT DOESN'T HAVE.
| The request is really about… | Route to | Why not this skill |
|---|---|---|
| Modeling on already-complete data | alterlab-statistical-analysis / alterlab-statsmodels | No missingness to handle. |
| FIML inside an SEM / latent-variable model | alterlab-sem-psychometrics | That skill fits the latent model with FIML. |
| Survey weights / design (a different kind of "adjustment") | alterlab-survey-analysis | Design-based inference, not imputation. |
| Whether the study design is sound | alterlab-ssci-design-gate | Design routing. |
Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-statistical-analysis) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.
Running the code. In Claude Code, run analysis code in a throwaway environment instead of installing packages: uv run --python ">=3.11" --with "statsmodels>=0.14" --with pandas python impute.py. This needs no install approval and leaves the user's environment untouched. If uv or the network is unavailable, say so and hand over the script; never report results you did not compute.
| Mechanism | Meaning | Consequence |
|---|---|---|
| MCAR | missingness independent of everything | listwise deletion is unbiased (but wasteful) |
| MAR | missingness depends on observed data | MI / FIML are valid (the workhorse assumption) |
| MNAR | missingness depends on the unobserved value itself | needs a selection / pattern-mixture model + sensitivity analysis |
The mechanism is an assumption, largely untestable (MAR vs MNAR especially) — state it and
justify it; inspect the missingness pattern (mice::md.pattern) and test MCAR (Little's test) as
supporting evidence, not proof.
Create m completed datasets (each imputes with added noise reflecting uncertainty), analyze each, then pool: the point estimate is the mean across imputations; the SE combines within-imputation and between-imputation variance (Rubin's rules), so it honestly reflects imputation uncertainty.
Python — statsmodels MICE:
import statsmodels.api as sm
from statsmodels.imputation import mice
imp = mice.MICEData(df) # chained-equations imputer over the frame
fit = mice.MICE("y ~ x1 + x2", sm.OLS, imp).fit(n_burnin=10, n_imputations=20)
fit.summary() # pooled estimates + SEs (Rubin's rules)
R — mice (field standard):
library(mice)
md.pattern(data) # inspect the missingness pattern
imp <- mice(data, m = 20, method = "pmm") # m completed datasets
fit <- with(imp, lm(y ~ x1 + x2))
summary(pool(fit)) # Rubin's-rules pooling (fmi, lambda, df)
FIML — for likelihood/SEM models under MAR, full-information ML uses all available data without
explicit imputation; route to alterlab-sem-psychometrics when the model is latent-variable.
IterativeImputer returns a single completed dataset and does not pool by
Rubin's rules — the sklearn docs say so explicitly. It is fine for a prediction pipeline, but using
it as "multiple imputation" for inference understates uncertainty. If you must, run it repeatedly
with sample_posterior=True and different seeds and pool manually — but mice/statsmodels MICE do
this correctly out of the box.Rule of thumb: m at least the percentage of incomplete cases (higher fraction of missing information → larger m); modern guidance often uses m ≈ 20–50. Report m and the fraction of missing information (FMI).
MECHANISM: MCAR / MAR / MNAR — stated and justified; pattern inspected (md.pattern)
METHOD: MICE (m, imputation model) with Rubin's-rules pooling | FIML | (deletion only if MCAR)
POOLING: estimates + SEs pooled by Rubin's rules; report FMI
SENSITIVITY: for MNAR, a sensitivity analysis (selection / pattern-mixture)
references/mechanisms_and_pooling.md — MCAR/MAR/MNAR detail, Rubin's-rules math, FIML vs MI, m guidance, the sklearn caveat.Part of the AlterLab Academic Skills suite.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
missing-data, multiple-imputation, mice, rubins-rules, fiml, statistical-analysis
17 skills in this plugin
/alterlab-abm-mesaBuilds agent-based models of social systems with Mesa 3 — the current AgentSet API (model.agents.shuffle_do('step'), auto-assigned unique_id, mandatory super().__init__(rng=...)), cell spaces (mesa.discrete_space OrthogonalMooreGrid / classic mesa.space grids), the DataCollector, batch_run parameter sweeps, and SolaraViz — for emergence, segregation, diffusion, opinion dynamics, and cooperation models. It uses the Mesa 3.x API (the old mesa.time schedulers like RandomActivation are removed) and treats the model as a generative theory to be validated, not just run. Use when the request mentions an agent-based model, Mesa, simulating interacting agents, or emergent macro behavior from micro rules. For discrete-event (queueing/process) simulation prefer alterlab-simpy; for reinforcement learning prefer alterlab-stable-baselines3. Part of the AlterLab Academic Skills suite./alterlab-causal-inferenceEstimates causal effects from observational and quasi-experimental data — difference-in-differences, instrumental variables, regression discontinuity, panel fixed effects, propensity-score / doubly-robust methods, and heterogeneous treatment effects (CATE) — using the verified Python stack: statsmodels and linearmodels (PanelOLS, IV2SLS), pyfixest (feols, event studies, Sun-Abraham, did2s), DoWhy (identify -> estimate -> refute), EconML (LinearDML, CausalForestDML, DRLearner), and rdrobust for RD. It names the identifying assumption before estimating and runs a refutation/robustness check after. Use when the request mentions difference-in-differences, instrumental variables, regression discontinuity, fixed effects / panel causal estimation, propensity scores, or treatment-effect estimation from non-randomized data. For choosing the design first prefer alterlab-ssci-design-gate; for plain regression or descriptive stats prefer alterlab-statistical-analysis. Part of the AlterLab Academic Skills suite./alterlab-meta-analysisRuns quantitative meta-analysis — computes effect sizes (Hedges' g / standardized mean difference, log odds/risk ratios) with their variances, pools them under fixed-effect and random-effects models, quantifies heterogeneity (I-squared, tau-squared, Cochran's Q), draws forest and funnel plots, and tests publication bias (Egger's regression, trim-and-fill) — using statsmodels.stats.meta_analysis in Python or the field-standard R metafor via Rscript. It enforces PRISMA reporting and the random- vs fixed-effect decision. Use when pooling effect sizes across studies, running a systematic review's quantitative synthesis, or assessing heterogeneity and publication bias. For finding and screening the literature prefer alterlab-deep-research; for a single study's statistics prefer alterlab-statistical-analysis. Part of the AlterLab Academic Skills suite./alterlab-multilevel-modelsFits and reports mixed-effects / multilevel / hierarchical models for clustered, nested, longitudinal, and repeated-measures data — random intercepts and slopes, variance components and the ICC, cross-level interactions, and GLMMs (logistic/Poisson) — using statsmodels MixedLM and bambi (Bayesian on PyMC) in Python, or the field-standard R lme4 / glmmTMB / brms via Rscript. It enforces the reporting items reviews find under-reported: full fixed + random specification, centering, variance components + ICC, estimation method, assumption checks, model comparisons, and effect sizes. Use when data are grouped/nested (students in schools, repeated measures, panel/longitudinal) and the question concerns within- vs between-cluster variation. For general single-level regression prefer alterlab-statsmodels; for panel fixed effects used for causal identification prefer alterlab-causal-inference. Part of the AlterLab Academic Skills suite./alterlab-qcaRuns Qualitative Comparative Analysis — crisp-set (csQCA), multi-value (mvQCA), and fuzzy-set (fsQCA) — for small-to-medium-N configurational research: calibrating raw data into set membership, building and refining a truth table, and Boolean minimization into conservative / parsimonious / intermediate solutions with consistency and coverage. Because there is no maintained Python QCA library, it shells out to R's QCA package (calibrate, truthTable, minimize) via Rscript and documents that dependency honestly rather than faking a Python API. Use when the request mentions QCA, fsQCA, csQCA, configurational or set-theoretic analysis, necessary/sufficient conditions, truth tables, or calibration of conditions. For net-effect estimation of a single treatment prefer alterlab-causal-inference; for interpretive analysis prefer alterlab-qualitative-methods. Part of the AlterLab Academic Skills suite./alterlab-qualitative-analysisAnalyzes qualitative data as a dispatched pipeline module — codebook development, thematic / framework / content analysis, and inter-coder reliability computed correctly (Krippendorff's alpha as primary via the krippendorff package or a bundled stdlib nominal calculator with bootstrap CIs; Cohen's / Fleiss' kappa via statsmodels) with 95% CIs and thresholds (alpha >= .80 reliable, .667-.80 tentative). It BRANCHES by design: coefficient-based ICR for codebook / content-analytic coding, versus consensus-and-reflexivity for reflexive thematic analysis where a statistic is not the right criterion. Supports human-vs-LLM double-coding with an alpha check against a human gold standard. Use when coding interviews or open-ended text, building a codebook, or reporting intercoder reliability. For topic modeling / embeddings / supervised text classification prefer alterlab-text-as-data; for the reflexivity gate prefer alterlab-ssci-reflexivity-gate. Part of the AlterLab Academic Skills suite.npx claudepluginhub alterlab-ieu/alterlab-academic-skills --plugin alterlab-social-science-workflow2 plugins in one repository ship this exact skill · first indexed Nov 9, 2026
Other plugins' skills for the same job