Em_tot_01: Use EM algorithm to estimate the parameters A and Pi of an...

View source: R/RcppExports.R

Em_tot_01R Documentation

Use EM algorithm to estimate the parameters A and Pi of an HMM

Description

Use EM algorithm to estimate the parameters A and Pi of an HMM

Usage

Em_tot_01(m, A, Pi, f0x, f1x, x, eps, maxit, h)

Arguments

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

Value

Product of matrices

Examples

 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

Marie-PerrotDockes/sanssouci.hmm documentation built on Oct. 26, 2023, 10:36 a.m.