Returns a DelayedArray-backed matrix representing Y - invLink(tcrossprod(Beta, design)) without materializing the full result.
Usage
ResidualMatrixGLM(
Y,
X,
Beta,
family = "gaussian",
nb.theta = NA_real_,
fit,
type = c("deviance", "pearson", "response", "response.se"),
chunkSize = 1000
)
# S4 method for class 'DelayedMatrix,matrix,matrix,ANY,ANY,ANY'
ResidualMatrixGLM(
Y,
X,
Beta,
family = "gaussian",
nb.theta = NA_real_,
type = c("deviance", "pearson", "response", "response.se"),
chunkSize = 1000
)
# S4 method for class 'ANY,matrix,matrix,ANY,ANY,ANY'
ResidualMatrixGLM(
Y,
X,
Beta,
family = "gaussian",
nb.theta = NA_real_,
type = c("deviance", "pearson", "response", "response.se"),
chunkSize = 1000
)
# S4 method for class 'DelayedMatrix,matrix,missing,missing,missing,modelFitsResponses'
ResidualMatrixGLM(
Y,
X,
Beta,
family = "gaussian",
nb.theta = NA_real_,
fit,
type = c("deviance", "pearson", "response", "response.se"),
chunkSize = 1000
)
# S4 method for class 'ANY,matrix,missing,missing,missing,modelFitsResponses'
ResidualMatrixGLM(
Y,
X,
Beta,
family = "gaussian",
nb.theta = NA_real_,
fit,
type = c("deviance", "pearson", "response", "response.se"),
chunkSize = 1000
)Arguments
- Y
A matrix-like object coercible to
DelayedArray.- X
A matrix-like object coercible to
DelayedArray.- Beta
A numeric matrix or object coercible to matrix.
- family
GLM family string
- nb.theta
array of overdispersion parameters for negative binomial regressions
- fit
multivariate regression fit of class
modelFitsResponsesfromglmFitResponses(), or similar- type
type of residual:
c("deviance", "pearson", "response", "response.se")- chunkSize
number of rows to read into memory at a time
Examples
library(BatchRegression)
library(fastglmm)
#> Loading required package: nlme
n <- 100
m <- 5
nc <- 2
set.seed(1)
Y <- matrix(rpois(n * m, 100), m, n)
X <- matrix(rnorm(n * nc), n, nc)
X <- cbind(1, X) # intercept term
colnames(X) <- seq(ncol(X))
rownames(Y) <- seq(m)
# negative.binomial
fam <- negative.binomial(4)
fit <- glmFitResponses(Y, X, fam)
# residuals
R <- ResidualMatrixGLM(Y, X, fit = fit)