funHMM fits topological hidden Markov models to
time-ordered sequences of curves (functional data,
sample paths of stochastic processes) without first projecting the
curves onto a finite basis. The emission functions are Onsager-Machlup
functionals of Gaussian measures on function spaces, as developed in
Kashlak, A. B., Loliencar, P. and Heo, G. (2023). Topological Hidden Markov Models. Journal of Machine Learning Research, 24(340), 1-49. https://jmlr.org/papers/v24/22-0685.html
Three emission models are available:
"bmwd": Brownian motion with a state-dependent linear
drift, including fractional Brownian motion with a fixed Hurst
parameter;"ou": the Ornstein-Uhlenbeck process with
state-dependent mean and mean-reversion rate;"nonpar": non-parametric state mean curves under an
L2, W21 (Sobolev) or W22
Cameron-Martin norm.The Baum-Welch (EM) and Viterbi algorithms are implemented in C and run on the log scale, so they are fast and numerically stable for long sequences.
# from CRAN (once accepted)
install.packages("funHMM")
# from a source tarball
install.packages("funHMM_0.1.0.tar.gz", repos = NULL, type = "source")library(funHMM)
set.seed(137)
A <- matrix(0.09, 5, 5) + 0.55 * diag(5) # transition matrix A1 of the paper
sim <- rthmm(200, init.prob = c(1, 0, 0, 0, 0), trans = A,
type = "bmwd", par = c(-8, -4, 0, 4, 8), len = 100)
fit <- thmm(sim$data, nstates = 5, type = "bmwd")
fit
table(fit$states, sim$states) # decoded vs true states
ari(fit$states, sim$states) # adjusted Rand index
plot(fit)See vignette("funHMM") for a tour of all three models
that reproduces the simulation studies of the paper.