statsmodels

Fit statistical models in Python with diagnostics, inference, and forecasting.

Updated Sep 2, 2026
One-click install
npx skills add https://github.com/ricfulop/cba-agentic-engineering-bootstrap --skill statsmodels-ricfulop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: statsmodels
Source: https://github.com/ricfulop/cba-agentic-engineering-bootstrap/tree/main/skills/statsmodels
Command: npx skills add https://github.com/ricfulop/cba-agentic-engineering-bootstrap --skill statsmodels-ricfulop

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires statsmodels, numpy, pandas, scipy, matplotlib, scikit-learn, and includes references (resource) components.

What problem does it solve? Running rigorous statistical analysis in Python often requires choosing the right model class, validating assumptions, and producing publication-ready inference tables, which is error-prone without structured guidance. ## Core Features & Use Cases - Regression and GLM Modeling: Fit OLS, WLS, GLS, quantile regression, logistic, Poisson, Negative Binomial, and mixed effects models with full coefficient tables and p-values. - Time Series Analysis: Build ARIMA, SARIMAX, VAR, and state space models with stationarity tests, ACF/PACF identification, and forecast intervals. - Diagnostics and Testing: Run heteroskedasticity, autocorrelation, normality, and influence tests, plus robust standard errors and power analysis. - Use Case: An economist analyzing survey data can fit a logistic regression, interpret odds ratios, check for influential observations with Cook's distance, and report cluster-robust standard errors in one workflow. ## Quick Start Fit an OLS regression of y on my predictors with statsmodels, show the summary table, and check the residuals for heteroskedasticity.

Frequently Asked Questions about statsmodels

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a linear regression in Python with statsmodels?

Use sm.OLS(y, X) after adding an intercept with sm.add_constant(X), then call .fit() and print results.summary() for coefficients, p-values, and R-squared. The formula API smf.ols('y ~ x1 + x2', data=df) handles categorical variables automatically.

How do I fit an ARIMA model for time series forecasting?

Use statsmodels.tsa.arima.model.ARIMA with an order tuple like (1,1,1), then call .fit() and .forecast(steps=n). First test stationarity with the ADF test and use ACF/PACF plots to identify p and q values.

statsmodels vs scikit-learn for regression, which should I use?

statsmodels provides detailed statistical inference including p-values, confidence intervals, and diagnostic tests, making it better for econometrics and research. scikit-learn focuses on prediction accuracy and pipelines without inference tables.

Why does my logistic regression fail to converge in statsmodels?

Non-convergence usually comes from perfect separation, where a predictor perfectly predicts the outcome, or from unscaled features. Check for separation, standardize continuous predictors, and inspect optimization warnings in the output.

When should I use Negative Binomial instead of Poisson regression?

Use Negative Binomial when count data shows overdispersion, meaning variance substantially exceeds the mean. Check the ratio of Pearson chi-squared to residual degrees of freedom; values above roughly 1.5 indicate Poisson is inappropriate.