big_univLinReg {bigstatsr} | R Documentation |
Column-wise linear regression
Description
Slopes of column-wise linear regressions of each column of a Filebacked Big Matrix, with some other associated statistics. Covariates can be added to correct for confounders.
Usage
big_univLinReg(
X,
y.train,
ind.train = rows_along(X),
ind.col = cols_along(X),
covar.train = NULL,
thr.eigval = 1e-04,
ncores = 1
)
Arguments
X |
An object of class FBM. |
y.train |
Vector of responses, corresponding to |
ind.train |
An optional vector of the row indices that are used, for the training part. If not specified, all rows are used. Don't use negative indices. |
ind.col |
An optional vector of the column indices that are used. If not specified, all columns are used. Don't use negative indices. |
covar.train |
Matrix of covariables to be added in each model to correct
for confounders (e.g. the scores of PCA), corresponding to |
thr.eigval |
Threshold to remove "insignificant" singular vectors.
Default is |
ncores |
Number of cores used. Default doesn't use parallelism. You may use nb_cores. |
Value
A data.frame with 3 elements:
the slopes of each regression,
the standard errors of each slope,
the t-scores associated with each slope. This is also an object of class
mhtest
. Seemethods(class = "mhtest")
.
See Also
Examples
set.seed(1)
X <- big_attachExtdata()
n <- nrow(X)
y <- rnorm(n)
covar <- matrix(rnorm(n * 3), n)
X1 <- X[, 1] # only first column of the Filebacked Big Matrix
# Without covar
test <- big_univLinReg(X, y)
## New class `mhtest`
class(test)
attr(test, "transfo")
attr(test, "predict")
## plot results
plot(test)
plot(test, type = "Volcano")
## To get p-values associated with the test
test$p.value <- predict(test, log10 = FALSE)
str(test)
summary(lm(y ~ X1))$coefficients[2, ]
# With all data
str(big_univLinReg(X, y, covar = covar))
summary(lm(y ~ X1 + covar))$coefficients[2, ]
# With only half of the data
ind.train <- sort(sample(n, n/2))
str(big_univLinReg(X, y[ind.train],
covar.train = covar[ind.train, ],
ind.train = ind.train))
summary(lm(y ~ X1 + covar, subset = ind.train))$coefficients[2, ]