compute_summary_statistics | R Documentation |
This is a function provided in the package of "susieR", Wang et al (2020) <doi:10.1101/501114>, for performing the univariate linear regression y ~ x separately for each column x of X to generate summary statistics. Each regression is implemented using .lm.fit(). The estimated effect size and stardard error for each variable are outputted.
compute_summary_statistics(X, y, Z = NULL, center = TRUE,
scale = TRUE, return_residuals = FALSE)
X |
n by p matrix of regressors. |
y |
n-vector of response variables. |
Z |
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. |
center |
If center = TRUE, center X, y and Z. |
scale |
If scale = TRUE, scale X, y and Z. |
return_residuals |
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.
# Example
set.seed(1)
n = 400
p = 500
beta = rep(0,p)
beta[1] = 1
X = matrix(rnorm(n*p),nrow = n,ncol = p)
X = scale(X,center = TRUE,scale = TRUE)
y = drop(X %*% beta + rnorm(n))
SS=compute_summary_statistics(X,y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.