Estimates the three parameters of a mixture of two exponential distributions by maximum likelihood estimation.
mix2exp(lphi = "logitlink", llambda = "loglink", iphi = 0.5,
il1 = NULL, il2 = NULL, qmu = c(0.8, 0.2), nsimEIM = 100,
zero = "phi")
An object of class "vglmff"
(see vglmff-class
).
The object is used by modelling functions
such as vglm
and vgam
.
Link functions for the parameters Links
for more choices.
Initial value for qmu
.
Vector with two values giving the probabilities relating to the
sample quantiles for obtaining initial values for
probs
argument into
quantile
.
See CommonVGAMffArguments
.
This VGAM family function requires care for a successful
application.
In particular, good initial values are required because
of the presence of local solutions. Therefore running
this function with several different combinations of
arguments such as iphi
, il1
, il2
,
qmu
is highly recommended. Graphical methods such
as hist
can be used as an aid.
This VGAM family function is experimental and should be used with care.
T. W. Yee
The probability density function can be loosely written as
rexp
,
exponential
,
mix2poisson
.
if (FALSE) lambda1 <- exp(1); lambda2 <- exp(3)
(phi <- logitlink(-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, data = mdata, trace = TRUE)
coef(fit, matrix = TRUE)
# Compare the results with the truth
round(rbind('Estimated' = Coef(fit),
'Truth' = c(phi, lambda1, lambda2)), digits = 2)
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