depmix creates an object of class depmix, a
dependent mixture model, otherwise known as hidden Markov
model.depmix(response, data=NULL, nstates, transition=~1, family=gaussian(),
prior=~1, initdata=NULL, respstart=NULL, trstart=NULL, instart=NULL,
ntimes=NULL,...)
## S3 method for class 'depmix':
summary(object)
## S3 method for class 'depmix':
logLik(object, method="lystig")
## S3 method for class 'depmix':
AIC(object, ..., k=2)
## S3 method for class 'depmix':
BIC(object, ...)
## S3 method for class 'depmix':
nobs(object, ...)
## S3 method for class 'depmix':
npar(object)
## S3 method for class 'depmix':
freepars(object)
## S3 method for class 'depmix':
setpars(object,values,which="pars",...)
## S3 method for class 'depmix':
getpars(object,which="pars",...)depmix.depmix object; the alternative value "fixed" return a
logical vector of the same length indicating which parameters are
fixed. The setpars functions sets parameters (or the logisetpars used to set the parameters to these
values.depmix returns an object of class depmix which has the
following slots:transInit models, ie multinomial
logistic models with length the number of states.logLik, AIC, and BIC return the respective values
associated with the current parameter values. nobs returns the
number of observations, ie sum(ntimes) that is used in computing the
BIC. npar returns the number of paramters of a model;
freepars returns the number of non-fixed parameters.depmix creates an S4 object of class depmix,
which needs to be fitted using depmix.fit to
optimize the parameters.
The response model(s) are created by call(s) to
response providing the family and optional
predictors. 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 as time-dependent,
depending on predictors. The prior density is also modeled as a
multinomial logistic. Both are created by calls to
transInit.
Starting values may be provided by the respective arguments. The order
in which parameters must be provided can be easily studied by using the
setpars function (see example).
Linear constraints on parameters can be provided as argument to the
depmix.fit function.depmix.fit, transInit,
response.# 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
# to see the ordering of parameters to use in setpars
mod <- setpars(mod, value=1:npar(mod))
mod
# to see which parameters are fixed (by default only baseline parameters in
# the multinomial logistic models for the transition models and the initial
# state probabilities model
mod <- setpars(mod, getpars(mod,which="fixed"))
modRun the code above in your browser using DataLab