
stepFlexmix(..., k=NULL, nrep=3, verbose=TRUE, drop=TRUE, unique=FALSE)## S3 method for class 'stepFlexmix,missing':
plot(x, y, what=c("AIC", "BIC", "ICL"),
xlab=NULL, ylab=NULL, legend="topright", ...)
## S3 method for class 'stepFlexmix':
getModel(object, which="BIC")
## S3 method for class 'stepFlexmix':
unique(object, ...)
k
argument
of flexmix
k
run flexmix
nrep
times and keep only the solution with maximum
likelihood.TRUE
, show progress information during
computations.TRUE
and k
is of length 1, then a single
flexmix object is returned instead of a "stepFlexmix"
object.TRUE
, then unique()
is called on the
result, see below."stepFlexmix"
stepFlexmix
object as input and return a numeric vector like
AIC,stepFlexmix-method
(see examples below).FALSE
and what
contains more
than 1 element, a legend is placed at the specified location, see
legend
for details."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 numer 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"
.
data("Nclus")
set.seed(511)
## try 5 times for k=4
ex1 <- stepFlexmix(Nclus~1, k=4, model=FLXMCmvnorm(diag=FALSE), nrep=5)
ex1
## now 3 times each for k=2:6, specify control parameter
ex2 <- stepFlexmix(Nclus~1, k=2:6, model=FLXMCmvnorm(diag=FALSE),
control=list(minprior=0), nrep=3)
ex2
plot(ex2)
## get BIC values
BIC(ex2)
## get smallest model
getModel(ex2, which=1)
## get model with 3 components
getModel(ex2, which="3")
## get model with smallest ICL (here same as for AIC and BIC: true k=4)
getModel(ex2, which="ICL")
## now 1 time each for k=2:6, with larger minimum prior
ex3 <- stepFlexmix(Nclus~1, k=2:6, model=FLXMCmvnorm(diag=FALSE),
control=list(minprior=0.1), nrep=1)
ex3
## keep only maximum likelihood solution for each unique number of
## fitted clusters:
unique(ex3)
Run the code above in your browser using DataLab