'depmix' and 'mix' methods.

Description

Various methods for depmix and mix objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
	
	## S4 method for signature 'depmix'
logLik(object,method=c("fb","lystig","classification"),na.allow=TRUE)
	## S4 method for signature 'mix'
logLik(object,method=c("fb","lystig","classification"),na.allow=TRUE)
	
	## S4 method for signature 'depmix.fitted.classLik'
logLik(object,method=c("classification","fb","lystig"),na.allow=TRUE)
	## S4 method for signature 'mix.fitted.classLik'
logLik(object,method=c("classification","fb","lystig"),na.allow=TRUE)
	
	## S4 method for signature 'depmix'
nobs(object, ...)
	## S4 method for signature 'mix'
nobs(object, ...)
	
	## S4 method for signature 'depmix'
npar(object)
	## S4 method for signature 'mix'
npar(object)
	
	## S4 method for signature 'depmix'
freepars(object)
	## S4 method for signature 'mix'
freepars(object)
	
	## S4 method for signature 'depmix'
setpars(object,values, which="pars",...)
	## S4 method for signature 'mix'
setpars(object,values, which="pars",...)
	
	## S4 method for signature 'depmix'
getpars(object,which="pars",...)	
	## S4 method for signature 'mix'
getpars(object,which="pars",...)	
	
	## S4 method for signature 'depmix'
getmodel(object,which="response",state=1,number=1)	
	## S4 method for signature 'mix'
getmodel(object,which="response",state=1,number=1)

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 (Rabiner, 1989), or by the method of Lystig and Hughes, 2002. The former is the default and implemented in a fast C routine. The forward-backward routine also computes the state and transition smoothed probabilities, which are not directly neccessary for the log likelihood. Those smoothed variables, and the forward and backward variables are accessible through the forwardbackward function. When method="classification", the classification likelihood is computed, which is the likelihood of the data assuming the state sequence is known and equal to the maximum a posteriori state sequence. The MAP state sequence is available through the viterbi function. The classification likelihood is comuted by default when calling the logLik method on an a model fitted by maximising the classification likelihood.

na.allow

Allow missing observations? When set to FALSE, the logLik method will return NA in the presence of missing observations. When set to TRUE, missing values will be ignored when computing the likelihood. When observations are partly missing (when a multivariate observation has missing values on only some of its dimensionis), this may give unexpected results.

which

getpars function: The default "pars" returns a vector of all parameters of a depmix object; the alternative value "fixed" returns a logical vector of the same length indicating which parameters are fixed. The setpars functions sets parameters 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.

getmodel function: possible values are "response" (the default), "prior" and "transition" to return the corresponding submodels.

state

In getmodel this determines the submodel to be returned (together with number in the case of response models); when which="transition", getmodel returns the transition submodel for state=state.

number

In getmodel this determines the "response" model to be returned from state state.

...

Not used currently.

Value

logLik

returns a logLik object with attributes df and nobs.

nobs

returns the number of observations (used in computing the BIC).

npar

returns the number of paramaters of a model.

freepars

returns the number of non-redundant parameters.

setpars

returns a (dep-)mix object with new parameter values.

getpars

returns a vector with the current parameter values.

getmodel

returns a submodel of a (dep-)mix model; the prior model, one of the transition models (determined by argument state) or one of the response models (determined by arguments state and number).

Author(s)

Ingmar Visser

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# 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()))

getmodel(mod,"response",2,1)

getmodel(mod,"prior")

# 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