prior_emiss_cont {mHMMbayes} | R Documentation |
Specifying informative hyper-prior on the continuous emission distribution(s) of the multilevel hidden Markov model
Description
prior_emiss_cont
provides a framework to manually specify an
informative hyper-prior on the Normal (i.e., Gaussian) emission
distributions. prior_emiss_cont
creates an object of class
mHMM_prior_emiss
used by the function mHMM
, and additionally
attaches the class cont
to signal use for continuous observations. The
set of hyper-prior distributions consists of a Normal-Inverse-Gamma
distribution (i.e., assuming both unknown population mean and variance
between subject level means) on the vector of means (i.e., intercepts and
regression coefficients), and an Inverse gamma distribution (i.e., assuming a
known mean) on each of the (fixed over subjects) emission variances.
Usage
prior_emiss_cont(
gen,
emiss_mu0,
emiss_K0,
emiss_V,
emiss_nu,
emiss_a0,
emiss_b0,
n_xx_emiss = NULL
)
Arguments
gen |
List containing the following elements denoting the general model properties:
|
emiss_mu0 |
A list containing |
emiss_K0 |
A list containing |
emiss_V |
A list containing |
emiss_nu |
A list containing |
emiss_a0 |
A list containing |
emiss_b0 |
A list containing |
n_xx_emiss |
Optional numeric vector with length |
Details
Estimation of the mHMM proceeds within a Bayesian context, hence a hyper-prior distribution has to be defined for the group level parameters. To avoid problems with 'label switching' when dealing with continuous emission distribution(s) (i.e., switching of the labels of the hidden states while sampling from the MCMC), the user is forced to specify hyper-prior parameter values when using continuous emission distributions (i.e., default, non-informative priors are not available for continuous emission distributions).
Note that emiss_K0
and emiss_nu
are assumed equal over the
states. Also note that in case covariates are specified, the hyper-prior
parameter values of the inverse Wishart distribution on the covariance matrix
remain unchanged, as the estimates of the regression coefficients for the
covariates are fixed over subjects.
Value
prior_emiss_cont
returns an object of class mHMM_prior_emiss
,
containing informative hyper-prior values for the continuous emission
distribution(s) of the multilevel hidden Markov model. The object is
specifically created and formatted for use by the function mHMM
,
and thoroughly checked for correct input dimensions.
The object contains the following components:
gen
A list containing the elements
m
, andn_dep
, used for checking equivalent general model properties specified underprior_emiss_cont
andmHMM
.emiss_mu0
A lists containing the hypothesized hyper-prior means of the Normal distribution on the continuous emission probabilities.
emiss_K0
A list containing
n_dep
elements denoting the number of hypothetical prior subjects on which the set of hyper-prior means specified inemiss_mu0
are based.emiss_V
A list containing
n_dep
elements containing the variance of the Inverse Gamma hyper-prior distribution on the between subject variance of the emission distribution means.emiss_nu
A list containing
n_dep
elements denoting the degrees of freedom of the Inverse Gamma hyper-prior distribution on the between subject variance of the emission distribution means.emiss_a0
A list containing
n_dep
elements denoting the shape values of the Inverse Gamma hyper-prior on each of the (fixed over subjects) emission standard deviation^2 of the Normal emission distributions.emiss_b0
A list containing
n_dep
elements denoting the scale values of the Inverse Gamma hyper-prior on each of the (fixed over subjects) emission standard deviation^2 of the Normal emission distributions.n_xx_emiss
A numeric vector denoting the number of (level 2) covariates used to predict the emission distribution of each of the dependent variables. When no covariates are used,
n_xx_emiss
equalsNULL
.
See Also
prior_gamma
for manually specifying an informative
hyper-prior on the transition probability matrix gamma, and
mHMM
for fitting a multilevel hidden Markov model.
Examples
###### Example using simulated data
# specifying general model properties:
m <- 3
n_dep <- 2
# hypothesized hyper-prior values for the continuous emission distribution
manual_prior_emiss <- prior_emiss_cont(
gen = list(m = m, n_dep = n_dep),
emiss_mu0 = list(matrix(c(30, 70, 170), nrow = 1),
matrix(c(7, 8, 18), nrow = 1)),
emiss_K0 = list(1, 1),
emiss_V = list(rep(5^2, m), rep(0.5^2, m)),
emiss_nu = list(1, 1),
emiss_a0 = list(rep(1.5, m), rep(1, m)),
emiss_b0 = list(rep(20, m), rep(4, m)))
# to use the informative priors in a model, simulate multivariate continuous data
n_t <- 100
n <- 10
gamma <- matrix(c(0.8, 0.1, 0.1,
0.2, 0.7, 0.1,
0.2, 0.2, 0.6), ncol = m, byrow = TRUE)
emiss_distr <- list(matrix(c( 50, 10,
100, 10,
150, 10), nrow = m, byrow = TRUE),
matrix(c(5, 2,
10, 5,
20, 3), nrow = m, byrow = TRUE))
data_cont <- sim_mHMM(n_t = n_t, n = n, data_distr = 'continuous',
gen = list(m = m, n_dep = n_dep),
gamma = gamma, emiss_distr = emiss_distr,
var_gamma = .1, var_emiss = c(5^2, 0.2^2))
# using the informative hyper-prior in a model
# Note that for reasons of running time, J is set at a ridiculous low value.
# One would typically use a number of iterations J of at least 1000,
# and a burn_in of 200.
out_3st_cont_sim_infemiss <- mHMM(s_data = data_cont$obs,
data_distr = "continuous",
gen = list(m = m, n_dep = n_dep),
start_val = c(list(gamma), emiss_distr),
emiss_hyp_prior = manual_prior_emiss,
mcmc = list(J = 11, burn_in = 5))
out_3st_cont_sim_infemiss
summary(out_3st_cont_sim_infemiss)