depmix {depmixS4}R Documentation

Dependent Mixture Model Specifiction

Description

depmixS4 is a framework for specifying and fitting dependent mixture models, otherwise known as hidden or latent Markov models. Optimization is done with the EM algorithm or optionally with Rdonlp2 when constraints on parameters are imposed. Models for different distributions can easily be added.

depmix creates an object of class depmix, a dependent mixture model, otherwise known as hidden Markov model.

Usage

        
        depmix(response, data=NULL, nstates, transition=~1, family=gaussian(), 
                prior=~1, initdata=NULL, respstart=NULL, trstart=NULL, instart=NULL,
                ntimes=NULL,...)
        
	## S4 method for signature 'depmix':
        summary(object)
	## S4 method for signature 'depmix':
        logLik(object)
	## S4 method for signature 'depmix':
        AIC(object)
	## S4 method for signature 'depmix':
        BIC(object)
	## S4 method for signature 'depmix':
        nobs(object)
        
	## S4 method for signature 'depmix':
        npar(object)
	## S4 method for signature 'depmix':
        freepars(object)
	## S4 method for signature 'depmix':
        setpars(object,which="pars",...)
	## S4 method for signature 'depmix':
        getpars(object,which="pars",...)     
        

Arguments

object An object with class depmix.
response The response to be modeled; either a formula or a list of formulae in the multivariate case. See details.
data An optional data.frame to interpret the variables in response and transition.
nstates The number of states of the model.
transition A one-sided formula specifying the model for the transitions. See details.
family A family argument for the response. This must be a list of family's if the response is multivariate.
prior A one-sided formula specifying the density for the prior or initial state probabilities.
initdata An optional data.frame to interpret the variables occuring in prior. The number of rows of this data.frame must be equal to the number of cases being modeled. See details.
respstart Starting values for the parameters of the response models.
trstart Starting values for the parameters of the transition models.
instart Starting values for the parameters of the prior or initial state probability model.
ntimes A vector specifying the lengths of individual, ie independent, time series. If not specified, the responses are assumed to form a single time series. If the data argument has an attribute ntimes, then this is used.
which The default "pars" returns a vector of all parameters of a 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 logical fixed vector) to new values; setpars also recomputes the dens, trans and init slots of depmix objects. Note that the getpars and setpars functions for depmix objects simply call the functions of the same name for the response and transition models.
... Not used currently.

Details

The function 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.

Value

depmix returns an object of class depmix which has the following slots:

response A list of a list of response models; the first index runs over states; the second index runs over the independent responses in case a multivariate response is provided.
transition A list of transInit models, ie multinomial logistic models with length the number of states.
prior A multinomial logistic model for the initial state probabilities.
dens,trDens,init See depmix-class help for details. For internal use.
stationary Logical indicating whether the transitions are time-dependent or not; for internal use.
ntimes A vector containing the lengths of independent time series; if data is provided, sum(ntimes) must be equal to nrow(data).
nstates The number of states of the model.
nresp The number of independent responses.
npars The total number of parameters of the model. This is not the degrees of freedom, ie there are redundancies in the parameters, in particular in the multinomial models for the transitions and prior.


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.

Author(s)

Ingmar Visser i.visser@uva.nl

References

On hidden Markov models: Lawrence R. Rabiner (1989). A tutorial on hidden Markov models and selected applications in speech recognition. Proceedings of IEEE, 77-2, p. 267-295.

On latent class models: A. L. McCutcheon (1987). Latent class analysis. Sage Publications.

See Also

depmix.fit, transInit, response.

Examples


# 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"))
mod


[Package depmixS4 version 0.1-0 Index]