oiposbinomial {VGAMdata}R Documentation

One-Inflated Positive Binomial Distribution Family Function

Description

Fits a one-inflated positive binomial distribution by maximum likelihood estimation.

Usage

oiposbinomial(lpstr1 = "logitlink", lprob = "logitlink",
    type.fitted = c("mean", "prob", "pobs1", "pstr1", "onempstr1"),
    iprob = NULL, gpstr1 = ppoints(9), gprob  = ppoints(9),
    multiple.responses = FALSE, zero = NULL)

Arguments

lpstr1, lprob

Link functions for the parameter ϕ\phi and the positive binomial probability μ\mu parameter. See Links for more choices. See CommonVGAMffArguments also. For the one-deflated model see below.

type.fitted

See CommonVGAMffArguments and fittedvlm.

iprob, gpstr1, gprob

For initial values; see CommonVGAMffArguments.

multiple.responses

Logical. See binomialff and posbinomial.

zero

See CommonVGAMffArguments for information.

Details

These functions are based on

P(Y=y)=ϕ+(1ϕ)Nμ(1μ)N/(1(1μ)N),P(Y=y) = \phi + (1-\phi) N \mu (1-\mu)^N / (1-(1-\mu)^N),

for y=1/Ny=1/N, and

P(Y=y)=(1ϕ)(NNy)μNy(1μ)N(1y)/(1(1μ)N).P(Y=y) = (1-\phi) {N \choose Ny} \mu^{Ny} (1-\mu)^{N(1-y)} / (1-(1-\mu)^N).

for y=2/N,,1y=2/N,\ldots,1. That is, the response is a sample proportion out of NN trials, and the argument size in roiposbinom is NN here. Ideally N>2N > 2 is needed. The parameter ϕ\phi is the probability of a structural one, and it satisfies 0<ϕ<10 < \phi < 1 (usually). The mean of YY is E(Y)=ϕ+(1ϕ)μ/(1(1μ)N)E(Y)=\phi + (1-\phi) \mu / (1-(1-\mu)^N) and these are returned as the default fitted values. By default, the two linear/additive predictors for oiposbinomial() are (logit(ϕ),logit(μ))T(logit(\phi), logit(\mu))^T.

Value

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

Note

The response variable should have one of the formats described by binomialff, e.g., a factor or two column matrix or a vector of sample proportions with the weights argument specifying the values of NN.

To work well, one ideally needs large values of NN and μ\mu much greater than 0, i.e., the larger NN and μ\mu are, the better. If N=1N = 1 then the model is unidentifiable since the number of parameters is excessive.

Estimated probabilities of a structural one and an observed one are returned, as in zipoisson.

The one-deflated positive binomial distribution might be fitted by setting lpstr1 = "identitylink", albeit, not entirely reliably. See zipoisson for information that can be applied here.

Author(s)

T. W. Yee

See Also

roiposbinom, posbinomial, binomialff, rbinom.

Examples

size <- 10  # Number of trials; N in the notation above
nn <- 200
odata <- data.frame(pstr1  = logitlink( 0, inv = TRUE),  # 0.50
              mubin1 = logitlink(-1, inv = TRUE),  # Binomial mean
              svec   = rep(size, length = nn),
              x2     = runif(nn))
odata <- transform(odata,
                   mubin2 = logitlink(-1 + x2, inv = TRUE))
odata <- transform(odata,
              y1 = roiposbinom(nn, svec, pr = mubin1, pstr1 = pstr1),
              y2 = roiposbinom(nn, svec, pr = mubin2, pstr1 = pstr1))
with(odata, table(y1))
fit1 <- vglm(y1 / svec ~  1, oiposbinomial, data = odata,
             weights = svec, trace = TRUE, crit = "coef")
fit2 <- vglm(y2 / svec ~ x2, oiposbinomial, data = odata,
             weights = svec, trace = TRUE)

coef(fit1, matrix = TRUE)
Coef(fit1)  # Useful for intercept-only models
head(fitted(fit1, type = "pobs1"))  # Estimate of P(Y = 1)
head(fitted(fit1))
with(odata, mean(y1))  # Compare this with fitted(fit1)
summary(fit1)

[Package VGAMdata version 1.1-9 Index]