posterior_prob_normal | R Documentation |
Forward-Backward Algorithm to Calculate the Posterior Probabilities of Hidden States in Normal Model
posterior_prob_normal(data, pi, mat_T, means, sdev)
data |
(numeric) normal data |
pi |
(numeric) prior probability of states |
mat_T |
(matrix) transition probability matrix |
means |
(numeric) vector with prior means |
sdev |
(numeric) prior standard deviation |
Please see supplementary information at \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1186/s12859-024-05751-4")} for more details on the algorithm.
List with the following elements:
F
: auxiliary forward variables
B
: auxiliary backward variables
s
: weights
prior_mat <- rbind(c(1-0.05, 0.05, 0),
c(0.05, 1-0.1, 0.05),
c(0, 0.05, 1-0.05))
prior_means <- c(-0.1, 0.0, 0.1)
prior_sd <- sqrt(0.1)
L <- 100
# Simulate HMM model based on normal data based on prior information
sim_data_normal <- hmm_simulate_normal_data(L = L,
mat_T = prior_mat,
means = prior_means,
sigma = prior_sd)
pi <- sim_data_normal$pi
# pi <- get_pi(prior_mat)
hmm_norm_data <- sim_data_normal$data
# Calculate posterior probabilities of hidden states
post_prob <- posterior_prob_normal(data = hmm_norm_data,
pi = pi,
mat_T = prior_mat,
means = prior_means,
sdev = prior_sd)
str(post_prob)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.