genapoisson {VGAM}R Documentation

Generally-Altered Poisson Distribution Family Function

Description

Fits a generally-altered Poisson distribution based on a conditional model involving a multinomial distribution and a generally-truncated Poisson distribution.

Usage

genapoisson(alter = 0, zero = NULL, llambda = "loglink", 
            type.fitted = c("mean", "lambda", "pobs.a", "onempobs.a"),
            imethod = 1, ilambda = NULL, ishrinkage = 0.95, probs.y = 0.35)

Arguments

alter

Vector of altered values, i.e., nonnegative integers. Must have unique values only. May be a NULL, which stands for empty set (same as poissonff). The default is the 0-altered Poisson.

llambda

See Links for more choices and information.

type.fitted

See CommonVGAMffArguments for information. The choice "pobs.a" is the probability of an altered value, and "onempobs.a" is its complement.

imethod, ilambda

See CommonVGAMffArguments for information.

probs.y, ishrinkage

See CommonVGAMffArguments for information.

zero

See CommonVGAMffArguments for information. Setting zero = "pobs" will model the multinomial probabilities as simple as possible (intercept-only), hence should be more numerically stable than the default, and this is recommended for many analyses especially when there are many explanatory variables..

Details

The generally-altered Poisson distribution is the ordinary Poisson distribution with the probability of certain values (alter argument) being modelled using a multinomial logit model. The other values are modelled using a generally-truncated Poisson distribution. The 0-altered Poisson distribution is a special case and is the default (it is called a hurdle model by some people).

This function implements Fisher scoring and currently does not handle multiple responses. Compared to genipoisson this family function handles deflation and inflation, therefore handles a wider range of data.

Value

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

The fitted.values slot of the fitted object, which should be extracted by the generic function fitted, returns the mean mu (default). The choice type.fitted = "pobs.a" returns the sum of all the altered probabilities.

Note

This family function does not yet have the robustness of multinomial when computing the working weight matrices. Several improvements are needed, e.g., better labelling and initial values and handling multiple responses. And summaryvglm does not work yet on these fitted models.

This family function effectively combines gentpoisson and multinomial into one family function.

Author(s)

T. W. Yee and Chenchen Ma

See Also

Genapois, gentpoisson, genipoisson, zapoisson, multinomial, rpospois, CommonVGAMffArguments, simulate.vlm.

Examples

avec <- c(0, 3)  # Alter these values
gdata <- data.frame(x2 = runif(nn <- 1000))
gdata <- transform(gdata, x3 = runif(nn))
gdata <- transform(gdata, lambda1   = exp(1 + 2 * x2 + 0.5 * x3),
                          lambda2   = exp(1 - 1 * x2 + 0.5 * x3),
                          lambda3   = exp(1))
gdata <- transform(gdata,
  y1 = rgenapois(nn, lambda = lambda1, pobs.a = c(0.2, 0.3), byrow = TRUE,
                 alter = avec),
  y2 = rgenapois(nn, lambda = lambda2, pobs.a = c(0.2, 0.3), byrow = TRUE,
                 alter = avec),
  y3 = rgenapois(nn, lambda = lambda3, pobs.a = c(0.2, 0.3), byrow = TRUE,
                 alter = avec))
genapoisson(alter = avec)
with(gdata, table(y1))
with(gdata, table(y2))
with(gdata, table(y3))

fit1 <- vglm(y1 ~ x2 + x3, genapoisson(alter = avec),
             crit = "coef", trace = TRUE, data = gdata)
head(fitted(fit1))
head(predict(fit1))
coef(fit1, matrix = TRUE)
# summary(fit1)  # Currently does not work!!

# Another example ------------------------------
fit3 <- vglm(y3 ~ 1, genapoisson(alter = avec), gdata, trace = TRUE)
coef(fit3, matrix = TRUE)

[Package VGAM version 1.1-1 Index]