# NOT RUN {
# }
# NOT RUN {
data(CAT)
y <- CAT$activity
x <- data.matrix(CAT$night)
prior_init <- c(0.5,0.3,0.2)
dt_init <- c(0.9,0.6,0.3)
emit_init <- c(10,50,100)
zero_init <- c(0.5,0,0) #assuming only the 1st state has structural zero's
tpm_init <- matrix(c(0,0.3,0.7,0.4,0,0.6,0.5,0.5,0),3,3,byrow=TRUE)
trunc <- c(10,7,4)
fit2 <- hsmmfit(y,rep(1440,3),3,trunc,prior_init,"log",dt_init,tpm_init,
emit_init,zero_init,emit_x=x,zeroinfl_x=x,hessian=FALSE,
method="Nelder-Mead", control=list(maxit=500,trace=1))
decode <- hsmmviterbi2(y,rep(1440,3),3,trunc,fit2$working_parameters,
dt_dist="log", zero_init=c(1,0,0),
emit_x=x,zeroinfl_x=x, plot=TRUE, xlab="time", ylab="count",
xlim=c(0,360),ylim=c(0,200))
# }
Run the code above in your browser using DataLab