Skip to content

Add SAVI e-values for linear regression - #9868

Open
michaellindon wants to merge 11 commits into
statsmodels:mainfrom
michaellindon:anytime_valid_linear_models
Open

Add SAVI e-values for linear regression#9868
michaellindon wants to merge 11 commits into
statsmodels:mainfrom
michaellindon:anytime_valid_linear_models

Conversation

@michaellindon

@michaellindon michaellindon commented Jun 26, 2026

Copy link
Copy Markdown

Summary

This PR adds support for safe anytime-valid inference (SAVI) for linear regression results, based on Lindon et al. (2026), "Anytime-Valid Inference in Linear Models with Applications to Regression-Adjusted Causal Inference," Journal of the American Statistical Association

The implementation reuses statsmodels' existing t and F statistics, including the active covariance estimator. This keeps the implementation thin while making e-values, SAVI p-values, and confidence sequences available from fitted regression results.

Motivation

This is useful from three related perspectives.

Anytime-valid inference

Classical regression p-values and confidence intervals are fixed-sample objects. They are not generally valid under continuous monitoring or optional stopping. SAVI replaces these with e-processes and confidence
sequences that remain valid over time, allowing users to monitor results as data accumulate while preserving time-uniform Type I error and coverage guarantees.

See Ramdas et al., "Game-theoretic statistics and safe anytime-valid inference".

Multiple testing

E-values are useful beyond sequential monitoring. They can be combined with multiple-testing procedures such as e-BH, which provides an e-value analogue of Benjamini-Hochberg and controls FDR under arbitrary dependence
between e-values. This makes e-values attractive for dependent regression screens, structured hypothesis tests, and exploratory workflows where many hypotheses are considered.

See Wang and Ramdas, "False discovery rate control with e-values".

Post-selection inference

Confidence intervals obtained by inverting e-values, or e-CIs, have strong post-selection properties. They can be adjusted after arbitrary data-dependent selection while controlling false coverage rate under arbitrary
dependence. This makes confidence sequences/e-CIs especially useful after model selection, variable screening, or exploratory regression analysis.

See Xu, Wang, and Ramdas, "Post-selection inference for e-value based confidence intervals".

API

This PR adds:

  • RegressionResults.e_values(..., g=...) for parameter-wise t tests or joint linear restrictions via F tests.
  • RegressionResults.p_values(savi=True, g=...) for reciprocal e-values as SAVI p-values.
  • RegressionResults.conf_int(savi=True, g=...) for parameter-wise confidence-sequences/e-CIs.
  • RegressionResults.summary(savi=True, g=...) to display e-values and confidence sequences in the regression summary table, including replacing the model-level Prob (F-statistic) with an F-test e-value.
  • RegressionResults.sequential_p_values(..., g=...) and RegressionResults.confidence_sequences(..., g=...) as explicit aliases for users who prefer sequential-inference terminology.

Classical behavior is unchanged unless savi=True is requested.

Example

The example below uses the full statsmodels Longley dataset:

from statsmodels.datasets import longley
from statsmodels.regression.linear_model import OLS
from statsmodels.tools.tools import add_constant

data = longley.load_pandas()
y = data.endog
X = add_constant(data.exog, prepend=False)

res = OLS(y, X).fit()
print(res.summary(savi=True))
                            OLS Regression Results
==============================================================================
Dep. Variable:                 TOTEMP   R-squared:                       0.995
Model:                            OLS   Adj. R-squared:                  0.992
Method:                 Least Squares   F-statistic:                     330.3
Date:                Fri, 26 Jun 2026   e (F-statistic):              2.04e+05
Time:                        13:17:08   Log-Likelihood:                -109.62
No. Observations:                  16   AIC:                             233.2
Df Residuals:                       9   BIC:                             238.6
Df Model:                           6
Covariance Type:            nonrobust
==============================================================================
                 coef    std err          t          e      [0.025      0.975]
------------------------------------------------------------------------------
GNPDEFL       15.0619     84.915      0.177      0.247    -312.329     342.453
GNP           -0.0358      0.033     -1.070      0.425      -0.165       0.093
UNEMP         -2.0202      0.488     -4.136     29.336      -3.903      -0.137
ARMED         -1.0332      0.214     -4.822     70.649      -1.859      -0.207
POP           -0.0511      0.226     -0.226      0.249      -0.923       0.821
YEAR        1829.1515    455.478      4.016     24.928      73.044    3585.258
const      -3.482e+06    8.9e+05     -3.911     21.587   -6.92e+06   -4.92e+04
==============================================================================

Testing

Tests cover:

  • e-values from t and F statistics,
  • SAVI p-values as reciprocal e-values,
  • confidence sequences containing classical confidence intervals,
  • robust covariance behavior,
  • summary(savi=True) replacing coefficient p-values, coefficient intervals, and the model-level F-test p-value,
  • validation of g and alpha,
  • convergence of the finite-sample e-process expression to the asymptotic Gaussian e-process for large n.
  • numerical agreement with the avlm CRAN package on the same input data, up to floating-point precision.

@michaellindon

Copy link
Copy Markdown
Author

Please let me know if you have any feedback concerning the API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant