genapoisson {VGAM} | R Documentation |
Fits a generally-altered Poisson distribution based on a conditional model involving a multinomial distribution and a generally-truncated Poisson distribution.
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)
alter |
Vector of altered values, i.e., nonnegative integers.
Must have unique values only.
May be a |
llambda |
See |
type.fitted |
See |
imethod, ilambda |
See |
probs.y, ishrinkage |
See |
zero |
See |
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.
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.
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.
T. W. Yee and Chenchen Ma
Genapois
,
gentpoisson
,
genipoisson
,
zapoisson
,
multinomial
,
rpospois
,
CommonVGAMffArguments
,
simulate.vlm
.
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)