Fit linear model after applying decorrelation projection to response and predictors.
Usage
lm_eclairs(
formula,
data,
ecl,
subset,
weights,
na.action,
method = "qr",
model = TRUE,
x = FALSE,
y = FALSE,
qr = TRUE,
singular.ok = TRUE,
contrasts = NULL,
offset,
...
)
Arguments
- 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
- ecl
estimate of covariance/correlation matrix from eclairs storing \(U\), \(d_1^2\), \(\lambda\) and \(\nu\)
- 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
- ...
same as for lm
Value
Object of class lm
returned by function lm
Details
This function fit a linear regression to the transformed response, and transformed design matrix. Note that the design matrix, not just the data.frame of variables is transformed so that 1) factors are transformed and 2) the intercept term is transformed.
Examples
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)
# fit linear model on transformed data
lm_eclairs(y ~ v1 + v2, data, ecl)
#>
#> Call:
#> lm_eclairs(formula = y ~ v1 + v2, data = data, ecl = ecl)
#>
#> Coefficients:
#> (Intercept) v1 v2
#> 0.06477 0.07013 -0.13982
#>