I am totally new in HMM and JAGS. My question is how can I get the hidden state sequence based on the trained model structure and parameters.
Specifically, I have trained a hidden Markov model by using rjags, and saved the sample results of model parameters, which contains 59 parameters with the lengths of 1000 (30000 iters, thining = 30).
So right now, I have the model structure which has been correctly written in the manner of JAGS, and the updated parameters(30000 burn-in, 30000 sample iters with 30 thinning). The question is, how can I get the corresponding hidden states?
I’ve been working on machine learning for a while, so my thought is loading the structure and parameters at first, then inputting a test sequence of observable states, then I will get what I want. But it seems different.
So far, I didn’t find any samples of this question, even in JAGS’s document.
Dose anyone know something about this? Thanks a lot.
My training code is as below:
# ------------------- model ------------------------#
load('./data/try_3_gtx_3d.RData')
library(rjags)
library(mcmcplots)
data_1 <- list(Y = three_dim_smc_data-1,
M = dim(team_id_unique_ordered)[1],
N = one_dim_sample_count,
T = two_dim_sample_length,
gp = three_dim_gp_data,
sm = three_dim_sm_data) # Y should be 0 and 1
inits_HMM <- list( beta0.p = runif(2, -10, 10))
parameters <- c("beta0", "PAD", "PDA", "bAD", "bDA", "sigmaAD", "sigmaDA",
"sigmab", "betagp",
"b", "delta0", 'betasm')
result <- jags.model("model/longitudinal_model_gp_sm_try1_gtx.txt", data_1, inits_HMM, n.chains = 3, n.adapt = 0)
update(result, n.iter = 30000)
rsamps_relience_pg_sm_try2 <- coda.samples(result, parameters, n.iter = 30000,
thin = 30)
save(rsamps_relience_pg_sm_try2, file = './results/rsamps_resilience_pg_sm_try3.RData')
mcmcplot(rsamps_relience_pg_sm_try2)
summary(rsamps_relience_pg_sm_try1)$statistics[-(c(3 : 317)),]
summary(rsamps_relience_pg_sm_try1)$quantiles[-(c(3 : 317)),]
If any other materials required, please inform me. Thank you so much!
I’m trying to output the sequences of hidden states corresponding to the given test observable state sequences, based on the model structure and well-trained parameters.
gtx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.