linearmodels
Linear Panel, Instrumental Variable, Asset Pricing, and System Regression models for Python
What it is and what it does
Linearmodels extends statsmodels with specialized econometric and financial regression estimators. It provides panel data models (fixed effects, first difference, between, pooled, Fama-MacBeth), instrumental variable methods (2SLS, LIML, k-class, GMM), high-dimensional regression via absorbing least squares, factor asset pricing models, and system regression (SUR, 3SLS, GMM system). The package is designed to work with NumPy, Pandas, and xarray data structures and supports formula-based model specification using formulaic.
The package targets econometricians, financial researchers, and data scientists working with panel data, endogenous regressors, or multi-equation systems. It builds on statsmodels' foundation but adds specialized estimators not available in the base library. Installation requires seven runtime dependencies (numpy, pandas, scipy, statsmodels, mypy_extensions, pyhdfe, formulaic), and the package is actively maintained with support for current Python versions.
Use it for:
- Estimate panel regression models with entity and time fixed effects on longitudinal firm or country data.
- Perform instrumental variable regression when regressors are endogenous, using 2SLS or GMM estimators.
- Implement Fama-MacBeth cross-sectional regression for asset pricing factor models across time periods.
- Fit system regression models (SUR, 3SLS) when multiple equations share disturbances or have cross-equation constraints.
- Handle high-dimensional fixed effects using absorbing least squares for large categorical variables.
- Estimate k-class or continuously-updating GMM models for robust inference under weak instruments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides panel regression, instrumental variable estimators, system regression, and factor asset pricing models that extend statsmodels for econometric and financial analysis.
Yes, with conditions. Install if you need specialized econometric estimators (panel models, IV, system regression, asset pricing) beyond statsmodels' scope and can work with Python 3.10 or later. The package is actively maintained with no known vulnerabilities. Verify the NCSA license terms match your project's requirements before committing to production use.
Install
linearmodels on PyPI
pip
pip install linearmodelsuv
uv add linearmodelspoetry
poetry add linearmodelsInstalling linearmodels
Before you install
Medium install friction due to compiled wheels across multiple platforms and Python versions (3.10–3.13). Active maintenance with last commit on 2026-08-13 and 1060 repository stars indicate ongoing support.
License in practice
Licensed under NCSA with unclear treatment in the package metadata—verify the actual license terms before use in proprietary or restricted contexts.
Quickstart
pip install linearmodels
from linearmodels import PanelOLS
import numpy as np
from statsmodels.datasets import grunfeld
data = grunfeld.load_pandas().data
data.year = data.year.astype(np.int64)
data = data.set_index(['firm','year'])
mod = PanelOLS(data.invest, data[['value','capital']], entity_effects=True)
res = mod.fit(cov_type='clustered', cluster_entity=True)
Requires Python 3.10 or later; depends on numpy, pandas, scipy, and statsmodels at specified minimum versions.
Verify before relying
- Whether NCSA license treatment is suitable for your use case (commercial, proprietary, or restricted distribution).
- Performance characteristics and scalability limits for high-dimensional regression with absorbing least squares.
- Compatibility with xarray data structures beyond the stated optional support.
- Actual download volume and user base size to assess community support.
Package facts
| License | NCSA (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 7 — numpy, pandas, scipy, statsmodels, mypy_extensions, pyhdfe, formulaic |
| Maintenance | actively maintained — 297 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 440,109/month — #6,648 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: linearmodels-7.0-cp310-cp310-macosx_10_9_x86_64.whl; linearmodels-7.0-cp310-cp310-macosx_11_0_arm64.whl; linearmodels-7.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; linearmodels-7.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; linearmodels-7.0-cp310-cp310-musllinux_1_2_x86_64.whl; linearmodels-7.0-cp310-cp310-win_amd64.whl; linearmodels-7.0-cp311-cp311-macosx_10_9_x86_64.whl; linearmodels-7.0-cp311-cp311-macosx_11_0_arm64.whl; linearmodels-7.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; linearmodels-7.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; linearmodels-7.0-cp311-cp311-musllinux_1_2_x86_64.whl; linearmodels-7.0-cp311-cp311-win_amd64.whl; linearmodels-7.0-cp312-cp312-macosx_10_13_x86_64.whl; linearmodels-7.0-cp312-cp312-macosx_11_0_arm64.whl; linearmodels-7.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; linearmodels-7.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; linearmodels-7.0-cp312-cp312-musllinux_1_2_x86_64.whl; linearmodels-7.0-cp312-cp312-win_amd64.whl; linearmodels-7.0-cp313-cp313-macosx_10_13_x86_64.whl; linearmodels-7.0-cp313-cp313-macosx_11_0_arm64.whl
Keywords: linear models, regression, instrumental variables, IV, panel, fixed effects, clustered, heteroskedasticity, endogeneity, instruments, statistics, statistical inference, econometrics
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
archProvides ARCH/GARCH volatility models, unit…
unclear · top 5,000 on PyPI
pyfixestPyFixest performs fast high-dimensional fixed…
permissive · top 15,000 on PyPI
statsmodelsstatsmodels provides statistical models,…
permissive · top 1,000 on PyPI
spglmFits Gaussian, Poisson, QuasiPoisson, and…
permissive · top 15,000 on PyPI
pyhdfePyHDFE absorbs high-dimensional fixed effects…
permissive · top 15,000 on PyPI
pwlfFits continuous piecewise linear functions to…
permissive · top 15,000 on PyPI
rdrobustImplements regression discontinuity (RD) design…
copyleft · top 15,000 on PyPI
polars-olsPolars OLS provides Rust-optimized linear…
unclear · top 15,000 on PyPI
patsyPatsy converts R-style statistical formulas…
permissive · top 1,000 on PyPI
piecewise-regressionFits piecewise linear regression models to data…
permissive · top 15,000 on PyPI