sajor2000/methodsmith / plugins/methodsmith/skills/method-model-choice
method-model-choice
VerifiedChooses and justifies the statistical model (regression, mixed/GEE, survival, causal, prediction, Bayesian) after the estimand is set. Use when the user asks which model to fit.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.8 KB |
| agents/openai.yaml | config | 252 B |
| references/advanced-models.md | markdown | 4.7 KB |
| references/evidence-access.md | markdown | 3.4 KB |
| references/forward-temporal-validation.md | markdown | 1.5 KB |
| references/mixed-effects.md | markdown | 8.1 KB |
| references/ml-prediction-decisions.md | markdown | 3.0 KB |
| references/ml-prediction-decisions.schema.json | config | 3.4 KB |
| references/ml-training-protocol.md | markdown | 23.4 KB |
| references/model-routing.md | markdown | 8.1 KB |
| references/python-implementation.md | markdown | 3.6 KB |
| references/r-implementation.md | markdown | 2.9 KB |
references/r-implementation.md
View on GitHub# R Implementation
Use the project's locked environment and existing conventions. Check `renv.lock`, `DESCRIPTION`, analysis scripts, and package versions before writing calls. Do not install packages.
## Preferred established paths
| Need | Candidate path | Required implementation checks |
|---|---|---|
| Ordinary linear/GLM | `stats::lm`, `stats::glm` | Family/link, contrasts, design matrix, diagnostics |
| LMM/GLMM | `lme4::lmer`, `lme4::glmer` (+ `lmerTest` or `pbkrtest` for Satterthwaite/Kenward-Roger df; `lme4` reports none) | Grouping, random structure, singularity, optimizer, marginalization |
| Flexible GLMM/count/zero models | `glmmTMB` | Family, dispersion/zero component, convergence code, simulation residuals |
| Residual covariance/MMRM | Existing `nlme`, `mmrm`, or project-approved path | Time spacing, covariance structure, denominator df |
| GEE | `geepack::geeglm` or existing approved path; `glmtoolbox::glmgee` when a Mancl-DeRouen bias-corrected sandwich is needed | Cluster id, waves/order, working correlation, small-cluster correction, MCAR assumption |
| Survival | `survival`, plus an existing approved competing-risk/flexible package | Time zero, event coding, PH/time-varying checks |
| Bayesian hierarchy | Existing `brms`, `rstanarm`, or project-approved Stan path | Priors, chains, R-hat, ESS, divergences, posterior predictive checks |
| Meta-analysis | Existing `meta` or `metafor` path | Effect scale, tau-squared, interval method, influence, prediction interval |
Prefer the installed package that directly implements the selected estimand. Do not introduce a package solely to make the scaffold look symmetric with Python.
## Scaffold contract
The `.R` scaffold must:
1. Declare required columns and stop when any are absent.
2. Assert the intended row grain or identifier uniqueness where applicable.
3. Validate outcome support, grouping levels, event coding, and exposure/offset positivity.
4. Make the primary formula and family/link visible in one place.
5. Fit one primary model; put sensitivity models in named functions or clearly inactive sections.
6. Capture convergence/singularity and family-specific diagnostic outputs.
7. Produce estimand-aligned contrasts or predictions rather than dumping raw coefficients alone.
8. Save no row-level output by default.
For mixed models, include variance/correlation summaries, singularity checks, and a predeclared simplification path. For nonlinear links, use appropriate marginal standardization when the memo requests population-average effects (e.g., an installed `marginaleffects::avg_comparisons()` or `emmeans` path; verify the API against the pinned version).
Record `sessionInfo()` or the repository's equivalent reproducibility evidence. If an unfamiliar API is version-sensitive, verify its official documentation before writing it; otherwise write no scaffold, use `provisional` or `blocked` with `code=none`, and record the exact version gap.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |