Skip to contents

Fit regression model Y[j,] ~ design for each feature j

Usage

# S4 method for class 'sparseMatrix'
glmmFitResponses(
  Y,
  design,
  family,
  Z,
  weights = NULL,
  offset = NULL,
  dcmpMethod = c("general", "categorical"),
  delta.range = c(-10, 10),
  tol = 1e-05,
  tol.eta = 1e-07,
  detail = 1,
  maxit = 100,
  lambda = 0,
  nthreads = 1,
  nReaders = 1,
  chunkSize = 1000,
  verbose = TRUE,
  ...
)

# S4 method for class 'ANY'
glmmFitResponses(
  Y,
  design,
  family,
  Z,
  weights = NULL,
  offset = NULL,
  dcmpMethod = c("general", "categorical"),
  delta.range = c(-10, 10),
  tol = 0.001,
  tol.eta = 0.001,
  detail = 1,
  maxit = 100,
  lambda = 0,
  nthreads = 1,
  nReaders = 1,
  chunkSize = NULL,
  verbose = TRUE,
  ...
)

# S4 method for class 'DelayedArray'
glmmFitResponses(
  Y,
  design,
  family,
  Z,
  weights = NULL,
  offset = NULL,
  dcmpMethod = c("general", "categorical"),
  delta.range = c(-10, 10),
  tol = 0.001,
  tol.eta = 0.001,
  detail = 1,
  maxit = 100,
  lambda = 0,
  nthreads = 1,
  nReaders = 1,
  chunkSize = NULL,
  verbose = TRUE,
  ...
)

Arguments

Y

matrix of responses as __rows__

design

design matrix

family

a description of the error distribution and link function to be used in the modelm just like for glm(). Also supports negative binomial as string "nb:theta".

Z

random effect design matrix

weights

sample-level weights

offset

sample-level offset values

dcmpMethod

use a "general" method (default) for SVD of Z. If Z is a categorical design matrix, used faster method "categorical"

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

tol.eta

convergence criterion eta in the PQL iteration

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)

maxit

max PQL iterations

lambda

ridge shrinkage parameter

nthreads

number of threads. Each model is fit in serial, analysis is parallelized across features

nReaders

number of threads used for reading data from disk

chunkSize

number of features to read per chunk

verbose

show progress

...

other args

Value

List of parameter estimates with entries coef, se, sigSq, rdf and other depending on detail

Details

Since the weights vary for each response, each model is computed separately without recycling precomputed values

Examples

library(fastglmm)
library(lme4)

set.seed(1)
sleepstudy$V <- rnorm(nrow(sleepstudy))

# lmer
fit <- lmer( Reaction ~ Days + V + (1 | Subject), sleepstudy)
fit
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: Reaction ~ Days + V + (1 | Subject)
#>    Data: sleepstudy
#> REML criterion at convergence: 1782.453
#> Random effects:
#>  Groups   Name        Std.Dev.
#>  Subject  (Intercept) 37.12   
#>  Residual             31.06   
#> Number of obs: 180, groups:  Subject, 18
#> Fixed Effects:
#> (Intercept)         Days            V  
#>     251.457       10.472       -1.295  

# prepare response, design and random effect
Y <- matrix(sleepstudy$Reaction, nrow=1)
rownames(Y) <- "Reaction"
colnames(Y) <- rownames(sleepstudy)

design <- model.matrix(~ Days, sleepstudy)
Z <- preprocess_indicator(sleepstudy$Subject)

fit1 <- glmmFitResponses(Y, design, Z, family=gaussian())

fit1
#> 		 glmmFitResponses 
#> 
#> coefs(2): (Intercept), Days
#> responses(1): Reaction
#> family: gaussian/identity 
#> Estimated: se, dispersion, rdf, varFitted, sigSq_e, sigSq_g 
#> 

coef(fit1)
#>          (Intercept)     Days
#> Reaction    251.4051 10.46729