dmm
creates an object of class dmm
, a
dependent mixture model.}
lca
creates an object of class dmm,lca
, a
latent class model or an independent mixture model. }dmm(nstates, itemtypes, modname = NULL, fixed = NULL,
stval = NULL, conrows = NULL, conpat = NULL, tdfix =
NULL, tdst = NULL, linmat = NULL, snames = NULL,
inames = NULL)
## S3 method for class 'dmm':
summary(object, specs=FALSE, precision=3, se=NULL, ...)
lca(nclasses, itemtypes, modname = NULL, fixed = NULL,
stval = NULL, conrows = NULL, conpat = NULL,
linmat = NULL, snames = NULL, inames = NULL)
dmm
model. They are now called classes because they do
not change over time.nitems
providing the type of
measurement, 1 for gaussian data, 2 for a binary item, n>3 for
categorical items with n answer possibilities. Answer categories are
assumed to be unordered categorical. Ordinal responses conrows
can be used to specify general
constraints between parameters. See details below.conpat
can be used to specify fixed
parameters and equality constraints. It can not be used in conjuction
with fixed. See details below.dmm
.dmm
.dmm
returns an object of class dmm
which has its own summary
method. This will print the parameter values, itemtypes, number of (free)
parameters, and the number of states. There is no print method. Using
print will print all fields of the model which is a list of the following:fixed
is a (logical) vector of length npars
specifying which parameters are fixed and which are not.lca
returns an object of class dmm, lca
, and is otherwise
identical to a dmm
object. The only difference is that the
transition matrix parameters are irrelevant, and
consequently they are not printed in the summary function.dmm
creates an object of class dmm
and sets
random initial parameter values if these are not provided. Even though
dmm
is not a mixture of Markov models, the mixture parameter is
is included in the parameter vector. This is important when specifying
constraints. Parameters are ordered as follows: the first parameter(s)
are the mixing proportions of the mixture of Markov and/or latent class
models. I.e., when a single latent class model or a single Markov
chain is fitted, this mixture proportion has value 1.0 and is it is
fixed in estimation. After the mixing proportions, the next parameters
in the parameter vector are the transition matrix parameters, the
square of nstates in row-major order. That is, first the transition
probabilities from state 1 to all the other states are given, then the
probabilities from state 2 to all the other states etc. Next are the
observation matrix parameters. These are provided consecutively for
each state/class. Ie a trichtomous item model with two states has 6
observation parameters; the first three are the probabilities of
observing category 1, 2 and 3 respectively in state 1 (which sum to
one), and then similarly for state 2. As another example: suppose we
have model for one binary item and one gaussian item, in that order, we
would have 4 observation parameters for each state, first the
probabilities of observing a symbol from category 1 or 2 in state 1,
the two parameters, the mean and standard deviation for state 1, and
then the same state 2 (see the example in fitdmm with data from rudy).
Finally the initial state probabilities are provided, in the order of
the states. In the case of a latent class model or a finite mixture
model, these parameters are usually denote as the mixture proportions.
Linear constraints can be set using arguments conrows
and
conpat
. conrows
must be contain nc by npars values, in
row major order, with nc the number of contraints to be specified.
conrows
is used to define general linear constraints. A row of
conrows
must contain the partial derivatives of a general linear
constraint with respect to each of the parameters. Suppose we want the
constraint x1 -2*x2=0, one row of conrows should contain a 1 in
position one and -2 in position and zeroes in the remaining positions.
In the function mixdmm
conrows
is understood to specify
linear constraints on the mixing proportions only. As a consequence,
it is not possible to easily constrain parameters between components of
a mixture model.
conpat
can be used as a shortcut for both fixed and conrows. It
must be a single vector of length npars contaning 0's (zeroes) for
fixed parameters, 1's (ones) for free parameters and higher numbers for
possibly equality constrained parameters. E.g.
conpat=c(1,1,0,2,2,3,3,3)
would indicate that pars 1 and 2 are
freely estimated, par 3 is fixed at its startvalue (which must be
provided in this case), par 4 and 5 are to estimated equal and pars 6,
7 and 8 are also to be estimated equal.mixdmm
on defining mixtures of dmm
's,
mgdmm
for defining multi group models, and
generate
for generating data from models.# create a 2 state model with one continuous and one binary response
# with start values provided in st
st <- c(1,0.9,0.1,0.2,0.8,2,1,0.7,0.3,5,2,0.2,0.8,0.5,0.5)
mod <- dmm(nsta=2,itemt=c(1,2), stval=st)
summary(mod)
# 2 class latent class model with equal conditional probabilities in each class
stv=c(1,rep(c(0.9,0.1),5),rep(c(0.1,0.9),5),0.5,0.5)
# here the conditional probs of the first item are set equal to those in
# the subsequent items
conpat=c(1,rep(c(2,3),5),rep(c(4,5),5),1,1)
lc=lca(ncl=2,itemtypes=rep(2,5),conpat=conpat,stv=stv)
summary(lc)
Run the code above in your browser using DataLab