View source: R/family.zeroinf.R
zigeometric | R Documentation |
Fits a zero-inflated geometric distribution by maximum likelihood estimation.
zigeometric(lpstr0 = "logitlink", lprob = "logitlink",
type.fitted = c("mean", "prob", "pobs0", "pstr0", "onempstr0"),
ipstr0 = NULL, iprob = NULL,
imethod = 1, bias.red = 0.5, zero = NULL)
zigeometricff(lprob = "logitlink", lonempstr0 = "logitlink",
type.fitted = c("mean", "prob", "pobs0", "pstr0", "onempstr0"),
iprob = NULL, ionempstr0 = NULL,
imethod = 1, bias.red = 0.5, zero = "onempstr0")
lpstr0 , lprob |
Link functions for the parameters
|
lonempstr0 , ionempstr0 |
Corresponding arguments for the other parameterization. See details below. |
bias.red |
A constant used in the initialization process of |
type.fitted |
See |
ipstr0 , iprob |
See |
zero , imethod |
See |
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.
An object of class "vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
and vgam
.
The zero-deflated geometric distribution might
be fitted by setting lpstr0 = identitylink
, albeit,
not entirely reliably. See zipoisson
for information that can be applied here. Else
try the zero-altered geometric distribution (see
zageometric
).
T. W. Yee
rzigeom
,
geometric
,
zageometric
,
spikeplot
,
rgeom
,
simulate.vlm
.
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 = logitlink(eta1, inverse = TRUE),
prob2 = logitlink(eta2, inverse = TRUE),
prob3 = logitlink(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.