Learn R Programming

VGAM (version 1.1-3)

zibinomial: Zero-Inflated Binomial Distribution Family Function

Description

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

Usage

zibinomial(lpstr0 = "logitlink", lprob = "logitlink",
           type.fitted = c("mean", "prob", "pobs0", "pstr0", "onempstr0"),
           ipstr0 = NULL, zero = NULL, multiple.responses = FALSE,
           imethod = 1)
zibinomialff(lprob = "logitlink", lonempstr0 = "logitlink",
             type.fitted = c("mean", "prob", "pobs0", "pstr0", "onempstr0"),
             ionempstr0 = NULL, zero = "onempstr0",
             multiple.responses = FALSE, imethod = 1)

Arguments

lpstr0, lprob

Link functions for the parameter \(\phi\) and the usual binomial probability \(\mu\) parameter. See Links for more choices. For the zero-deflated model see below.

type.fitted
ipstr0

Optional initial values for \(\phi\), whose values must lie between 0 and 1. The default is to compute an initial value internally. If a vector then recyling is used.

lonempstr0, ionempstr0

Corresponding arguments for the other parameterization. See details below.

multiple.responses

Logical. Currently it must be FALSE to mean the function does not handle multiple responses. This is to remain compatible with the same argument in binomialff.

zero, imethod

See CommonVGAMffArguments for information. Argument zero changed its default value for version 0.9-2.

Value

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

Warning

Numerical problems can occur. Half-stepping is not uncommon. If failure to converge occurs, make use of the argument ipstr0 or ionempstr0, or imethod.

Details

These functions are based on $$P(Y=0) = \phi + (1-\phi) (1-\mu)^N,$$ for \(y=0\), and $$P(Y=y) = (1-\phi) {N \choose Ny} \mu^{Ny} (1-\mu)^{N(1-y)}.$$ for \(y=1/N,2/N,\ldots,1\). That is, the response is a sample proportion out of \(N\) trials, and the argument size in rzibinom is \(N\) here. The parameter \(\phi\) is the probability of a structural zero, and it satisfies \(0 < \phi < 1\). The mean of \(Y\) is \(E(Y)=(1-\phi) \mu\) and these are returned as the fitted values by default. By default, the two linear/additive predictors for zibinomial() are \((logit(\phi), logit(\mu))^T\).

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

References

Welsh, A. H., Lindenmayer, D. B. and Donnelly, C. F. (2013). Fitting and interpreting occupancy models. PLOS One, 8, 1--21.

See Also

rzibinom, binomialff, posbinomial, gtbinomial, Binomial.

Examples

Run this code
# NOT RUN {
size <- 10  # Number of trials; N in the notation above
nn <- 200
zdata <- data.frame(pstr0 = logitlink( 0, inverse = TRUE),  # 0.50
                    mubin = logitlink(-1, inverse = TRUE),  # Mean of usual binomial
                    sv    = rep(size, length = nn))
zdata <- transform(zdata,
                   y = rzibinom(nn, size = sv, prob = mubin, pstr0 = pstr0))
with(zdata, table(y))
fit <- vglm(cbind(y, sv - y) ~ 1, zibinomialff, data = zdata, trace = TRUE)
fit <- vglm(cbind(y, sv - y) ~ 1, zibinomialff, data = zdata, trace = TRUE,
            stepsize = 0.5)

coef(fit, matrix = TRUE)
Coef(fit)  # Useful for intercept-only models
head(fitted(fit, type = "pobs0"))  # Estimate of P(Y = 0)
head(fitted(fit))
with(zdata, mean(y))  # Compare this with fitted(fit)
summary(fit)
# }

Run the code above in your browser using DataLab