depmix
creates an object of class depmix
, a dependent
mixture model, otherwise known as hidden Markov model. For a short
description of the package see depmixS4
.depmix(response, data=NULL, nstates, transition=~1, family=gaussian(),
prior=~1, initdata=NULL, respstart=NULL, trstart=NULL, instart=NULL,
ntimes=NULL,...)
family
's if the response is multivariate.prior
. The number of rows of this data.frame
must be equal to the number of cases being modeled,
length(ntimes)
. See 'Details'.ntimes=nrow(data)
.
If the data
argument has an attribute ntimes, tdepmix
returns an object of class depmix
which has the
following slots:transInit
models, ie multinomial
logistic models with length the number of states.depmix-class
help for
details. For internal use.depmix
creates an S4 object of class depmix
,
which needs to be fitted using fit
to optimize the
parameters.
The response model(s) are by default created by call(s) to
GLMresponse
using the formula
and the family
arguments, the latter specifying the error distribution. See
GLMresponse
for possible values of the family
argument for glm
-type responses (ie a subset of the glm
family options, and the multinomial). Alternative response
distributions are specified by using the makeDepmix
function. Its help page has examples of specifying a model with a
multivariate normal response, as well as an example of adding a
user-defined response model, in this case for the ex-gauss
distribution.
If response
is a list of formulae, the response
's are
assumed to be independent conditional on the latent state.
The transitions are modeled as a multinomial logistic model for each
state. Hence, the transition matrix can be modeled using time-varying
covariates. The prior density is also modeled as a multinomial
logistic. Both of these models are created by calls to
transInit
.
Starting values for the initial, transition, and response models may be
provided by their respective arguments. NB: note that the starting
values for the initial and transition models as well as of the
multinomial logit response models are interpreted as probabilities, and
internally converted to multinomial logit parameters. The order in
which parameters must be provided can be easily studied by using the
setpars
and getpars
functions.
Linear constraints on parameters can be provided as argument to the
fit
function.
The print function prints the formulae for the response, transition and
prior models along with their parameter values.Lawrence R. Rabiner (1989). A tutorial on hidden Markov models and selected applications in speech recognition. Proceedings of IEEE, 77-2, p. 267-295.
fit
, transInit
, GLMresponse
,
depmix-methods
for accessor functions to depmix
objects.
For full control see the makeDepmix
help page and its
example section for the possibility to add user-defined response
distributions.# create a 2 state model with one continuous and one binary response
data(speed)
mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,family=list(gaussian(),multinomial()))
# print the model, formulae and parameter values
mod
Run the code above in your browser using DataLab