Skip to content
Automation
Skill

/statsmodels

Statistical modeling: OLS/WLS/GLS, GLM (logit, probit, Poisson), time series (ARIMA, VAR), mixed effects, diagnostics. Formula API. Use for regressions without fixed effects, GLMs, or time series. For FE/DiD use pyfixest; panel/IV use linearmodels.

From plugin
auto-empirical-research-skills
5k200 skills

Claude Code

$ npx -y skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill statsmodels --agent claude-code

SKILL.md

statsmodels.SKILL.md
name: statsmodels
description: >-
  Statistical modeling: OLS/WLS/GLS, GLM (logit, probit, Poisson), time series (ARIMA, VAR), mixed effects, diagnostics. Formula API. Use for regressions without fixed effects, GLMs, or time series. For FE/DiD use pyfixest; panel/IV use linearmodels.
metadata:
  audience: research-coders
  domain: python-library
  library-version: "0.14.6"
  skill-last-updated: "2026-03-27"

statsmodels Skill

statsmodels general-purpose statistical modeling library for Python. Covers OLS/WLS/GLS, GLM (logit, probit, Poisson, negative binomial), discrete choice models, time series (ARIMA, SARIMAX, VAR), mixed effects (MixedLM), robust regression, hypothesis tests, and comprehensive diagnostics. Supports R-style formula API. Use when fitting regressions without fixed effects, running GLMs or logit/probit, analyzing time series, or using formula syntax. For fixed effects or DiD, use pyfixest; for panel/IV/system models, use linearmodels.

Comprehensive skill for statistical modeling with statsmodels. Use decision trees below to find the right guidance, then load detailed references.

What is statsmodels?

statsmodels is the general-purpose **statistical modeling** library for Python:

  • **Two APIs**: Formula API (`smf.ols("y ~ x1 + x2", data=df)`) for R-style modeling, and array API (`sm.OLS(y, X)`) for programmatic control
  • **Broad model coverage**: OLS, WLS, GLS, GLM (all families), logit, probit, multinomial, count models, zero-inflated models, quantile regression, robust regression
  • **Time series**: ARIMA, SARIMAX, VAR, exponential smoothing, state space models, unit root tests
  • **Diagnostics**: Heteroskedasticity tests, normality tests, specification tests, VIF, influence measures, residual analysis
  • **Hypothesis testing**: t-tests, F-tests, Wald tests, likelihood ratio tests, multiple comparison corrections

How to Use This Skill

Reference File Structure

| File | Purpose | When to Read | |------|---------|--------------| | `quickstart.md` | Installation, formula vs array API, first model | Starting with statsmodels | | `linear-models.md` | OLS, WLS, GLS, robust regression, quantile regression | Fitting linear models | | `glm-discrete.md` | GLM families, logit/probit, count models, zero-inflated | Non-linear models, binary/count outcomes | | `time-series.md` | ARIMA, SARIMAX, VAR, exponential smoothing, unit root tests | Analyzing temporal data | | `diagnostics.md` | Heteroskedasticity, normality, VIF, influence, residuals | Checking model assumptions | | `hypothesis-testing.md` | t-tests, F-tests, Wald tests, multiple comparisons | Testing coefficients and comparing models | | `gotchas.md` | Constant term, convergence, predict pitfalls, pyfixest boundary | Debugging issues |

Reading Order

1. **New to statsmodels?** Start with `quickstart.md` then `linear-models.md` 2. **Need GLM or logit/probit?** Read `quickstart.md` then `glm-discrete.md` 3. **Time series analysis?** Read `quickstart.md` then `time-series.md` 4. **Checking model assumptions?** Read `diagnostics.md` 5. **Coming from R?** Read `quickstart.md` (formula API mirrors R syntax)

Related Skills

  • **pyfixest**: Use instead of statsmodels when your model needs absorbed fixed effects, IV with FE, or difference-in-differences. pyfixest is faster for FE models; statsmodels is broader for everything else
  • **linearmodels**: Use for panel data models (FE, RE, between, first difference, Fama-MacBeth), IV/GMM without FE (2SLS, LIML, GMM), system estimation (SUR, 3SLS), and asset pricing. Built on top of statsmodels; extends it for structured data
  • **svy**: Use for survey-weighted regression and estimation with complex survey designs. **Important:** statsmodels WLS is NOT equivalent to survey-weighted regression โ€” WLS handles heteroscedastic errors but does not account for stratification, clustering, or finite population corrections. If your data comes from a complex probability survey (NHANES, ACS PUMS, CPS, ECLS-K, etc.), load the `svy` skill instead
  • **data-scientist**: Provides methodology guidance (when to use which model, assumption checking protocol, interpretation). Load alongside statsmodels for the "why"; statsmodels provides the "how"
  • **polars**: Data manipulation before modeling. statsmodels accepts pandas DataFrames; convert with `df.to_pandas()` if using Polars
  • **plotnine**: Publication-quality visualization of model results and diagnostics

Quick Decision Trees

"I need to fit a regression model"

What kind of regression?
โ”œโ”€ Linear (continuous outcome)
โ”‚   โ”œโ”€ Basic OLS โ†’ ./references/linear-models.md
โ”‚   โ”œโ”€ Weighted least squares โ†’ ./references/linear-models.md
โ”‚   โ”‚   (โš  WLS โ‰  survey-weighted regression โ€” for complex surveys, use `svy` skill)
โ”‚   โ”œโ”€ Correlated errors (GLS) โ†’ ./references/linear-models.md
โ”‚   โ”œโ”€ Robust to outliers (M-estimator) โ†’ ./references/linear-models.md
โ”‚   โ””โ”€ Quantile regression โ†’ ./references/linear-models.md
โ”œโ”€ Binary outcome (0/1)
โ”‚   โ”œโ”€ Logit โ†’ ./references/glm-discrete.md
โ”‚   โ””โ”€ Probit โ†’ ./references/glm-discrete.md
โ”œโ”€ Count outcome (0, 1, 2, ...)
โ”‚   โ”œโ”€ Poisson โ†’ ./references/glm-discrete.md
โ”‚   โ”œโ”€ Negative binomial โ†’ ./references/glm-discrete.md
โ”‚   โ””โ”€ Zero-inflated โ†’ ./references/glm-discrete.md
โ”œโ”€ Multinomial (3+ categories)
โ”‚   โ””โ”€ Multinomial logit โ†’ ./references/glm-discrete.md
โ”œโ”€ GLM (custom family/link)
โ”‚   โ””โ”€ GLM framework โ†’ ./references/glm-discrete.md
โ””โ”€ Need fixed effects?
    โ””โ”€ Use pyfixest instead (faster FE absorption)

"I need to analyze time series"

What time series task?
โ”œโ”€ Forecast a single series
โ”‚   โ”œโ”€ ARIMA / SARIMAX โ†’ ./references/time-series.md
โ”‚   โ””โ”€ Exponential smoothing โ†’ ./references/time-series.md
โ”œโ”€ Multiple interrelated series
โ”‚   โ””โ”€ VAR / VECM โ†’ ./references/time-series.md
โ”œโ”€ Test for stationarity
โ”‚   โ”œโ”€ ADF test โ†’ ./references/time-series.md
โ”‚   โ””โ”€ KPSS test โ†’ ./references/time-series.md
โ”œโ”€ Examine autocorrelation
โ”‚   โ””โ”€ ACF / PACF โ†’ ./references/time-series.md
โ””โ”€ Structural
Read more
@brycewang-stanford
Ships withauto-empirical-research-skills

## ๐Ÿ”ฅ ๅŠ›่ ยท StatsPAI โ€” Stata ไธŽ R ็š„ Python ๅนณๆ›ฟ๏ผŒไธบ AI Agent ่€Œ็”Ÿ ๐Ÿ” Stata / R ๅนณๆ›ฟ๏ผšreghdfeใ€csdidใ€rdrobustใ€synthใ€fixestใ€did ็ญ‰ๅธธ็”จๅ‘ฝไปคๅœจ Python ไธญไธ€็ซ™ๅผๆ›ฟไปฃ๏ผŒไธ€ไธช import statspai as sp ๆžๅฎš DID / RD / IV / SCM / DML / matching ๐Ÿค– ้ขๅ‘ Agent ่ฎพ่ฎก๏ผš็ป“ๆž„ๅŒ–็ป“ๆžœๅฏน่ฑก + ๅ†…็ฝฎ MCP Server๏ผŒClaude / Codex

Stars on GitHub

Momentum

stars in total
5.0k
Star history of brycewang-stanford/Auto-Empirical-Research-Skills on GitHub, a chart by star-history.com

More skills from other plugins.

agent-builder

agent-builder

Load immediately after an Agent intent, before the first agent_builder_* call. Governs how you create, configure, test, andโ€ฆ

n8n2w209k
@n8n-io@n8n-ioInstall Skill
browser-use

browser-use

Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work. Also coversโ€ฆ

@browser-use@browser-useInstall Skill
agent-browser

agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, fillingโ€ฆ

@vercel-labs-2@vercel-labs-2Install Skill
add-anydoc

add-anydoc

Add local office-document-to-Markdown conversion to NanoClaw agent containers with the pinned Firecrawl AnyDoc CLI. Use whenโ€ฆ

@nanocoai@nanocoaiInstall Skill

Questions about statsmodels.

Which coding agents can use statsmodels?
statsmodels installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.