Description Usage Arguments Details Value Warning Note Author(s) See Also Examples

View source: R/family.mixture.R

Estimates the three parameters of a mixture of two exponential distributions by maximum likelihood estimation.

1 2 |

`lphi, llambda` |
Link functions for the parameters |

`iphi, il1, il2` |
Initial value for |

`qmu` |
Vector with two values giving the probabilities relating to the sample
quantiles for obtaining initial values for |

`nsimEIM, zero` |
See |

The probability density function can be loosely written as

*
f(y) = phi * Exponential(lambda1) +
(1-phi) * Exponential(lambda2)*

where *phi* is the probability an observation belongs
to the first group, and *y>0*.
The parameter *phi* satisfies *0 < phi < 1*.
The mean of *Y* is
*phi/lambda1 + (1-phi)/lambda2*
and this is returned as the fitted values.
By default, the three linear/additive predictors are
*(logit(phi),
log(lambda1), log(lambda2))^T*.

An object of class `"vglmff"`

(see `vglmff-class`

).
The object is used by modelling functions such as `vglm`

and `vgam`

.

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.

Fitting this model successfully to data can be
difficult due to local solutions, uniqueness problems
and ill-conditioned data. It pays to fit the model
several times with different initial values and check
that the best fit looks reasonable. Plotting the
results is recommended. This function works better as
*lambda1* and *lambda2*
become more different. The default control argument
`trace = TRUE`

is to encourage monitoring convergence.

T. W. Yee

`rexp`

,
`exponential`

,
`mix2poisson`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
## Not run: 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)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.