stepFlexmix {flexmix}R Documentation

Run FlexMix Repeatedly

Description

Runs flexmix repeatedly for different numbers of components and return the maximum likelihood solution for each.

Usage

stepFlexmix(..., K=NULL, nrep=3,
            compare=c("logLik", "BIC", "AIC"), verbose=TRUE)

Arguments

... 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.

Value

A list of objects of class "flexmix" if length(K)>1, else directly an object of class "flexmix".

Author(s)

Friedrich Leisch

Examples

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)

[Package Contents]