Learn R Programming

depmixS4 (version 0.2-1)

depmix-methods: 'depmix' and 'mix' methods.

Description

Various methods for depmix and mix objects.

Usage

## S3 method for class 'depmix':
logLik(object,method="lystig")
	## S3 method for class 'mix':
logLik(object,method="lystig")
	
	## S3 method for class 'depmix':
nobs(object, ...)
	## S3 method for class 'mix':
nobs(object, ...)
	
	## S3 method for class 'depmix':
npar(object)
	## S3 method for class 'mix':
npar(object)
	
	## S3 method for class 'depmix':
freepars(object)
	## S3 method for class 'mix':
freepars(object)
	
	## S3 method for class 'depmix':
setpars(object,values, which="pars",...)
	## S3 method for class 'mix':
setpars(object,values, which="pars",...)
	
	## S3 method for class 'depmix':
getpars(object,which="pars",...)	
	## S3 method for class 'mix':
getpars(object,which="pars",...)

Arguments

object
A depmix or mix object.
values
To be used in setpars to set new parameter values; see the example.
method
The log likelihood can be computed by either the forward backward algorithm from Rabiner, 1989, or by the method of Lystig and Hughes, 2002. The latter is the default as it is faster because in the forward backward routine the state and transition
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
...
Not used currently.

Value

  • logLikreturns a logLik object with attributes df and nobs.
  • nobsreturns the number of observations (used in computing the BIC).
  • nparreturns the number of paramters of a model.
  • freeparsreturns the number of non-fixed parameters.
  • setparsreturns a (dep-)mix object with new parameter values.
  • getparsreturns a vector with the current parameter values.

Examples

Run this code
# 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()))

# get the loglikelihood of the model
logLik(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

Run the code above in your browser using DataLab