LinearRegression
linear_regression.LinearRegression(self , alpha, p, phi= 1 )
Covariate adjusted t-tests from Lindon et al. (2024 ) .
Coefficients and covariance matrix are calculated using the Recursive Least Squares algorithm.
Parameters
alpha
float
Probability of Type I error \(\alpha\) .
required
p
int
Number of covariates \(p\) .
required
phi
float
Prior scale \(\phi\) .
1
Attributes
Xty
Sum of products of covariates and response \(X^T y\) .
beta
Estimate of regression coefficients \(\hat{\beta}\) .
covariance
Estimate of covariance matrix \(\hat{\Sigma}\) .
phi
Prior scale \(\phi\) .
yty
Sum of squared response values \(y^T y\) .
Methods
nu
Degrees of freedom.
predict
Predict values for given covariates.
sigma
Estimate the standard deviation of the error term.
sse
Compute the Sum of Squared Errors (SSE).
standard_errors
Estimate the standard errors of the coefficients.
t_stats
Calculate the t statistics of the coefficients.
update
Update the model with new data.
z2
Calculate the squared z-scores.
nu
linear_regression.LinearRegression.nu()
Degrees of freedom.
predict
linear_regression.LinearRegression.predict(X)
Predict values for given covariates.
Parameters
X
np.ndarray
Matrix of covariates.
required
sigma
linear_regression.LinearRegression.sigma()
Estimate the standard deviation of the error term.
sse
linear_regression.LinearRegression.sse()
Compute the Sum of Squared Errors (SSE).
standard_errors
linear_regression.LinearRegression.standard_errors()
Estimate the standard errors of the coefficients.
t_stats
linear_regression.LinearRegression.t_stats()
Calculate the t statistics of the coefficients.
update
linear_regression.LinearRegression.update(yx)
Update the model with new data.
Parameters
yx
np.ndarray
Array of response and covariate values \([y, x_1, \dots, x_p]\) .
required
z2
linear_regression.LinearRegression.z2()
Calculate the squared z-scores.
References
Lindon, Michael, Dae Woong Ham, Martin Tingley, and Iavor Bojinov. 2024.
“Anytime-Valid Linear Models and Regression Adjusted Causal Inference in Randomized Experiments.” https://arxiv.org/abs/2210.08589 .