Em_tot | R Documentation |
Use EM algorithm to estimate the parameters A Pi and f1 of an HMM
Em_tot(m, A, Pi, f0x, f1x, x, eps, maxit, h)
m |
the number of positions (hypothesis) |
A |
a matrix 2 * 2 the transition probabilities |
Pi |
a vector of the initial state 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 |
eps |
the value ta reach for the convergence |
maxit |
integer, the maximum number of iteration |
alpha |
a matrix m * 2 containing the forward variables |
beta |
a matrix m * 2 containing the backward variables |
Product of matrices
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 <- simulate.data.hmm.2states(m, Pi, A, f0, f1)
x <- rdata$x
theta <- rdata$theta
mod <- for_back(m, A, f0x, f1x, Pi)
f0x <- dnorm(x, f0[1], f0[2])
f1x <- dnorm(x, f1[1], f1[2])
alpha <- mod$alpha
beta <- mod$beta
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.