Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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/(1-p0), where p0:=\exp(-μ_U) is the probability that the response is 0.

Usage

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

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).

Details

The mu.eta member function is that of the base poisson family, hence ignores truncation.

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.

Value

A family object.

References

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

Examples

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))

spaMM

Mixed-Effect Models, with or without Spatial Random Effects

v3.10.0
CeCILL-2
Authors
François Rousset [aut, cre, cph] (<https://orcid.org/0000-0003-4670-0371>), Jean-Baptiste Ferdy [aut, cph], Alexandre Courtiol [aut] (<https://orcid.org/0000-0003-0637-2959>), GSL authors [ctb] (src/gsl_bessel.*)
Initial release
2022-02-06

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.