Description Usage Arguments Value References Examples
Simulate a continuous-time hidden Markov series and its underlying states with covariates
1 2 | hmmsim2.cont(workparm, M, n, zeroindex, emit_x = NULL, zeroinfl_x = NULL,
timeindex)
|
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 |
emit_x |
matrix of covariates for the log poisson means. Default to NULL. |
zeroinfl_x |
matrix of covariates for the nonzero structural zero proportions. Default to NULL. |
timeindex |
a vector containing the time points |
simulated series and corresponding states
Walter Zucchini, Iain L. MacDonald, Roland Langrock. Hidden Markov Models for Time Series: An Introduction Using R, Second Edition. Chapman & Hall/CRC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | priorparm <- 0
tpmparm <- c(-1,-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 <- hmmsim2.cont(workparm,2,1000,zeroindex,emit_x=designx,
zeroinfl_x=designx,timeindex=timeindex)
y <- result$series
state <- result$state
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.