statsmodels
In-depth entryby statsmodels developers (NumFOCUS) · Library
Python library for estimating statistical and econometric models with R-style formulas, rich result summaries and tests: OLS, GLM, discrete choice, ARIMA, state space, VAR and more
Overview
statsmodels is the main Python library for classical statistical modelling and econometrics, released under the Modified BSD (3-clause) license and fiscally sponsored by NumFOCUS. It provides estimators with full inference output in the style of R or Stata: linear regression (OLS, WLS, GLS, quantile regression), generalized linear models, robust linear models, discrete-choice models (logit, probit, multinomial, count models), mixed-effects models, generalized estimating equations, survival analysis, nonparametric methods and a large statistics module with hypothesis tests, multiple-comparison corrections and diagnostics. Models can be specified with R-style formulas on pandas DataFrames or directly with arrays, and every estimator returns a results object with coefficients, standard errors (including heteroskedasticity- and cluster-robust options), tests and a text summary that is tested against reference implementations.
Time-series support is extensive: ARIMA and SARIMAX, exponential smoothing, unobserved-components and custom state-space models with Kalman filtering, VAR/VECM, dynamic factor models, Markov switching, unit-root and cointegration tests, seasonal decomposition and forecasting utilities. Version 0.15.0 is current at the time of writing.
statsmodels is the natural choice when a Python workflow needs inference rather than prediction, which distinguishes it from scikit-learn. It complements rather than replaces specialized packages: linearmodels adds panel, IV and system estimators; arch adds volatility models and bootstrap methods. Limitations include slower development of high-dimensional fixed-effects tools compared with R's fixest, a less uniform API across older and newer modules, and single-machine, in-memory execution.
Capabilities
- OLS, WLS, GLS and quantile regression with robust and clustered covariance
- Generalized linear and robust linear models
- Discrete choice and count models
- ARIMA/SARIMAX, exponential smoothing and state-space models
- VAR, VECM, dynamic factor and Markov-switching models
- Unit-root, cointegration and diagnostic tests
- R-style formula interface on pandas DataFrames
- Mixed-effects, GEE, survival and nonparametric methods
Typical workflows
- Regression tables for a working paper exported from summary objects
- Event-study or difference-in-differences with clustered standard errors
- ARIMA/state-space forecasting of macro series
- Pre-estimation diagnostics and hypothesis tests in a notebook
Strengths
- Inference-focused output comparable to R and Stata
- BSD-licensed and widely installed
- Deep time-series toolkit
- Results validated against reference packages
Limitations
- High-dimensional fixed effects slower than R's fixest
- API consistency varies across modules
- In-memory, single-node computation
- No built-in causal-ML estimators (see EconML, DoWhy)
Prerequisites
- Python with NumPy, SciPy and pandas
Who it is for
- Econometricians and applied statisticians using Python
- Data scientists needing inference and diagnostics
- Students moving from Stata or R to Python
Alternatives & comparison
scikit-learn optimizes for prediction and offers little inference; statsmodels is the inference counterpart. linearmodels and arch fill gaps (panel/IV/system models; GARCH and bootstraps) and share the same NumPy/pandas conventions. fixest in R and Stata's reghdfe remain faster for many-level fixed effects.
- arch (Python package)
Kevin Sheppard's Python package for univariate ARCH/GARCH volatility models, bootstraps, multiple-comparison procedures, unit-root and cointegration tests
Open sourceFree - DoWhy
Python causal-inference library organized around model, identify, estimate and refute steps, with graphical causal models for attribution, counterfactuals and root-cause analysis
Open sourceFree - EconML
Python library for heterogeneous treatment-effect estimation with machine learning: double ML, doubly robust learners, causal forests, meta-learners, IV and policy learning
Open sourceFree - EViews
Commercial Windows econometrics package for time-series estimation, forecasting and macro modelling, sold as single-user, volume, University and free Student Lite editions
ProprietaryPaid - fixest
R package for fast estimation of OLS, GLM, Poisson, IV and difference-in-differences models with many fixed effects, clustered errors, multiple estimations and publication tables
Open sourceFree - gretl
Free, GPL-licensed cross-platform econometrics program with a GUI, the hansl scripting language and estimators for time series, panels and limited dependent variables
Open sourceFree - linearmodels
Python package by Kevin Sheppard adding panel data, instrumental-variable, system (SUR/3SLS) and asset-pricing estimators missing from statsmodels
Open sourceFree - R
Language and environment for statistical computing and graphics, with the CRAN package archive and a strong base in academic statistics and econometrics
Open sourceOpen source - scikit-learn
BSD-licensed Python machine-learning library for classification, regression, clustering, dimensionality reduction, preprocessing and model selection on NumPy and SciPy
Open sourceFree - SciPy
Core open-source Python library for scientific computing on NumPy arrays: optimization, integration, interpolation, linear algebra, sparse matrices, statistics, signal processing
Open sourceFree - Stata
Commercial statistical software from StataCorp widely used in economics and social science, with editions BE/SE/MP, a command language, Mata and comprehensive PDF manuals
ProprietaryPaid
Sources & verification
Primary sources consulted for this record. Claims are tied to the fields each source supports; the automated link checker re-verifies every URL on a schedule.
- Licensestatsmodels LICENSE.txtchecked Nov 1, 2026
https://github.com/statsmodels/statsmodels/blob/main/LICENSE.txt
Supports: license_spdx, source_model
- Official documentationstatsmodels documentation — statsmodels 0.15.0checked Nov 1, 2026
https://www.statsmodels.org/stable/index.html
Supports: capabilities, description, license_spdx
- Official sitechecked Nov 1, 2026
- Repositorychecked Nov 1, 2026
- Confidence
- High
- Reviewed
- Nov 1, 2026
- Links
- Verified · Nov 2, 2026
Spotted an error?
More in Econometrics & causal inference
EconML
PyWhy (originally Microsoft Research) · Econometrics & causal inference
Python library for heterogeneous treatment-effect estimation with machine learning: double ML, doubly robust learners, causal forests, meta-learners, IV and policy learning
DoWhy
PyWhy (originally Microsoft Research) · Econometrics & causal inference
Python causal-inference library organized around model, identify, estimate and refute steps, with graphical causal models for attribution, counterfactuals and root-cause analysis
EViews
S&P Global (EViews) · Econometrics & causal inference
Commercial Windows econometrics package for time-series estimation, forecasting and macro modelling, sold as single-user, volume, University and free Student Lite editions
gretl
gretl developers (Allin Cottrell, Riccardo Lucchetti) · Econometrics & causal inference
Free, GPL-licensed cross-platform econometrics program with a GUI, the hansl scripting language and estimators for time series, panels and limited dependent variables