crabbymetrics exposes hypothesis tests in two layers:
Fitted estimators with covariance support expose wald_test(...) methods for linear restrictions \(R\beta = q\).
TwoSLS also exposes anderson_rubin_test(...) for weak-IV-robust scalar endogenous-regressor tests.
Module-level helpers remain available for lower-level workflows: wald_test(coef, vcov, r, q=None), likelihood_ratio_test(...), and the shorter lr_test(...) alias.
The estimator method is the preferred path when the fitted object owns the covariance calculation.
import numpy as npimport crabbymetrics as cmrng = np.random.default_rng(123)x = rng.normal(size=(300, 3))y =1.0+ x @ np.array([0.0, 0.0, 0.8]) + rng.normal(scale=0.7, size=300)model = cm.OLS()model.fit(x, y)# Joint test that the first two slope coefficients are zero.R = np.array([ [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0],])model.wald_test(R, vcov="hc1")
For intercept-bearing estimators, the restriction matrix uses coefficient order [intercept, slopes...]. For fixed-effects summaries without an intercept, use the reported slope order.
The same test can be run manually from arrays when needed:
For IV models with one endogenous regressor, the Anderson Rubin method tests \(H_0: \beta = \beta_0\) by checking whether the excluded instruments predict y - beta0 * d after accounting for included exogenous regressors. This remains valid under weak instruments.
Likelihood-ratio tests are intentionally kept as array/scalar utilities for now, because they compare two nested likelihood values rather than one fitted covariance summary.