HMMR: Flexible and user-friendly probabilistic segmentation of time series (or structured longitudinal data) with regime changes by a regression model governed by a hidden Markov process, fitted by the EM (Baum-Welch) algorithm.
It was written in R Markdown, using the knitr package for production.
See help(package="samurais")
for further details and
references provided by citation("samurais")
.
hmmr <- emHMMR(univtoydataset$x, univtoydataset$y, K, p, variance_type, n_tries,
max_iter, threshold, verbose)
## EM: Iteration : 1 || log-likelihood : -1556.39696825748
## EM: Iteration : 2 || log-likelihood : -1022.479357477
## EM: Iteration : 3 || log-likelihood : -1019.51830707444
## EM: Iteration : 4 || log-likelihood : -1019.51780361393
hmmr$summary()
## ---------------------
## Fitted HMMR model
## ---------------------
##
## HMMR model with K = 5 components:
##
## log-likelihood nu AIC BIC
## -1019.518 49 -1068.518 -1178.946
##
## Clustering table (Number of observations in each regimes):
##
## 1 2 3 4 5
## 100 120 200 100 150
##
## Regression coefficients:
##
## Beta(K = 1) Beta(K = 2) Beta(K = 3) Beta(K = 4) Beta(K = 5)
## 1 6.031872e-02 -5.326689 -2.65064 120.8611 3.858683
## X^1 -7.424715e+00 157.189455 43.13601 -474.9869 13.757278
## X^2 2.931651e+02 -643.706204 -92.68115 598.3724 -34.384733
## X^3 -1.823559e+03 855.171715 66.18499 -244.5174 20.632196
##
## Variances:
##
## Sigma2(K = 1) Sigma2(K = 2) Sigma2(K = 3) Sigma2(K = 4) Sigma2(K = 5)
## 1.220624 1.111487 1.080043 0.9779724 1.028399