gampoi_overdispersion_mle {glmGamPoi} | R Documentation |
Estimate the Overdispersion for a Vector of Counts
gampoi_overdispersion_mle( y, mean = base::mean(y), model_matrix = matrix(1, nrow = length(y), ncol = 1), do_cox_reid_adjustment = TRUE, subsample = FALSE, verbose = FALSE )
y |
a numeric or integer vector with the counts for which the overdispersion is estimated |
mean |
a numeric vector of either length 1 or |
model_matrix |
a numeric matrix that specifies the experimental
design. It can be produced using |
do_cox_reid_adjustment |
the classical maximum likelihood estimator of the |
subsample |
the estimation of the overdispersion is the slowest step when fitting
a Gamma-Poisson GLM. For datasets with many samples, the estimation can be considerably sped up
without loosing much precision by fitting the overdispersion only on a random subset of the samples.
Default: |
verbose |
a boolean that indicates if information about the individual steps are printed
while fitting the GLM. Default: |
The function employs a rough heuristic to decide if the iterative
or the Bandara approach is used to calculate the overdispersion. If
max(y) < length(y)
Bandara's approach is used, otherwise the
conventional one is used.
The function returs a list with the following elements:
estimate
the numerical estimate of the overdispersion.
iterations
the number of iterations it took to calculate the result.
method
the method that was used to calculate the
overdispersion: either "conventional"
or "bandara"
.
message
additional information about the fitting process.
set.seed(1) # true overdispersion = 2.4 y <- rnbinom(n = 10, mu = 3, size = 1/2.4) # estimate = 1.7 gampoi_overdispersion_mle(y) # true overdispersion = 0 y <- rpois(n = 10, lambda = 3) # estimate = 0 gampoi_overdispersion_mle(y) # with different mu, overdispersion estimate changes gampoi_overdispersion_mle(y, mean = 15) # Cox-Reid adjustment changes the result gampoi_overdispersion_mle(y, mean = 15, do_cox_reid_adjustment = FALSE) # Many very small counts, true overdispersion = 50 y <- rnbinom(n = 1000, mu = 0.01, size = 1/50) summary(y) # estimate = 31 gampoi_overdispersion_mle(y)