Learn R Programming

hmmTMB

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.

Preprint

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

install.packages("hmmTMB")

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

devtools::install_github("TheoMichelot/hmmTMB")

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.,

?MarkovChain
?Observation
?HMM

We describe functionalities of the package in several vignettes:

Copy Link

Version

Install

install.packages('hmmTMB')

Monthly Downloads

260

Version

1.0.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Theo Michelot

Last Published

October 24th, 2023

Functions in hmmTMB (1.0.2)

MarkovChain

R6 class for HMM hidden process model
hmmTMB-package

hmmTMB: Fit Hidden Markov Models using Template Model Builder
Observation

R6 class for HMM observation model
mvnorm_invlink

Multivariate Normal inverse link function
as_character_formula

Read formula with as.character without splitting
logsumexp

Log of sum of exponentials
make_formulas

Process formulas and store in nested list
as_sparse

Transforms matrix to dgTMatrix
HMM

R6 class for hidden Markov model
make_matrices

Create model matrices
is_whole_number

Check if number of whole number
logLik.HMM

logLik function for SDE objects
mlogit

Multivariate logit function
hmmTMB_cols

hmmTMB colour palette
bdiag_check

Create block diagonal matrix (safe version)
quad_pos_solve

Solve for positive root of quadratic ax^2 + bx + c = 0 when it exists
invmlogit

Multivarite inverse logit function
cov_grid

Grid of covariates
mvnorm_link

Multivariate Normal link function
na_fill

Fill in NAs
update.HMM

Update a model to a new model by changing one formula
strip_comments

Strip comments marked with a hash from a character vector
prec_to_cov

Get covariance matrix from precision matrix
find_re

Find s(, bs = "re") terms in formula
Dist

R6 class for probability distribution