cpglmm {cplm}R Documentation

Compound Poisson Generalized Linear Mixed Models


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


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



a two-sided linear formula object describing the model structure, 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 matrix and a grouping factor. The right side can also include basis generators. See lme4 and basisGenerators below.


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 argument in the tweedie function. The default is link="log".


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 cpglm; see there for details.


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.


a list of parameters for controlling the fitting process. See cpglm. The parameter PQL.init is not used.


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 tp for details.


a character string that determines which optimization routine is to be used. Possible choices are "nlminb" (the default, see nlminb), "bobyqa" (bobyqa) and "L-BFGS-B" (optim).


if FALSE, the constructed "cpglmm" object is returned before the model is fitted.


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 evaluation of the log-likelihood at the expense of speed.


Estimation of compound Poisson mixed models in existing software has been limited to the Penalized Quasi-Likelihood [PQL] approach (e.g., see glmmPQL). While straightforward and fast, this method is not equipped to estimate the unknown variance function, i.e., 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 estimation.

This implementation is based on the older lme4 package (the 0.9* version), with changes made on updating of the mean, the variance function and the marginal loglikelihood. For the Laplace method, the contribution of the dispersion parameter to the approximated loglikelihood is explicitly accounted for, which should be more accurate and more consistent with the quadrature estimate. Indeed, 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 documentation associated with lme4.

In addition, similar to the package amer (already retired from CRAN), we provide convenient interfaces for fitting additive models using penalized splines. See the 'example' section for one such application.


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.


Yanwei (Wayne)) Zhang actuary_zhang@hotmail.com


Zhang Y (2013). Likelihood-based and Bayesian Methods for Tweedie Compound Poisson Linear Mixed Models, Statistics and Computing, 23, 743-757. https://github.com/actuaryzhang/cplm/files/144051/TweediePaper.pdf

Bates D, Maechler M, Bolker B and Walker S (2015). lme4: Linear mixed-effects models using Eigen and S4..

See Also

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


## Not run: 
# use Stock and Spacing as main effects and Plant as random effect
(f1 <- cpglmm(RLD ~ Stock + Spacing +  (1|Plant), data = FineRoot))
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

# 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 = ClaimTriangle))

## End(Not run)

[Package cplm version 0.7-12 Index]