statsmodels: Econometric and Statistical Modeling with Python
Citation. Skipper Seabold and Josef Perktold. "Statsmodels: Econometric and Statistical Modeling with Python". Proceedings of the 9th Python in Science Conference (SciPy 2010), pp. 92–96. doi.org/10.25080/Majora-92bf1922-011. CC BY. The library: statsmodels.org, version 0.15.0, released 27 August 2026. Source: github.com/statsmodels/statsmodels, BSD 3-clause licence. It needs NumPy, SciPy, pandas and patsy.
Status. Used. The maintainer chose statsmodels as a core dependency (#315). open_familyoffice/econometrics.py wraps it with guards against look-ahead. It refits on an expanding window, its Granger tests name the cause, and its regimes are filtered only. A test fails if any module imports a two-sided smoother. The evaluator's own tests stay in the project's code.
Read. Read on 2026-11-28 through a subagent. It read the 2010 paper's PDF and the stable documentation of the eight module groups that #192 names. It read the source where the documentation is silent. Every page came through a fetch that summarises, so long passages weren't seen word for word. The pages of most single functions came back in full. The overview pages, the example notebooks and parts of the source came back only in part. The model-results page for Markov switching failed to load. Statements below about defaults come from the function signatures and the source.
Summary
Claim. The 2010 paper presents statsmodels as a library for statistical and econometric models in Python. Its results are tested against R, SAS and Stata, or against simulations where no other package has them. The authors called it "very much still a work in progress". In 2010 it had linear and generalized regression and outlier-resistant fits, and its time-series models were in development.
Method. A library. The modules that #192 asks about, and what each computes by default:
- Standard errors under heteroskedasticity and autocorrelation. Regression results take
cov_type: HC0 to HC3, HAC (Newey–West, Bartlett kernel) and cluster errors. HAC needsmaxlagsfrom the user, with no automatic rule on that path. The small-sample correction is off by default. - Multiple testing.
multipletestsoffers Bonferroni, Holm, Holm–Šidák, Hochberg, Hommel and the Benjamini–Hochberg and Benjamini–Yekutieli FDR rules, among others. Its default is Holm–Šidák. None is a resampling method. - Unit roots and cointegration. ADF (lag chosen by AIC), KPSS, Zivot–Andrews (one break), Engle–Granger and Johansen. Johansen gives critical values only, not p-values, and only up to 12 series.
- VAR and VECM. Granger tests, impulse responses and variance decompositions. A VAR fits one lag unless the user asks for a criterion. Impulse responses are orthogonalised by a Cholesky factor, so they depend on the order of the series.
- Regime switching. Markov regression and autoregression, fitted through the Hamilton filter, with filtered and smoothed probabilities of each regime.
- State space. The Kalman filter and smoother, unobserved components and SARIMAX.
append(refit=True)re-estimates on more data, andextendfilters new data with fixed parameters. - Diagnostics. Ljung–Box, ARCH and Breusch–Pagan tests, and Jarque–Bera and omnibus normality tests.
- Smoothing. The HP filter, STL, LOWESS, exponential smoothing, and the Baxter–King and Christiano–Fitzgerald filters.
Findings, as the source reports them. These are the defaults and limits that matter for a backtest.
| Setting | Number | Value |
|---|---|---|
HAC errors, get_robustcov_results |
automatic lag, and small-sample correction | none (maxlags required), and off |
multipletests |
default method | Holm–Šidák |
VAR.fit with no criterion |
lags | 1 |
coint_johansen |
p-values, and most series | none, and 12 |
acorr_ljungbox |
default lags | the smaller of 10 and n/5 |
| Releases | major, and patch | about every 3 years, several a year |
Where the claims go beyond the evidence
Full-sample estimates look like one-sided ones. A state-space model's in-sample predictions are one step ahead, but its parameters come from the whole sample. Smoothed regime probabilities use the whole sample, and the library's example plots only those. The HP filter, STL, LOWESS and the band-pass filters are two-sided. The documentation of most of these doesn't say so.
No refit loop. The documentation advises fitting on a training sample, then using extend or apply on later data. There is no built-in rolling or expanding refit, so each project writes its own.
Some numbers have been wrong. In September 2026 the project fixed five entries of the MacKinnon table behind the ADF p-values (issue #10271). An issue on the Johansen test's accuracy (#7334) is open. KPSS, Ljung–Box and the ACF return confident results on a constant series (#10647). Markov-switching fits can fail to converge (#8416).
The API is still moving. The documentation marks the Markov-switching models and multipletests as subject to change, and calls one FDR method "not verified against another package".
Credit. The project tests against other packages and records each difference in its test suite. It releases often, fixes reported errors, and states in its documentation where a method is unverified or may change.
Use in this repo
The evaluator's statistics stay in the project. The repo already has, in plain Python and checked by mutation testing, the tests that the verdict rests on:
- Newey–West variance (
metrics.long_run_variance), PSR, DSR and the minimum track record (metrics.py). - Circular and stationary block bootstraps (
bootstrap.py). - SPA_c and studentized StepM (
selection.py), and the Ledoit–Wolf test (sharpe_test.py). - The effective number of trials (
independence.py).
statsmodels has no block bootstrap, DSR, PBO, SPA or StepM, so it would replace none of them. The arch package has SPA, StepM and block bootstraps. #315 proposes it as a development dependency, to cross-check the project's results in a test.
Where statsmodels would help. It fits models that the project doesn't have:
- unit roots and cointegration, before any test on persistent macro series (#137).
- VAR, Granger tests and impulse responses, as the first version of the dependency graph (#187,
pcmci.md). - Markov switching, for regimes (#233–#235).
- diagnostics on a strategy's returns, such as autocorrelation, ARCH and normality, before the harness trusts an i.i.d. formula (#8).
Guards against look-ahead. Each use above needs one, and #315 lists them:
- Refit in an expanding or rolling window.
- Use filtered regime probabilities, never smoothed ones.
- Use no two-sided smoother as a feature.
- Set HAC lags explicitly.
- Check a Granger test's column order, since
grangercausalityteststests whether the second column causes the first.
The verdict's look-ahead oracle (#12) can't see these leaks, because the leak is inside a fitted model, not in the data feed.
Multiple testing. multipletests gives the FDR rules that #94 and #187 need, but its default, Holm–Šidák, assumes independence or positive dependence. A graph's or a ledger's tests are dependent, so the resampling methods the project has (StepM) remain the first choice.
The decision. The project already has NumPy, SciPy and pandas through yfinance, so statsmodels would add itself and patsy. #315 proposes an optional extra, not a core dependency, so that the hourly tick and the evaluator don't load it. That is a question for the maintainer.