obtain_emiss {mHMMbayes}R Documentation

Obtain the emission distribution probabilities for a fitted multilevel HMM

Description

obtain_emiss obtains the emission distribution for an object containing a fitted multilevel hidden Markov model, either at the group level, i.e., representing the average emission distribution over all subjects, or at the subject level, returning the emission distribution for each subject.

Usage

obtain_emiss(object, level = "group", burn_in = NULL)

Arguments

object

An object of class mHMM, generated by the function mHMM.

level

String specifying if the returned transition probability matrix gamma should be at the group level (level = "group"), i.e., representing the average transition probability matrix over all subjects, or at the subject level (level = "subject").

burn_in

An integer which specifies the number of iterations to discard when obtaining the model parameter summary statistics. When left unspecified (burn_in = NULL), the burn in period specified when creating the mHMM object will be used.

Value

obtain_emiss creates an object of the class mHMM_emiss. Depending on the specification at the input variable level, the output is either a list of matrices with the emission distribution at the group level (if level = "group") for each dependent variable, or a list of lists, where for each dependent variable a list is returned with the number of elements equal to the number of subjects analyzed (if level = 'subject'). In the latter scenario, each matrix in the lower level list represents the subject specific emission distribution for a specific dependent variable.

See Also

mHMM for fitting the multilevel hidden Markov model.

Examples

###### Example on package data, see ?nonverbal

# specifying general model properties:
m <- 2
n_dep <- 4
q_emiss <- c(3, 2, 3, 2)

# specifying starting values
start_TM <- diag(.8, m)
start_TM[lower.tri(start_TM) | upper.tri(start_TM)] <- .2
start_EM <- list(matrix(c(0.05, 0.90, 0.05,
                          0.90, 0.05, 0.05), byrow = TRUE,
                        nrow = m, ncol = q_emiss[1]), # vocalizing patient
                 matrix(c(0.1, 0.9,
                          0.1, 0.9), byrow = TRUE, nrow = m,
                        ncol = q_emiss[2]), # looking patient
                 matrix(c(0.90, 0.05, 0.05,
                          0.05, 0.90, 0.05), byrow = TRUE,
                        nrow = m, ncol = q_emiss[3]), # vocalizing therapist
                 matrix(c(0.1, 0.9,
                          0.1, 0.9), byrow = TRUE, nrow = m,
                        ncol = q_emiss[4])) # looking therapist

# Run a model without covariate(s):
out_2st <- mHMM(s_data = nonverbal,
                gen = list(m = m, n_dep = n_dep, q_emiss = q_emiss),
                start_val = c(list(start_TM), start_EM),
                mcmc = list(J = 11, burn_in = 5))

out_2st
summary(out_2st)

# obtaining the emission probabilities at the group and subject level
obtain_emiss(out_2st, level = "group")
obtain_emiss(out_2st, level = "subject")




[Package mHMMbayes version 1.1.0 Index]