statsmodels
Statsmodels delivers rigorous statistical inference through comprehensive model estimation, diagnostic testing, and publication-ready summaries. It excels at linear and generalized linear regression, time series modeling, ANOVA, survival analysis, and causal inference—all with the p-values and confidence intervals essential for academic and scientific work.
Statsmodels performs statistical inference with detailed diagnostics, p-values, and confidence intervals for regression and hypothesis testing.
AI-generated summary based on this skill's SKILL.md
Install
tondevrel/scientific-agent-skills/statsmodels
git clone https://github.com/tondevrel/scientific-agent-skills
cp -r scientific-agent-skills/skills/statsmodels ~/.claude/skills/statsmodelsFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I perform OLS linear regression in Python using statsmodels?
Statsmodels makes OLS regression straightforward with its formula interface. Import `statsmodels.formula.api as smf`, define your model using R-style syntax (e.g., `smf.ols('y ~ x1 + x2', data=df)`), then call `.fit()` to estimate coefficients. The resulting summary includes p-values, confidence intervals, R-squared, and diagnostic statistics—everything needed for publication.
What regression models does statsmodels support?
Statsmodels supports OLS (ordinary least squares), GLM (generalized linear models), logistic regression, Poisson regression for count data, weighted least squares (WLS) for heteroscedastic data, and many specialized models. Each provides detailed diagnostics, p-values, and confidence intervals for rigorous statistical inference.
Can statsmodels perform ARIMA time series forecasting?
Yes. Statsmodels includes ARIMA and SARIMAX for time series analysis and forecasting. Use `statsmodels.tsa.arima.model.ARIMA` to fit autoregressive integrated moving average models, or `SARIMAX` for seasonal variants. Both support diagnostic plots, in-sample fit statistics, and out-of-sample predictions.
How does statsmodels handle hypothesis testing and p-values?
Statsmodels delivers comprehensive hypothesis testing through model summaries that report p-values, confidence intervals, and test statistics for each coefficient. It supports t-tests, F-tests, Wald tests, and likelihood ratio tests. The `.summary()` method generates publication-ready tables with all diagnostic information.
What causal inference and treatment effect methods are available?
Statsmodels supports causal inference through regression-based treatment effect estimation, instrumental variables (IV/2SLS), and difference-in-differences models. These methods estimate average treatment effects while controlling for confounders, with p-values and confidence intervals for rigorous causal claims.
How can I check for multicollinearity and heteroscedasticity in statsmodels?
Statsmodels provides residual diagnostics and tests for model assumptions. Calculate variance inflation factors (VIF) to detect multicollinearity, use Breusch-Pagan or White tests for heteroscedasticity, and examine residual plots. The `.summary()` output includes Durbin-Watson statistics and other diagnostic metrics for comprehensive model validation.
SKILL.md
rendered from the published skill — quoted content, verbatim
Statsmodels - Statistical Modeling & Inference
Statsmodels is the bridge between Python and the rigor of R-style statistical analysis. It allows users to estimate models using formulas (via patsy), perform extensive diagnostic tests, and produce detailed summary tables that are the standard in academic publishing.
When to Use
- Estimating Linear Regression models with detailed diagnostics (OLS, WLS).
- Generalized Linear Models (GLM): Logistic, Poisson, Gamma regression.
- Time Series Analysis (ARIMA, SARIMAX, VAR, State Space
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
skills/statsmodels/SKILL.md