# hmmviterbi.cont: Viterbi algorithm to decode the latent states for... In ziphsmm: Zero-Inflated Poisson Hidden (Semi-)Markov Models

## Description

Viterbi algorithm to decode the latent states for continuous-time hidden Markov models without covariates

## Usage

 ```1 2``` ```hmmviterbi.cont(y, M, prior_init, tpm_init, emit_init, zero_init, timeindex, plot = FALSE, xlim = NULL, ylim = NULL, ...) ```

## Arguments

 `y` the observed series to be decoded `M` number of latent states `prior_init` a vector of prior probability values `tpm_init` transition rate matrix `emit_init` a vector containing means for each poisson distribution `zero_init` a vector containing structural zero proportions in each state `timeindex` a vector containing the time points `plot` whether a plot should be returned `xlim` vector specifying the minimum and maximum on the x-axis in the plot. Default to NULL. `ylim` vector specifying the minimum and maximum on the y-axis in the plot. Default to NULL. `...` further arguments to be passed to the plot() function

## Value

the decoded series of latent states

## References

Walter Zucchini, Iain L. MacDonald, Roland Langrock. Hidden Markov Models for Time Series: An Introduction Using R, Second Edition. Chapman & Hall/CRC

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```prior_init <- c(0.5,0.2,0.3) emit_init <- c(10,40,70) zero_init <- c(0.5,0,0) omega <- matrix(c(-0.3,0.2,0.1,0.1,-0.2,0.1,0.2,0.2,-0.4),3,3,byrow=TRUE) timeindex <- rep(1,1000) for(i in 2:1000) timeindex[i] <- timeindex[i-1] + sample(1:3,1) result <- hmmsim.cont(n=1000,M=3,prior=prior_init, tpm_parm=omega, emit_parm=emit_init,zeroprop=zero_init,timeindex=timeindex) y <- result\$series fit2 <- fasthmmfit.cont(y,x=NULL,M=3,prior_init,omega, emit_init,0.5,timeindex=timeindex,hessian=FALSE, method="BFGS", control=list(maxit=500,trace=1)) decode2 <- hmmviterbi.cont(y,3,fit2\$prior,fit2\$tpm,fit2\$emit, c(fit2\$zeroprop,0,0),timeindex=timeindex) ```

ziphsmm documentation built on May 2, 2019, 6:10 a.m.