Safe Anytime Valid Inference for Linear Models
Overview
Anytime-valid inference for linear models, namely, sequential t-tests, sequential F-tests, and confidence sequences with time-uniform Type-I error and coverage guarantees. This allows hypotheses to be continuously tested without sacrificing false positive guarantees. Heteroskedasticity-robust and cluster-robust versions are provided. It is based on the methods documented in Lindon et al. (2026) doi:10.1080/01621459.2026.2692052 and Lindon (2026) doi:10.48550/arXiv.2610.25613.
New Features
av.lm()gains aclusterargument for CR1 cluster-robust standard errors (the sandwich scaled byG / (G - 1), without Stata/fixest's extra(n - 1) / (n - k)). Whenclusteris supplied, the anytime-valid p-values, F-test, and confidence intervals useG - 1(clusters minus one) as the denominator degrees of freedom, rather thann - p(observations minus coefficients).clustercannot be combined withvcov_estimator. The method is described in Lindon (2026), "Anytime-Valid Inference in Linear Models with Clustered Outcomes: Exact Multivariate Tests and Cluster-Robust Confidence Sequences", <https://arxiv.org/abs/2610.25613>.clusteraccepts a vector of cluster identifiers, a one-sided formula (cluster = ~ cyl), or a column name (cluster = "cyl"). Formulas and column names are looked up in the model'sdataand aligned with the observations used in the fit.- With
cluster, the anytime-valid sample size is the number of clustersG, sogis on the cluster scale, and the joint F-test uses the cluster-robust e-value with exponentG/2. The F-test p-value is 1 when the cluster-robust covariance of the tested coefficients is singular (e.g. fewer clusters than tested coefficients).
Show all changes in 0.2.0Hide the rest of the changes in 0.2.0
vcov()on anavlmobject returns the covariance used for inference (classical, HC or CR1).optimal_g()gains anuargument, so it can tunegfor cluster-robust inference (optimal_g(G, nu = G - 1, alpha = 0.05)).- The summary prints the value of
g.
Bug Fixes
- The heteroskedasticity-robust (
vcov_estimator) F-test now uses the Wald statistic of the tested coefficients, inverting their covariance rather than taking a block of the full precision matrix, and stores it asQ / d. Previously the evidence was overstated when testing more than one coefficient. confint()no longer misplaces intervals when the fit has aliased (NA) coefficients; previously every coefficient after an aliased one gotNAor the wrong standard error. Heteroskedasticity- and cluster-robust summaries of such fits no longer fail with a singular-matrix error.- Heteroskedasticity- and cluster-robust standard errors now account for
weights(rows and residuals are scaled bysqrt(w); zero weights are dropped). Previously the weights were ignored, giving wrong standard errors for weighted fits. - Intercept-only models now work with
vcov_estimatorandcluster. clusternow accepts one observation per cluster, which gives the HC0 sandwich scaled byn / (n - 1).optimal_g()now searches belowg = 1, where the optimum lies for small samples.- Anytime-valid ANOVA p-values use the number of observations as the sample size; models without an intercept were off by one.
av()checks thatgis a single positive number and gives informative errors forglm, multivariate (mlm) and multi-stratum (Error()) fits instead of failing later or returning meaningless output.
Internal
- The classical, heteroskedasticity-robust and cluster-robust code paths share one covariance routine, and unused helpers were removed.
From NEWS.md in the release
Install
Health
- OK13 OK2026-09-08
- ERROR12 OK, 1 ERROR2026-09-07
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 16 (6 internal)
- Examples that run
- 100%5 run in a plain check
- Exported functions with examples
- 50%
- Documented parameters
- 100%
- Return-value docs
- 100%
- Help pages citing references
- 13%
Downloads
Dependencies
Installing avlm adds no packages beyond those that come with R.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- 0.2.0Latest2026-10-21 · current release · diff ↗ ·
22 hours in CRAN's queue
Listed in CRAN's incoming queue from 2026-10-20 17:40 to 2026-10-21 15:47 UTC, in 6 readings. - RR 4.6.0 released · 2026-04-24
- 0.1.02025-04-23
- RR 4.5.0 released · 2025-04-11
Package metadata
- First published
- 2025-04-23
- Total releases
- 2 / 1 yrs
- License
- MIT + file LICENSE OSI
- Download size
- 22 KB
Cite
Cite this package
Run in R for the authors' entry:
citation("avlm")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.1080/01621459.2026.2692052.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.