###### Example using simulated data
# specifying general model properties:
m <- 3
n_dep <- 2
# hypothesized hyper-prior values for the count emission distribution
manual_prior_emiss <- prior_emiss_count(
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(16, m), rep(4, m)),
emiss_nu = list(0.1, 0.1))
# to use the informative priors in a model, simulate multivariate count data
n_t <- 100
n <- 10
# Specify group-level transition and emission means
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(log(c( 50,
100,
150)), nrow = m, byrow = TRUE),
matrix(log(c(5,
10,
20)), nrow = m, byrow = TRUE))
# Simulate data
data_count <- sim_mHMM(n_t = n_t, n = n, data_distr = 'count',
gen = list(m = m, n_dep = n_dep),
gamma = gamma, emiss_distr = emiss_distr,
var_gamma = .1, var_emiss = c(.05, 0.01), log_scale = TRUE)
# Specify starting values
start_gamma <- gamma
start_emiss <- list(matrix(c(50,
100,
150), nrow = m, byrow = TRUE),
matrix(c(5,
10,
20), nrow = m, byrow = TRUE))
# 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_count_sim_infemiss <- mHMM(s_data = data_count$obs,
data_distr = "count",
gen = list(m = m, n_dep = n_dep),
start_val = c(list(start_gamma), start_emiss),
emiss_hyp_prior = manual_prior_emiss,
mcmc = list(J = 11, burn_in = 5))
out_3st_count_sim_infemiss
summary(out_3st_count_sim_infemiss)
Run the code above in your browser using DataLab