lcmixed
is a method for the
flexmix
-function in package
flexmix
. It provides the necessary information to run an
EM-algorithm for maximum likelihood estimation for a latent class
mixture (clustering) model where some variables are continuous
and modelled within the mixture components by Gaussian distributions
and some variables are categorical and modelled within components by
independent multinomial distributions. lcmixed
can be called
within flexmix
. The function flexmixedruns
is a wrapper
function that can be run to apply lcmixed
.Note that at least one categorical variable is needed, but it is possible to use data without continuous variable.
There are further format restrictions to the data (see below in the
documentation of continuous
and discrete
), which
can be ignored when running lcmixed
through
flexmixedruns
.
lcmixed( formula = .~. , continuous, discrete, ppdim,
diagonal = TRUE, pred.ordinal=FALSE, printlik=FALSE )
lcmixed
this always has the form x~1
,
where x
is a matrix or data frome of all variables to be
involved, because regression and explanatory varTRUE
, Gaussian models are fitted
restricted to diagonal covariance matrices. Otherwise, covariance
matrices are unrestricted. TRUE
is consistent with the
"within class independence" assumption for the multFALSE
, the within-component
predicted value for categorical variables is the probability mode,
otherwise it is the mean of the standard (1,2,3,...) scores, which
may be better for ordinal variables.TRUE
, the loglikelihood is printed
out whenever computed.FLXMC
(not documented; only used
internally by flexmix
).flexmixedruns
, flexmix
,
flexmix-class
,
discrete.recode
, which recodes a dataset into the format
required by lcmixed
set.seed(112233)
data(Cars93)
Cars934 <- Cars93[,c(3,5,8,10)]
cc <-
discrete.recode(Cars934,xvarsorted=FALSE,continuous=c(2,3),discrete=c(1,4))
fcc <- flexmix(cc$data~1,k=2,
model=lcmixed(continuous=2,discrete=2,ppdim=c(6,3),diagonal=TRUE))
summary(fcc)
Run the code above in your browser using DataLab