Fit regression model Y[j,] ~ design for each feature j
Usage
# S4 method for class 'sparseMatrix'
lmmFitResponses(
Y,
design,
Z,
Weights = NULL,
dcmpMethod = c("general", "categorical"),
REML = TRUE,
delta.range = c(-10, 10),
tol = 1e-06,
detail = 1,
lambda = 0,
nthreads = 1,
chunkSize = 1000,
verbose = TRUE,
...
)
# S4 method for class 'ANY'
lmmFitResponses(
Y,
design,
Z,
Weights = NULL,
dcmpMethod = c("general", "categorical"),
REML = TRUE,
delta.range = c(-10, 10),
tol = 1e-06,
detail = 1,
lambda = 0,
nthreads = 1,
chunkSize = 1000,
verbose = TRUE,
...
)
# S4 method for class 'DelayedArray'
lmmFitResponses(
Y,
design,
Z,
Weights = NULL,
dcmpMethod = c("general", "categorical"),
REML = TRUE,
delta.range = c(-10, 10),
tol = 1e-06,
detail = 1,
lambda = 0,
nthreads = 1,
chunkSize = 1000,
verbose = TRUE,
...
)Arguments
- Y
matrix of responses as __rows__
- design
design matrix
- Z
random effect design matrix
- Weights
matrix sample-level weights the same dimension as Y
- dcmpMethod
use a
"general"method (default) for SVD ofZ. IfZis a categorical design matrix, used faster method"categorical"- REML
logical scalar - Should the estimates be chosen to optimize the REML criterion vs ML?
- delta.range
min and max values (in log space), of the search space for delta to fit the random effect
- tol
convergence criterion for the 1D search of the delta space
- detail
level of model detail returned, with LEAST = 0, LOW = 1, MEDIUM = 2, HIGH = 3, MOST = 4, MAX = 5. LEAST (beta), LOW (beta, se, sigSq, rdf), MEDIUM (vcov), HIGH (residuals), MOST (hatvalues), MAX (deviance residuals)
- lambda
ridge shrinkage parameter
- nthreads
number of threads. Each model is fit in serial, analysis is parallelized across features
- chunkSize
number of features to read per chunk
- verbose
show progress
- ...
other args
Details
Since the weights vary for each response, each model is computed separately without recycling precomputed values
Examples
library(DelayedArray)
library(fastglmm)
n <- 100
m <- 5
nc <- 2
set.seed(1)
Y <- matrix(rnorm(n * m), m, n)
Y <- DelayedArray(Y)
X <- matrix(rnorm(n * nc), n, nc)
rownames(Y) <- seq(m)
W <- matrix(runif(n * m), m, n)
Subject <- sample(LETTERS[1:3], n, replace=TRUE)
Z <- preprocess_indicator(Subject)
# fit regressions with model j using Y[j,] as a response
fit <- lmmFitResponses(Y, X, Z, W)
fit
#> lmmFitResponses
#>
#> coefs(2): V1, V2
#> responses(5): 1, 2, 3, 4, 5
#> family: gaussian/identity
#> Estimated: se, dispersion, rdf, sigSq_e, sigSq_g
#>