Last chance! 50% off unlimited learning
Sale ends in
mix2normal1(lphi = "logit", lmu = "identity", lsd = "loge",
ephi = list(), emu1 = list(), emu2 = list(),
esd1 = list(), esd2 = list(),
iphi = 0.5, imu1 = NULL, imu2 = NULL, isd1 = NULL, isd2 = NULL,
qmu = c(0.2, 0.8), equalsd = TRUE, nsimEIM = 100, zero = 1)
Links
for more choices.earg
in Links
for general information.
If equalsd = TRUE
then esd1
must equal esd2
.qmu
.qmu
.
Currently these are not great, therefore using these arguments
where practical is a good ideprobs
argument into
TRUE
then the appropriate
constraint matrices will be used."vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
,
and vgam
.iphi
,
qmu
,
imu1
,
imu2
,
isd1
,
isd2
,
etc. This
equalsd = TRUE
then $\sigma_1 = \sigma_2$ is enforced.Everitt, B. S. and Hand, D. J. (1981) Finite Mixture Distributions. London: Chapman & Hall.
normal1
,
Normal
,
mix2poisson
.mu1 = 99; mu2 = 150; nn = 1000
sd1 = sd2 = exp(3)
(phi = logit(-1, inverse = TRUE))
mdata = data.frame(y = ifelse(runif(nn) < phi, rnorm(nn, mu1, sd1),
rnorm(nn, mu2, sd2)))
fit = vglm(y ~ 1, mix2normal1(equalsd = TRUE), mdata)
# Compare the results
cfit = coef(fit)
round(rbind('Estimated' = c(logit(cfit[1], inverse = TRUE),
cfit[2], exp(cfit[3]), cfit[4]), 'Truth' = c(phi, mu1, sd1, mu2)), dig = 2)
# Plot the results
xx = with(mdata, seq(min(y), max(y), len = 200))
plot(xx, (1-phi)*dnorm(xx, mu2, sd2), type = "l", xlab = "y",
main = "Orange=estimate, blue=truth", col = "blue", ylab = "Density")
phi.est = logit(coef(fit)[1], inverse = TRUE)
sd.est = exp(coef(fit)[3])
lines(xx, phi*dnorm(xx, mu1, sd1), col = "blue")
lines(xx, phi.est * dnorm(xx, Coef(fit)[2], sd.est), col = "orange")
lines(xx, (1-phi.est) * dnorm(xx, Coef(fit)[4], sd.est), col = "orange")
abline(v = Coef(fit)[c(2,4)], lty = 2, col = "orange")
abline(v = c(mu1, mu2), lty = 2, col = "blue")
Run the code above in your browser using DataLab