LaMa: Fast Numerical Maximum Likelihood Estimation for Latent Markov Models

A variety of latent Markov models, including hidden Markov models, hidden semi-Markov models, state-space models and continuous-time variants can be formulated and estimated within the same framework via directly maximising the likelihood function using the so-called forward algorithm. Applied researchers often need custom models that standard software does not easily support. Writing tailored 'R' code offers flexibility but suffers from slow estimation speeds. We address these issues by providing easy-to-use functions (written in 'C++' for speed) for common tasks like the forward algorithm. These functions can be combined into custom models in a Lego-type approach, offering up to 10-20 times faster estimation via standard numerical optimisers. To aid in building fully custom likelihood functions, several vignettes are included that show how to simulate data from and estimate all the above model classes.

Version: 2.1.2
Depends: R (≥ 3.5.0), RTMB (≥ 1.9.0)
Imports: Rcpp, stats, utils, methods, Matrix, splines2, mgcv, MASS, numDeriv, RTMBdist (≥ 1.0.5)
LinkingTo: Rcpp, RcppArmadillo
Suggests: knitr, rmarkdown, testthat (≥ 3.0.0), PHSMM, MSwM, scales
Published: 2026-07-24
DOI: 10.32614/CRAN.package.LaMa
Author: Jan-Ole Fischer ORCID iD [aut, cre]
Maintainer: Jan-Ole Fischer <jan-ole.fischer at mailbox.org>
License: MIT + file LICENSE
URL: https://janolefi.github.io/LaMa/
NeedsCompilation: yes
Materials: README, NEWS
CRAN checks: LaMa results

Documentation:

Reference manual: LaMa.html , LaMa.pdf
Vignettes: Continuous-time_HMMs (source, R code)
Model extensions (source, R code)
Hidden semi-Markov models (source, R code)
Introduction to LaMa (source, R code)
LaMa_and_RTMB (source, R code)
Longitudinal data (source, R code)
MMMPPs (source, R code)
Penalised_splines (source, R code)
State-space models (source, R code)

Downloads:

Package source: LaMa_2.1.2.tar.gz
Windows binaries: r-devel: not available, r-release: not available, r-oldrel: not available
macOS binaries: r-release (arm64): not available, r-oldrel (arm64): not available, r-release (x86_64): not available, r-oldrel (x86_64): not available
Old sources: LaMa archive

Linking:

Please use the canonical form https://CRAN.R-project.org/package=LaMa to link to this page.