sweepystats.linreg.LinearRegression#
- class sweepystats.linreg.LinearRegression(X, y, weights=None)#
A class to perform linear regression based on the sweep operation.
- Parameters:
- Xarray-like
Design matrix of shape (n, p)
- yarray-like
Response vector of shape (n,)
- weightsarray-like, optional
Weight vector of shape (n,). If provided, performs weighted least squares. Weights should be non-negative. If None (default), performs ordinary least squares.
- __init__(X, y, weights=None)#
Methods
R2()Computes the R² (coefficient of determination) of fit.
__init__(X, y[, weights])coef()Fitted coefficient values (beta hat).
coef_std()Standard deviation of the fitted coefficient values
cov()Estimated variance-covariance of beta hat, i.e. Var(b) = sigma2 * inv(X'X).
exclude_k(k[, force])Exclude the `k`th variable in regression
f_test(k)Tests whether the `k`th variable is significant by performing an F-test. The model must already be fitted. .
fit([verbose])Perform least squares fitting by sweeping in all variables.
include_k(k[, force])Include the `k`th variable in regression
resid()Estimate of residuals = ||y - yhat||^2
sigma2()Estimate of sigma square.