Skip to contents

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

Usage

glmFitResponses(
  Y,
  design,
  family,
  weights = NULL,
  offset = NULL,
  detail = 1,
  doCoxReid = ncol(Y) < 100,
  nthreads = 1,
  nReaders = 1,
  chunkSize = NULL,
  epsilon = 1e-08,
  maxit = 25,
  epsilon_nb = 1e-04,
  maxit_nb = 5,
  lambda = 0,
  ...
)

# S4 method for class 'matrix'
glmFitResponses(
  Y,
  design,
  family,
  weights = NULL,
  offset = NULL,
  detail = 1,
  doCoxReid = ncol(Y) < 100,
  nthreads = 1,
  nReaders = 1,
  chunkSize = NULL,
  epsilon = 1e-08,
  maxit = 25,
  epsilon_nb = 1e-04,
  maxit_nb = 5,
  lambda = 0,
  ...
)

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", see details below

weights

vector of sample-level weights

offset

vector of sample-level offset values

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)

doCoxReid

use Cox-Reid adjustment when estimating overdispersion for negative binomial models. Default TRUE for less than 100 samples

nthreads

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

nReaders

ignored here

chunkSize

not used

epsilon

tolerance for GLM IRLS

maxit

max iterations for GLM IRLS

epsilon_nb

tolerance for negative binomial

maxit_nb

max iterations for negative binomial

lambda

ridge shrinkage parameter

...

other args

Value

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

Details

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

Generalized linear models can be fit with family like in glm() using gaussian(), poisson(), binomial(), binomial("probit"), quasibinomial(), quasipoisson(), negative.binomial(theta), "nb", "nb:theta". Or array of entries of form "nb:theta", where theta is the parameter for the negative binomial distribution

Examples

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)

# fit regressions with model j using Y[,j] as a response
fit <- glmFitResponses(Y, X, "poisson")

fit
#> 		 glmFitResponses 
#> 
#> coefs(3): 1, 2, 3
#> responses(5): 1, 2, 3, 4, 5
#> family: poisson/log 
#> Estimated: se, dispersion, rdf, varFitted, mu_mean, y_mean 
#>