lm_each_eclairs | R Documentation |
Fit linear model on each feature after applying decorrelation projection to response and predictors.
lm_each_eclairs(
formula,
data,
X,
ecl,
subset,
weights,
na.action,
method = "qr",
model = TRUE,
x = FALSE,
y = FALSE,
qr = TRUE,
singular.ok = TRUE,
contrasts = NULL,
offset,
...
)
formula |
an object of class 'formula' (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
data |
a matrix or data.frame containing the variables in the model |
X |
matrix or data.frame where each column stores a predictor to be evaluated by the regression model one at a time. The |
ecl |
estimate of covariance/correlation matrix from eclairs storing |
subset |
same as for lm |
weights |
same as for lm |
na.action |
same as for lm |
method |
same as for lm |
model |
same as for lm |
x |
same as for lm |
y |
same as for lm |
qr |
same as for lm |
singular.ok |
same as for lm |
contrasts |
same as for lm |
offset |
same as for lm |
... |
other arguments passed to |
data.frame with columns beta
, se
, tsat
, pvalue
storing results for regression model fit for each feature
library(Rfast)
n <- 800 # number of samples
p <- 200 # number of features
# create correlation matrix
Sigma <- autocorr.mat(p, .9)
# draw data from correlation matrix Sigma
Y <- rmvnorm(n, rep(0, p), sigma = Sigma * 5.1, seed = 1)
# eclairs decomposition
ecl <- eclairs(Y)
# simulate covariates
data <- data.frame(matrnorm(p, 2, seed = 1))
colnames(data) <- paste0("v", 1:2)
# simulate response
y <- rnorm(p)
# Simulate 1000 features to test
X <- matrnorm(p, 1000, seed = 1)
colnames(X) <- paste0("set_", seq(ncol(X)))
# Use linear model to test each feature stored as columns in X
res <- lm_each_eclairs(y ~ v1 + v2, data, X, ecl)
head(res)
# Analysis after non-linear transform
#------------------------------------
# Apply function to transforme data
f <- function(x) log(x^2 + 0.001)
# evaluate covariance of transformed data
ecl_transform <- cov_transform(ecl, f, 100)
# Use linear model to test each feature stored as columns in X
# in data transformed by f()
res2 <- lm_each_eclairs(f(y) ~ v1 + v2, data, X, ecl_transform)
head(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.