hmmsmooth.cont3: Compute the posterior state probabilities for continuous-time...

Description Usage Arguments Value References Examples

View source: R/hmmsmooth.cont3.R

Description

Compute the posterior state probabilities for continuous-time hidden Markov models with covariates in the state-dependent parameters and transition rates

Usage

1
hmmsmooth.cont3(y, x, M, prior, tpmparm, zeroparm, emitparm, timeindex)

Arguments

y

the observed series to be decoded

x

matrix of covariates in the state-dependent parameters and transition rates.

M

number of latent states

prior

prior parameters from the fitted continuous-time hidden Markov model

tpmparm

parameters from the fitted continuous-time hidden Markov model

zeroparm

parameters for the structural zero proportions in the fitted continuous-time hidden Markov model

emitparm

parameters for the Poisson means in the fitted continuous-time hidden Markov model

timeindex

a vector containing the time points

Value

posterior state probabilities

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
15
16
17
18
19
20
21
22
23
## Not run: 
set.seed(2910)
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

fit2 <-  fasthmmfit.cont3(y=y,x=designx,M=2,
  initparm=workparm, timeindex=timeindex,
  hessian=FALSE, method="CG", control=list(trace=1))
post <- hmmsmooth.cont3(y,designx,2,fit2$prior,fit2$tpm,fit2$zeroparm,
       fit2$emitparm,timeindex)

## End(Not run)

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