obtain_emiss: Obtain the emission distribution probabilities for a fitted...

Description Usage Arguments Value See Also Examples

View source: R/obtain_emiss.R

Description

obtain_emiss obtains the emission distribution probabilities (also known as conditional probabilities) for a fitted multilevel hidden Markov model, for either the group level, i.e., representing the average emission distribution probabilities over all subjects, or at the subject level, returning the emission distribution probabilities for each subject.

Usage

1
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 emission distribution probabilities should be at the group level (level = "group"), i.e., representing the average emission distribution probabilities 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 with the function mHMM will be used.

Value

obtain_emiss returns the object est_emiss. Depending on the specification at the input variable level, est_emiss is either a list of matrices with the emission distribution probabilities 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 probabilities for a specific dependent variable.

See Also

mHMM for fitting the multilevel hidden Markov model, creating the object mHMM.

Examples

 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
###### Example on package data

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

mHMMbayes documentation built on Oct. 30, 2019, 5:05 p.m.