50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

spaMM (version 4.5.0)

Poisson: Family function for GLMs and mixed models with Poisson and zero-truncated Poisson response.

Description

Poisson (with a capital P) is a family that specifies the information required to fit a Poisson generalized linear model. Differs from the base version stats::poisson only in that it handles the zero-truncated variant, which can be specified either as Tpoisson(<link>) or as Poisson(<link>, trunc = 0L). The truncated poisson with mean μT is defined from the un-truncated poisson with mean μU, by restricting its response strictly positive value. μT=μU/(1p0), where p0:=exp(μU) is the probability that the response is 0.

Usage

Poisson(link = "log", trunc = -1L, LLgeneric=TRUE)
Tpoisson(link="log")
# $linkfun(mu, mu_truncated = FALSE)
# $linkinv(eta, mu_truncated = FALSE)

Value

A family object suitable for use with glm, as stats:: family objects.

Arguments

link

log, sqrt or identity link, specified by any of the available ways for GLM links (name, character string, one-element character vector, or object of class link-glm as returned by make.link).

trunc

Either 0L for zero-truncated distribution, or -1L for default untruncated distribution.

eta,mu

Numeric (scalar or array). The linear predictor; and the expectation of response, truncated or not depending on mu_truncated argument.

mu_truncated

Boolean. For linkinv, whether to return the expectation of truncated (μT) or un-truncated (μU) response. For linkfun, whether the mu argument is μT, or is μU but has μT as attribute (μU without the attribute is not sufficient).

LLgeneric

For development purposes, not documented.

Details

Molas & Lesaffre (2010) developed expressions for deviance residuals for the truncated Poisson distribution, which were the ones implemented in spaMM until version 3.12.0. Later versions implement the (non-equivalent) definition as “2*(saturated_logLik - logLik)”.

predict, when applied on an object with a truncated-response family, by default returns μT. The simplest way to predict μU is to get the linear predictor value by predict(.,type="link"), and deduce μU using linkinv(.) (with default argument mu_truncated=FALSE), since getting μU from μT is comparatively less straightforward. The mu.eta member function is that of the base poisson family, hence its mu argument represents μU.

simulate, when applied on an object with a truncated-response family, simulates the truncated family. There is currently no clean way to override this (trying to passtype="link" to predict will not have the intended effect).

References

McCullagh, P. and Nelder, J.A. (1989) Generalized Linear Models, 2nd edition. London: Chapman & Hall.

Molas M. and Lesaffre E. (2010). Hurdle models for multilevel zero-inflated data via h-likelihood. Statistics in Medicine 29: 3294-3310.

Examples

Run this code
data("scotlip")
logLik(glm(I(1+cases)~1,family=Tpoisson(),data=scotlip))
logLik(fitme(I(1+cases)~1+(1|id),family=Tpoisson(),fixed=list(lambda=1e-8),data=scotlip))

Run the code above in your browser using DataLab