/alterlab-social-science-workflow:alterlab-sem-psychometricsfrom alterlab-social-science-workflow
Fits and evaluates measurement models: CFA, SEM, EFA, IRT, and multi-group invariance using semopy, factor_analyzer, pingouin, and girth. Computes McDonald's omega and judges fit against Hu & Bentler cutoffs.
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; scripts run unread.
Skill type: ANALYSIS MODULE. Fits CFA / SEM / EFA / IRT and tests measurement invariance.
The discipline: report fit against real cutoffs, report reliability with omega (not alpha
alone), and establish invariance before comparing groups. Whether the scale should be trusted at
all is the upstream call of alterlab-ssci-measurement-gate.
A MEASUREMENT MODEL IS ONLY DONE WHEN FIT, RELIABILITY (OMEGA), AND INVARIANCE ARE ALL REPORTED.
| The request is really about… | Route to | Why not this skill |
|---|---|---|
| Whether the scale is valid/trustworthy at all (reliability≠validity discipline) | alterlab-ssci-measurement-gate | Gate decision, upstream of fitting. |
| Writing / wording the questionnaire items | alterlab-survey-design | Instrument construction. |
| Plain regression / descriptive stats | alterlab-statistical-analysis | No latent structure. |
| A causal treatment-effect estimate | alterlab-causal-inference | Different problem. |
Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-ssci-measurement-gate) 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 "semopy>=2.3" --with pandas python cfa.py (add --with girth for IRT). 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.
CFA / SEM — semopy (v2.3):
from semopy import Model, calc_stats
desc = """
# measurement model
Trust =~ q1 + q2 + q3
Efficacy =~ q4 + q5 + q6
# structural path
Trust ~ Efficacy
"""
m = Model(desc); m.fit(data) # obj='MLW' default; 'FIML' for missing
est = m.inspect(std_est=True) # standardized loadings for omega
stats = calc_stats(m) # DataFrame: chi2, CFI, TLI, RMSEA, AIC, BIC ...
Note: calc_stats returns CFI/TLI/RMSEA but not SRMR — report the indices it gives and
compute SRMR separately if required.
EFA — factor_analyzer (v0.5):
from factor_analyzer import FactorAnalyzer, calculate_kmo, calculate_bartlett_sphericity
kmo_all, kmo_model = calculate_kmo(X) # sampling adequacy > .60
chi2, p = calculate_bartlett_sphericity(X) # sphericity
fa = FactorAnalyzer(n_factors=3, rotation="promax"); fa.fit(X)
fa.loadings_; fa.get_factor_variance() # (variance, proportional, cumulative)
ConfirmatoryFactorAnalyzer + ModelSpecificationParser.parse_model_specification_from_dict
give a CFA alternative when semopy is unavailable.
factor_analyzer is unmaintained (0.5.1, Feb 2024) and breaks on current stacks: FactorAnalyzer.fit
raises TypeError (force_all_finite) on scikit-learn ≥ 1.8, and ModelSpecificationParser
fails under pandas 3 ("assignment destination is read-only"). calculate_kmo /
calculate_bartlett_sphericity still work. Run it in an isolated env
(uv run --with factor_analyzer --with "scikit-learn<1.8" --with "pandas<3" python efa.py), or do the EFA in R psych
(fa(), KMO(), cortest.bartlett(), fa.parallel()) — say which you used.
Reliability — omega (not alpha alone): pingouin gives cronbach_alpha but no omega, and
semopy does not return omega. Compute McDonald's omega from the standardized loadings with
scripts/omega.py (ω = (Σλ)² / [(Σλ)² + Σ(1−λ²)]). Report alpha + omega together.
IRT: girth (twopl_mml, rasch_mml) for dichotomous 2PL/Rasch; py-irt for Bayesian/
scalable. For polytomous/multidimensional IRT with full fit statistics, R mirt is the practical
standard — say so rather than forcing a thin Python path.
CFI/TLI ≥ .95 · RMSEA ≤ .06 · SRMR ≤ .08. Use a two-index combination; do not chase a single number. Report the χ² and df alongside (χ² is sample-size sensitive, so not decisive).
Multi-group CFA sequence — configural → metric → scalar → strict — judged by ΔCFI ≤ .01 / ΔRMSEA ≤ .015, not only Δχ². Scalar invariance is the prerequisite for comparing latent means; without it a group "difference" may be a measurement artifact. Fit each nested model and compare.
MODEL: <CFA/SEM/EFA/IRT + the semopy/factor_analyzer spec>
FIT: CFI= TLI= RMSEA= (chi2/df=) vs Hu & Bentler cutoffs
RELIABILITY: omega= (alpha= ) per factor, from standardized loadings
VALIDITY: <AVE, HTMT if convergent/discriminant claimed>
INVARIANCE: <configural|metric|scalar|strict established; ΔCFI reported>
references/fit_and_invariance.md — omega math, fit-index nuance, the invariance sequence, IRT notes.scripts/omega.py — stdlib McDonald's omega from standardized loadings.
Needs ≥ 2 standardized loadings, each finite and within [−1, 1] (|λ| > 1 = Heywood case,
rejected); reverse-code negatively keyed items first — ω is the reliability of the sum as scored.Part of the AlterLab Academic Skills suite.
evals/evals.json (opens in a new tab)evals/fixtures/customer_survey_sem.csv (opens in a new tab)evals/fixtures/customer_survey_sem_codebook.md (opens in a new tab)evals/fixtures/survey_cfa.csv (opens in a new tab)evals/fixtures/survey_cfa_codebook.md (opens in a new tab)evals/fixtures/test_items.csv (opens in a new tab)references/fit_and_invariance.md (opens in a new tab)scripts/omega.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
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
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.Other plugins' skills for the same job