Learn R Programming

cplm (version 0.4-1)

cpglmm: Compound Poisson Generalized Linear Mixed Models

Description

This function fits compound Poisson generalized linear mixed models using Laplacian approximation.

Usage

cpglmm(formula, link = "log", data, weights, offset, subset, 
    na.action, inits = NULL,  contrasts = NULL, 
    control = list())

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' and 'p' that supply the initital 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.

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 Tweedie compound Poisson distribution is composed of a probability mass at the origin accompanied by a skewed continuous distribution on the positive values. It has been widely used to accommodate zero-inflated continuous data, but primarily in the form of generalized linear models (see cpglm for more details). The function cpglmm now enables users to apply mixed-effect models when working with the Tweedie compound Poisson distribution, thus enriching the set of tools to handle zero-inflated data. Specifically, cpglmm fits compound Poisson generalized linear mixed models [CPGLMM] using Laplacian approximation. The 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. In computing the marginal logliklihood, the density of the compound Poisson distribution is approximated using numerical methods provided in the tweedie package, and the parameters in the optimization include the dispersion parameter and the index parameter in additional to the mean parameters and the variance components. For details of the implementation, see the documentations in lme4. The control argument is a list that can supply various controlling elements used in the fitting 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) , 
            link="log", data = fineroot)
summary(f1)
# 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 <- cpglmm(RLD~  Stock + Spacing +  (1|Plant) + (1|Zone), 
            link="log", data = fineroot)
# test the additional random effect
anova(f1,f2)

Run the code above in your browser using DataLab