Tools · SPBoucher
Menu

statsmodels

In-depth entry

by 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

BSD-3-Clause licenseFreeOpen sourceLocalSelf-hostable
Visit official site Compare

Link verified Nov 2, 2026

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

  1. Regression tables for a working paper exported from summary objects
  2. Event-study or difference-in-differences with clustered standard errors
  3. ARIMA/state-space forecasting of macro series
  4. 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
Compare statsmodels with its alternatives →

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.

  • License
    statsmodels LICENSE.txt

    https://github.com/statsmodels/statsmodels/blob/main/LICENSE.txt

    Supports: license_spdx, source_model

    checked Nov 1, 2026
  • Official documentation
    statsmodels documentation — statsmodels 0.15.0

    https://www.statsmodels.org/stable/index.html

    Supports: capabilities, description, license_spdx

    checked Nov 1, 2026
  • Official site
    statsmodels

    https://www.statsmodels.org/

    Supports: name, summary

    checked Nov 1, 2026
  • Repository
    statsmodels/statsmodels

    https://github.com/statsmodels/statsmodels

    Supports: repo_url, languages

    checked Nov 1, 2026
Confidence
High
Reviewed
Nov 1, 2026
Links
Verified · Nov 2, 2026

Spotted an error?

Broken link, outdated license, wrong category, or a tool that no longer exists? Tell us; reports are reviewed by the editor.

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

MITFreeOpen sourceLocalNov 2, 2026

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

MITFreeOpen sourceLocalNov 2, 2026

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

ProprietaryPaidAcademicLocalNov 2, 2026

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

GPL-3.0-onlyFreeOpen sourceLocalNov 2, 2026