Learn R Programming

VGAM (version 0.9-2)

zigeometric: Zero-Inflated Geometric Distribution Family Function

Description

Fits a zero-inflated geometric distribution by maximum likelihood estimation.

Usage

zigeometric(lpstr0  = "logit", lprob = "logit",
            type.fitted = c("mean", "pobs0", "pstr0", "onempstr0"),
            ipstr0  = NULL, iprob = NULL,
            imethod = 1, bias.red = 0.5, zero = NULL)
zigeometricff(lprob = "logit", lonempstr0 = "logit",
              type.fitted = c("mean", "pobs0", "pstr0", "onempstr0"),
              iprob = NULL, ionempstr0 = NULL,
              imethod = 1, bias.red = 0.5, zero = -2)

Arguments

lpstr0, lprob
Link functions for the parameters $\phi$ and $p$ (prob). The usual geometric probability parameter is the latter. The probability of a structural zero is the former. See Links for mor
lonempstr0, ionempstr0
Corresponding arguments for the other parameterization. See details below.
bias.red
A constant used in the initialization process of pstr0. It should lie between 0 and 1, with 1 having no effect.
type.fitted
See CommonVGAMffArguments and fittedvlm for information.
ipstr0, iprob
See CommonVGAMffArguments for information.
zero, imethod
See CommonVGAMffArguments for information.

Value

  • An object of class "vglmff" (see vglmff-class). The object is used by modelling functions such as vglm and vgam.

Details

Function zigeometric() is based on $$P(Y=0) = \phi + (1-\phi) p,$$ for $y=0$, and $$P(Y=y) = (1-\phi) p (1 - p)^{y}.$$ for $y=1,2,\ldots$. The parameter $\phi$ satisfies $0 < \phi < 1$. The mean of $Y$ is $E(Y)=(1-\phi) p / (1-p)$ and these are returned as the fitted values by default. By default, the two linear/additive predictors are $(logit(\phi), logit(p))^T$. Multiple responses are handled. Estimated probabilities of a structural zero and an observed zero can be returned, as in zipoisson; see fittedvlm for information.

The VGAM family function zigeometricff() has a few changes compared to zigeometric(). These are: (i) the order of the linear/additive predictors is switched so the geometric probability comes first; (ii) argument onempstr0 is now 1 minus the probability of a structural zero, i.e., the probability of the parent (geometric) component, i.e., onempstr0 is 1-pstr0; (iii) argument zero has a new default so that the onempstr0 is intercept-only by default. Now zigeometricff() is generally recommended over zigeometric(). Both functions implement Fisher scoring and can handle multiple responses.

See Also

rzigeom, geometric, zageometric, rgeom.

Examples

Run this code
gdata <- data.frame(x2 = runif(nn <- 1000) - 0.5)
gdata <- transform(gdata, x3 = runif(nn) - 0.5,
                          x4 = runif(nn) - 0.5)
gdata <- transform(gdata, eta1 =  1.0 - 1.0 * x2 + 2.0 * x3,
                          eta2 = -1.0,
                          eta3 =  0.5)
gdata <- transform(gdata, prob1 = logit(eta1, inverse = TRUE),
                          prob2 = logit(eta2, inverse = TRUE),
                          prob3 = logit(eta3, inverse = TRUE))
gdata <- transform(gdata, y1 = rzigeom(nn, prob1, pstr0 = prob3),
                          y2 = rzigeom(nn, prob2, pstr0 = prob3),
                          y3 = rzigeom(nn, prob2, pstr0 = prob3))
with(gdata, table(y1))
with(gdata, table(y2))
with(gdata, table(y3))
head(gdata)

fit1 <- vglm(y1 ~ x2 + x3 + x4, zigeometric(zero = 1), data = gdata, trace = TRUE)
coef(fit1, matrix = TRUE)
head(fitted(fit1, type = "pstr0"))

fit2 <- vglm(cbind(y2, y3) ~ 1, zigeometric(zero = 1), data = gdata, trace = TRUE)
coef(fit2, matrix = TRUE)
summary(fit2)

Run the code above in your browser using DataLab