for_back | R Documentation |
Perform the forward backward algorithm (see Rabiner 89)
for_back(m, A, f0x, f1x, Pi)
m |
the number of positions (hypothesis) |
A |
a matrix 2 * 2 the transition probabilities |
f0x |
a vector of the values of the density under the null hypothesis on the observations |
f1x |
a vector of the values of the density under the alternative hypothesis on the observations |
Pi |
a vector of the initial state probabilities |
alpha the forward variables, the lines corespond to the position, the first column is for state 0 and the second for state one
beta the backward variables (same as alpha)
gamma matrix such that gamma\[i , 0\] = P(\theta_i = 0 | X)
, gamma\[i,1\] = P(\theta_i = 1 | X)
ksi matrix such that ksi\[i , 0\] = P(\theta_i = 0 | X)
, ksi\[i,1\] = P(\theta_i = 1 | X)
m <- 10
A <- matrix(c(0.95, 0.05, 0.2, 0.80), 2, 2, byrow = T)
f0 <- c(0, 1)
f1 <- c(2, 1)
Pi <- c( 0.9, 0.1)
rdata <- sim_hmm_2states(m, Pi, A, f0, f1)
x <- rdata$x
theta <- rdata$theta
mod <- for_back(m, A, f0x = dnorm(x), f1x = dnorm(x, 1,2), Pi)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.