R/univariate_regression.R
univariate_regression.Rd
This function performs the univariate linear
regression y ~ x separately for each column x of X. Each regression
is implemented using .lm.fit()
. The estimated effect size
and stardard error for each variable are outputted.
univariate_regression(
X,
y,
Z = NULL,
center = TRUE,
scale = FALSE,
return_residuals = FALSE
)
n by p matrix of regressors.
n-vector of response variables.
Optional n by k matrix of covariates to be included in all
regresions. If Z is not NULL
, the linear effects of
covariates are removed from y first, and the resulting residuals
are used in place of y.
If center = TRUE
, center X, y and Z.
If scale = TRUE
, scale X, y and Z.
Whether or not to output the residuals if Z
is not NULL
.
A list with two vectors containing the least-squares
estimates of the coefficients (betahat
) and their standard
errors (sebetahat
). Optionally, and only when a matrix of
covariates Z
is provided, a third vector residuals
containing the residuals is returned.