myStepFlexmix: Run 'flexmix' Repeatedly

Description Usage Arguments Value See Also Examples

Description

Runs flexmix repeatedly for different cluster values and returns the result with highest likelihood value.

Usage

1
myStepFlexmix(..., cluster, verbose = FALSE, drop = TRUE, unique = FALSE)

Arguments

cluster

List of initial cluster assignments of observations at the start of the EM algorithm.

verbose

If TRUE, show progress information during computations.

drop

If TRUE and k is of length 1, then a single flexmix object is returned instead of a "stepFlexmix" object.

unique

If TRUE, then unique() is called on the result, see below.

...

Passed to flexmix.

Value

An object of class "stepFlexmix" containing the best models with respect to the log likelihood for the different number of components in a slot if length(k)>1, else directly an object of class "flexmix". If unique=FALSE, then the resulting object contains one model per element of k (which is the number of clusters the EM algorithm started with). If unique=TRUE, then the result is resorted according to the number of clusters contained in the fitted models (which may be less than the number with which the EM algorithm started), and only the maximum likelihood solution for each number of fitted clusters is kept. This operation can also be done manually by calling unique() on objects of class "stepFlexmix".

See Also

Other mixtures: FLXMCL-class, FLXPwlda-class, FLXPwlda, myfitted, mypredict

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(benchData)
data <- xor3Data(500)
model <- FLXMCLmultinom(trace = FALSE, decay = 0.1)
cluster <- lapply(1:5, kmeans(data$x, centers = 3)$cluster)
fit <- myStepFlexmix(y ~ ., data = as.data.frame(data), concomitant = FLXPmultinom(~ x.1 + x.2), model = model, 
    cluster = cluster, control = list(verb = 1, tolerance = 10^-1))
fit2 <- flexmix(y ~ ., data = as.data.frame(data), concomitant = FLXPmultinom(~ x.1 + x.2), model = model, 
    cluster = posterior(fit), control = list(verb = 1))
pred <- mypredict(fit2, aggregate = TRUE)
mean(max.col(pred[[1]]) != data$y)

schiffner/locClass documentation built on May 29, 2019, 3:39 p.m.