mix2poisson(lphi = "logit", llambda = "loge",
ephi=list(), el1=list(), el2=list(),
iphi = 0.5, il1 = NULL, il2 = NULL,
qmu = c(0.2, 0.8), nsimEIM=100, zero = 1)
Links
for more choices.Links
for more choices.earg
in Links
for general information.qmu
.probs
argument into
"vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
and vgam
.iphi
, il1
,
il2
, qmu
is highly recommended. Graphical methods such
as hist
can be used as an aid. With grouped data (i.e., using the weights
argument)
one has to use a large value of nsimEIM
;
see the example below.
rpois
,
poissonff
,
mix2normal1
.# Example 1: simulated data
n = 1000
mu1 = exp(2.5) # also known as lambda1
mu2 = exp(3)
(phi = logit(-0.5, inverse=TRUE))
y = ifelse(runif(n) < phi, rpois(n, mu1), rpois(n, mu2))
fit = vglm(y ~ 1, mix2poisson)
coef(fit, matrix=TRUE)
# Compare the results with the truth
round(rbind('Estimated'=Coef(fit), 'Truth'=c(phi, mu1, mu2)), dig=2)
# Plot the results
ty = table(y)
plot(names(ty), ty, type="h", main="Red=estimate, blue=truth")
abline(v=Coef(fit)[-1], lty=2, col="red", lwd=2)
abline(v=c(mu1, mu2), lty=2, col="blue", lwd=2)
# Example 2: London Times data (Lange, 1997, p.31)
deaths = 0:9
freq = c(162, 267, 271, 185, 111, 61, 27, 8, 3, 1)
y = rep(deaths, freq)
# Usually this does not work well unless nsimEIM is large
fit = vglm(deaths ~ 1, weight = freq,
mix2poisson(iphi=0.3, il1=1, il2=2.5, nsimEIM=5000))
# This works better in general
fit = vglm(y ~ 1, mix2poisson(iphi=0.3, il1=1, il2=2.5))
coef(fit, matrix=TRUE)
Coef(fit)
Run the code above in your browser using DataLab