stepFlexmix {flexmix} | R Documentation |
Runs flexmix repeatedly for different numbers of components and return the maximum likelihood solution for each.
stepFlexmix(..., K=NULL, nrep=3, compare=c("logLik", "BIC", "AIC"), verbose=TRUE)
... |
passed to flexmix |
K |
A vector of integers passed in turn to the k argument
of flexmix |
nrep |
For each value of k run flexmix
nrep times and keep only the solution with maximum
likelihood. |
compare |
Goodness of fit measure used to select the best model,
one of "logLik" , "BIC" or "AIC" . |
verbose |
If TRUE , show progress information during
computations. |
A list of objects of class "flexmix"
if length(K)>1
,
else directly an object of class "flexmix"
.
Friedrich Leisch
Friedrich Leisch. FlexMix: A general framework for finite mixture models and latent class regression in R. Journal of Statistical Software, 11(8), 2004. http://www.jstatsoft.org/v11/i08/
data(NPreg) ## try 5 times for k=2 ex1 <- stepFlexmix(yn~x+I(x^2), data=NPreg, K=2, nrep=5) ex1 ## now for k=2,3,4,5 ## low nrep to have reasonable execution time of example ## even on slow systems ex2 <- stepFlexmix(yn~x+I(x^2), data=NPreg, K=2:5, nrep=2) ex2 sapply(ex2, logLik) ## model selection: sapply(ex2, AIC) sapply(ex2, BIC)