R Package for the estimation and inference of hidden Markov models and hidden semi-Markov models.
install.packages(c('pkgload', 'evd', 'extRemes', 'mnormt'))Load the package with
library(devtools)
load_all('path/to/HMMHSMM')where path/to is the path to the location where HMMHSMM
resides.
library(HMMHSMM)
J <- 3
delta <- c(1,0,0)
Pi <- matrix(c(0.9, 0.05, 0.05,
0.2,0.7, 0.1,
0.05, 0.15, 0.8), byrow=TRUE, nrow=J)
obspar <- list(loc=c(-3, 5, 10), scale=c(1, 2, 4), shape=c(-0.2, 0.3, 0.5))
fulldata <- generateHMM(n=1000, J=J, obsdist="gev", obspar=obspar, Pi=Pi, delta=delta, seed=123)
data <- fulldata$x
t0 <- Sys.time()
model <- findmleHMMnostarting(J=J, x=data, obsdist="gev", no.initials=50, EM=TRUE, seed=123)
t1 <- Sys.time()
confint <- confintHMM(x=data, HMM=model, obsdist="gev", level=0.95, B=100, EM=TRUE, seed=123)This will print
...
loglik at iter 20 : -2529.93799504314
loglik at iter 21 : -2529.93766554389
loglik at iter 22 : -2529.93766225114
function converged at iteration 22