Learn R Programming

ziphsmm (version 2.0.6)

hmmsim3.cont: Simulate a continuous-time hidden Markov series and its underlying states with covariates in state-dependent parameters and transition rates.

Description

Simulate a continuous-time hidden Markov series and its underlying states with covariates in state-dependent parameters and transition rates.

Usage

hmmsim3.cont(workparm, M, n, zeroindex, x, timeindex)

Arguments

workparm

working parameters

M

number of latent states

n

length of the simulated series

zeroindex

a vector specifying whether a certain state is zero-inflated

x

matrix of covariates for the log poisson means, structural zero proportions and transition rates.

timeindex

a vector containing the time points

Value

simulated series and corresponding 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

Run this code
# NOT RUN {
priorparm <- 0
tpmparm <- c(-2,0.1,-0.1,-2,0.2,-0.2)
zeroindex <- c(1,0)
zeroparm <- c(0,-1,1)
emitparm <- c(2,0.5,-0.5,3,0.3,-0.2)
workparm <- c(priorparm,tpmparm,zeroparm,emitparm)
timeindex <- rep(1,1000)
for(i in 2:1000) timeindex[i] <- timeindex[i-1] + sample(1:4,1)

designx <- matrix(rnorm(2000),nrow=1000,ncol=2)
result <- hmmsim3.cont(workparm,2,1000,zeroindex,x=designx,timeindex=timeindex)
y <- result$series
state <- result$state

# }

Run the code above in your browser using DataLab