domains / data / statistical-modeling / statsmodels

statsmodels

Skill card

combined

The K-Dense-AI copy is the upstream source (v1.5) and contains material constraints the other copies lack, such as explicit version pinning, the missing='raise' data-preparation rule, and the requirement to use result_object=True for transitioning tests. The zLanqing and foryourhealth111 copies are near-identical reproductions of an earlier version that include inline code examples but lack these specific safety and compatibility checks. The sickn33 copy is a wrapper that defers to a separate guide. Because the upstream copy has unique, mandatory steps that the reproductions omit, crowning one would hide the real alternative of using the inline examples versus the version-pinned constraints.

Repositories

RepositoryPath
zLanqing/codex-claude-academic-skillsscientific-toolkit-skill/references/scientific-skills/statsmodels/SKILL.md
K-Dense-AI/scientific-agent-skillsskills/statsmodels/SKILL.md
foryourhealth111-pixel/Vibe-Skillsbundled/skills/statsmodels/SKILL.md
sickn33/agentic-awesome-skillsplugins/agentic-awesome-skills-claude/skills/statsmodels/SKILL.md

Other copies

RoleRepositoryPath
peerzLanqing/codex-claude-academic-skillsscientific-toolkit-skill/references/scientific-skills/statsmodels/SKILL.md
peerK-Dense-AI/scientific-agent-skillsskills/statsmodels/SKILL.md
peerforyourhealth111-pixel/Vibe-Skillsbundled/skills/statsmodels/SKILL.md
peersickn33/agentic-awesome-skillsplugins/agentic-awesome-skills-claude/skills/statsmodels/SKILL.md
inferiorbrycewang-stanford/Auto-Empirical-Research-Skillsskills/17-DAAF-Contribution-Community-daaf/dot-claude/skills/statsmodels/SKILL.md
inferiorFreedomIntelligence/OpenClaw-Medical-Skillsskills/statsmodels/SKILL.md
adaptersickn33/agentic-awesome-skillsplugins/agentic-awesome-skills/skills/statsmodels/SKILL.md
adaptersickn33/agentic-awesome-skillsskills/statsmodels/SKILL.md

Combined skill

---
name: statsmodels
description: Statistical models library for Python. Use when you need specific model classes (OLS, GLM, mixed models, ARIMA) with detailed diagnostics, residuals, and inference.
license: BSD-3-Clause license
metadata:
    skill-author: K-Dense Inc.
---

# Statsmodels: Statistical Modeling and Econometrics

## Overview

Statsmodels is Python's premier library for statistical modeling, providing tools for estimation, inference, and diagnostics. Apply this skill for rigorous statistical analysis, from simple linear regression to complex time series models.

## Compatibility and Setup

- **Version Pinning**: Use statsmodels 0.15.0 with Python 3.12+ (NumPy 2.5.3, SciPy 1.18.1).
- **Imports**: Use `statsmodels.api` for stable high-level imports.
- **API Changes**: In 0.15, use `result_object=True` for ADF/KPSS tests and `rng=` instead of `seed`.

## When to Use This Skill

- Fitting regression models (OLS, WLS, GLS, quantile regression)
- Performing generalized linear modeling (logistic, Poisson, Gamma, etc.)
- Analyzing discrete outcomes (binary, multinomial, count, ordinal)
- Conducting time series analysis (ARIMA, SARIMAX, VAR, forecasting)
- Running statistical tests and diagnostics

## Best Practices

1. **Data Preparation**:
   - **Intercept**: Always add a constant for array-based models (`sm.add_constant`).
   - **Missing Values**: Use `missing="raise"` during construction to catch unexpected NaNs.
   - **Scaling**: Record units and estimate scaling on training data only.

2. **Model Building**:
   - Start with a simple model and add complexity as needed.
   - Match the model to the outcome type (e.g., Logit for binary, Poisson for counts).

3. **Inference**:
   - Report effect sizes and confidence intervals, not just p-values.
   - Use robust standard errors when heteroskedasticity or clustering is present.

4. **Model Evaluation**:
   - Check residuals (plot vs fitted, Q-Q plot).
   - Use AIC/BIC only for comparable likelihoods on the same response and rows.

## Quick Start Examples

### Linear Regression (OLS)

```python
import statsmodels.api as sm

X = sm.add_constant(X_data)
model = sm.OLS(y, X)
results = model.fit()
print(results.summary())
```

### Time Series (ARIMA)

```python
from statsmodels.tsa.arima.model import ARIMA
from statsmodels.tsa.stattools import adfuller

# Check stationarity
adf_result = adfuller(y_series, result_object=True)
print(f"ADF p-value: {adf_result.pvalue:.4f}")

model = ARIMA(y_series, order=(1, 1, 1))
results = model.fit()
forecast = results.get_forecast(steps=10).summary_frame()
```

## Reporting

- Use `.summary()` for detailed output.
- Document transformations and excluded observations.
- Interpret coefficients carefully, accounting for link functions (e.g., exp(β) for log link).