Sequentially valid supervised-learning inference from the OLS summary interface
1 Why Anytime-Valid?
Ordinary linear regression summaries are fixed-sample summaries. They are calibrated for a sample size chosen before looking at the data. Anytime-valid inference is useful when the same analysis might be checked repeatedly as observations arrive, because its p-values and confidence intervals are calibrated for optional stopping.
crabbymetrics exposes this through the usual OLS.summary(...) method rather than through a separate model class:
out = model.summary(vcov="vanilla", anytime_valid=True, g=g_star)
The coefficient estimates are still the ordinary least-squares estimates. The extra fields in the summary are the anytime-valid p-values, confidence intervals, and omnibus F-test p-value.
2 Confidence Sequences In The Supervised-Learning Workflow
The supervised-learning use case is monitoring a fitted regression task as more labeled observations arrive. A usual confidence interval answers a fixed-time question: if the analyst commits to one sample size in advance, how wide should the interval be? A confidence sequence answers the sequential version: if the analyst inspects the same coefficient path repeatedly over time, how should the inferential boundary be widened so coverage remains valid across those looks?
In this release the supported supervised-learning entry point is OLS. You fit the regression once on the current labeled design matrix, then request anytime-valid inference from the summary. The same idea can be used in a running evaluation loop by refitting as the sample grows and using the same summary fields for monitored coefficients.
This page uses the term confidence sequence for the sequentially valid coefficient intervals returned in confint. The output is still a finite-sample summary dictionary for the fitted model at the current sample size; crabbymetrics does not yet expose a streaming estimator object.
3 Data-Generating Example
This mirrors the structure of the avlm README example: three centered covariates, a binary treatment, and treatment-by-covariate interactions. The coefficient on trt is a baseline treatment effect, while the interaction coefficients allow that effect to vary with the covariates.
Show code
import numpy as npfrom html import escapefrom IPython.display import HTML, displayimport crabbymetrics as cmnp.set_printoptions(precision=4, suppress=True)def html_table(headers, rows): parts = ["<table>", "<thead>", "<tr>"] parts.extend(f"<th>{escape(str(header))}</th>"for header in headers) parts.extend(["</tr>", "</thead>", "<tbody>"])for row in rows: parts.append("<tr>") parts.extend(f"<td>{cell}</td>"for cell in row) parts.append("</tr>") parts.extend(["</tbody>", "</table>"])return"".join(parts)rng = np.random.default_rng(1)n =100x = rng.normal(size=(n, 3))x = x - x.mean(axis=0)trt = rng.choice([0.0, 1.0], size=n)noise = rng.normal(size=n)y = (1.0+1.4* x[:, 2]+2.3* trt+2.0* x[:, 0] * trt+3.0* x[:, 1] * trt+ noise)design = np.column_stack([x, trt, x * trt[:, None]])coef_names = ["Intercept", "X1", "X2", "X3", "trt", "X1:trt", "X2:trt", "X3:trt"]
4 Fit OLS Once
The fitted model is just cm.OLS(). The optimal_g(...) helper chooses the mixture precision parameter that minimizes the anytime-valid confidence-interval width at this target sample size and significance level.
The second argument to optimal_g is the total coefficient count, including the intercept fitted internally by OLS.