This R package implements flexible hidden Markov models, based on Template Model Builder (TMB): flexible state-dependent distributions, transition probability structures, random effects, and smoothing splines.


The statistical background, as well as details about the implementation of the package, and several example analyses, are presented in the following preprint.

Michelot, T. (2022). hmmTMB: Hidden Markov models with flexible covariate effects in R. arXiv:2211.14139.

Package installation

The package is available on CRAN, and the stable version can therefore be installed using


The development version of the package can be installed from Github using devtools,


Package documentation

To find help files for the methods implemented in the package, search for help using the name of the corresponding class, e.g.,


We describe functionalities of the package in several vignettes: