
Last chance! 50% off unlimited learning
Sale ends in
mix2exp(lphi = "logit", llambda = "loge", ephi = list(),
el1 = list(), el2 = list(), iphi = 0.5, il1 = NULL, il2 = NULL,
qmu = c(0.8, 0.2), nsimEIM = 100, zero = 1)
Links
for more choearg
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.rexp
,
exponential
,
mix2poisson
.lambda1 = exp(1); lambda2 = exp(3)
(phi = logit(-1, inverse = TRUE))
mdata = data.frame(y1 = rexp(nn <- 1000, lambda1))
mdata = transform(mdata, y2 = rexp(nn, lambda2))
mdata = transform(mdata, Y = ifelse(runif(nn) < phi, y1, y2))
fit = vglm(Y ~ 1, mix2exp, mdata, trace = TRUE)
coef(fit, matrix = TRUE)
# Compare the results with the truth
round(rbind('Estimated' = Coef(fit),
'Truth' = c(phi, lambda1, lambda2)), dig = 2)
# Plot the results
with(mdata, hist(Y, prob = TRUE, main = "Orange = estimate, blue = truth"))
abline(v = 1 / Coef(fit)[c(2, 3)], lty = 2, col = "orange", lwd = 2)
abline(v = 1 / c(lambda1, lambda2), lty = 2, col = "blue", lwd = 2)
Run the code above in your browser using DataLab