posterior_prob_normal {oHMMed} | R Documentation |
Forward-Backward Algorithm to Calculate the Posterior Probabilities of Hidden States in Normal Model
Description
Forward-Backward Algorithm to Calculate the Posterior Probabilities of Hidden States in Normal Model
Usage
posterior_prob_normal(data, pi, mat_T, means, sdev)
Arguments
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 |
Details
Please see supplementary information at doi:10.1186/s12859-024-05751-4 for more details on the algorithm.
Value
List with the following elements:
-
F
: auxiliary forward variables -
B
: auxiliary backward variables -
s
: weights
Examples
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)
[Package oHMMed version 1.0.2 Index]