Fits panfmm() for each number of classes in k and tabulates the
log-likelihood, number of parameters, AIC and BIC (with n the number of
observations), the usual criteria for choosing the number of classes
(Deb and Trivedi 2002 prefer BIC). Mixtures with too many classes may
fail to converge or return near-empty classes; such fits are reported
with NA.
Arguments
- formula, data, index, family, concomitant, ...
passed to
panfmm()- k
integer vector of numbers of classes
Value
a data.frame with columns k, logLik, df, AIC, BIC and
smallest (the smallest mean class probability), with the fits in the
attribute "fits"
Validation
Numerical accuracy is checked in the package tests and in the validation suite; see the validation article on the package website.
See also
Other panel models:
panfmm(),
panglm(),
pangmm(),
panhurdle(),
paniv(),
panqr(),
panselect(),
twopart()
Examples
set.seed(3)
d <- data.frame(id = rep(1:150, each = 3), t = rep(1:3, 150), x = rnorm(450))
d$y <- rpois(450, exp(ifelse(rep(rbinom(150, 1, 0.4), each = 3) == 1, 1.5, 0) + 0.3 * d$x))
panfmmselect(y ~ x, data = d, index = c("id", "t"), k = 1:2, nstart = 2, seed = 1)
#> k logLik df AIC BIC smallest
#> 1 1 -1004.9506 2 2013.901 2022.120 1.0000000
#> 2 2 -799.9038 5 1609.808 1630.354 0.3791781
# \donttest{
# up to three classes (a few seconds)
panfmmselect(y ~ x, data = d, index = c("id", "t"), k = 1:3, nstart = 2, seed = 1)
#> k logLik df AIC BIC smallest
#> 1 1 -1004.9506 2 2013.901 2022.120 1.0000000
#> 2 2 -799.9038 5 1609.808 1630.354 0.3791781
#> 3 3 -798.7190 8 1613.438 1646.312 0.1170190
# }