Learn R Programming

cplm (version 0.5-1)

cpglmm: Compound Poisson Generalized Linear Mixed Models

Description

Laplace approximation and adaptive Gauss-Hermite quadrature methods for compound Poisson generalized linear mixed models and additive models.

Usage

cpglmm(formula, link = "log", data, weights, offset, subset, 
    na.action, inits = NULL,  contrasts = NULL, 
    control = list(), basisGenerators = c("tp","tpU","bsp","sp2d"),
    optimizer = "nlminb", doFit = TRUE, nAGQ = 1)

Arguments

formula
a two-sided linear formula object describing the fixed-effects part of the model, with the response on the left of a ~ operator and the terms, separated by + operators, on the right. The vertical bar character "|" separates an expression for a model matri
link
a specification for the model link function. This can be either a literal character string or a numeric number. If it is a character string, it must be one of "log", "identity", "sqrt" or "inverse". If it is numeric, it is the same as the link.power
data
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model.
subset, weights, na.action, offset, contrasts
further model specification arguments as in glm; see there for details.
inits
a named list with three components 'beta', 'phi', 'p', 'Sigma' that supply the initial values used in the optimization. If not supplied, the function will generate initial values automatically, which are based on a GLM with the supplied model structure.
control
a list of parameters for controlling the fitting process. See 'Details' below.
basisGenerators
a character vector of names of functions that generate spline bases. This is used when smoothing effects are to be included in the model. See amer and tp for
optimizer
a character string that determines which optimization routine is to be used. Possible choices are "nlminb" (the default, see nlminb), "bobyqa" (
doFit
if FALSE, no model will be fitted and the constructed "cpglmm" object is returned.
nAGQ
a positive integer - the number of points per axis for evaluating the adaptive Gauss-Hermite approximation to the log-likelihood. This defaults to 1, corresponding to the Laplacian approximation. Values greater than 1 produce greater accuracy in the evalu

Value

  • cpglmm returns an object of class cpglmm. See cpglmm-class for details of the return values as well as various method available for this class.

Details

The estimation of the mixed-effect models in the compound Poisson distribution in existing software has been limited to the PQL approach (Penalized Quasi-Likelihood, see glmmPQL). While straightforward and fast, this method, because of its quasi-likelihood nature, does not offer a neat solution to the problem of estimating the index parameter. In contrast, the function cpglmm implements true likelihood-based inferential procedures, i.e., the Laplace approximation and the Adaptive Gauss-Hermite Quadrature (for single grouping factor), so that all parameters in the model can be estimated using maximum likelihood estimations. These methods are often considered to have better asymptotic properties. This implementation is based on the code for glmer in the lme4 package, with changes made on the updating of the mean, the variance function and the marginal loglikelihood. For the Laplace methods, one big difference to glmer is that the contribution of the dispersion parameter to the approximated loglikelihood is explicitly accounted for, which I think is more accurate and more consistent with the quadrature estimate. As a result, both the dispersion parameter and the index parameter are included as a part of the optimization process. In computing the marginal loglikelihood, the density of the compound Poisson distribution is approximated using numerical methods provided in the tweedie package. For details of the Laplace approximation and the Gauss-Hermite quadrature method for generalized linear mixed models, see the documentations associated with lme4.

In addition, similar to the package amer, we provide convenient interfaces for fitting additive models with penalized splines using the mixed-effect model facility. All the spline constructors available in amer or those defined by the users following the amer requirement can be directly used here. See the 'example' section for one such application.

The control argument is a list that can supply various controlling elements used in the optimization process:

[object Object],[object Object],[object Object],[object Object]

See Also

The users are recommended to see cpglm for a general introduction to the compound Poisson distribution, glmer for syntax and usage of mixed-effect models and cpglmm-class for detailed explanation of the return value.

Examples

Run this code
# use Stock and Spacing as main effects and Plant as random effect
(f1 <- cpglmm(RLD ~ Stock + Spacing +  (1|Plant), data = fineroot))
            
# most of the methods defined in lme4 are directly applicable
coef(f1); fixef(f1); ranef(f1)  #coefficients
VarCorr(f1)  #variance components

# add another random effect
(f2 <- update(f1, . ~ . + (1|Zone)))
# test the additional random effect
anova(f1,f2)

# try a different optimizer 
(f3 <- cpglmm(RLD ~  Stock + Spacing +  (1|Plant), 
            data = fineroot, optimizer = "bobyqa", 
            control = list(trace = 2)))

# adaptive G-H quadrature  
(f4 <- cpglmm(RLD ~  Stock + Spacing +  (1|Plant), 
            data = fineroot, nAGQ = 3))

# a model with smoothing effects
(f5 <- cpglmm(increLoss ~ tp(lag, k = 4) + (1|year) , 
            data = insLoss))

Run the code above in your browser using DataLab