Provides flexible maximum likelihood estimation and inference for Hidden
Markov Models (HMMs) and Hidden Semi-Markov Models (HSMMs), as well as the
underlying systems in which they operate. The package supports a wide range
of observation and dwell-time distributions, offering a flexible modelling
framework suitable for diverse practical data. Efficient implementations of
the forward-backward and Viterbi algorithms are provided via 'Rcpp' for enhanced
computational performance. Additional functionality includes model simulation,
residual analysis, non-initialised estimation, local and global decoding,
calculation of diverse information criteria, computation of confidence intervals
using parametric bootstrap methods, numerical covariance matrix estimation, and
comprehensive visualisation functions for interpreting the data-generating
processes inferred from the models. Methods follow standard approaches described
by Guédon (2003)
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