Package: LaMa 1.0.0

Jan-Ole Koslik

LaMa: Fast Numerical Maximum Likelihood Estimation for Latent Markov Models

The class of latent Markov models, including hidden Markov models, hidden semi-Markov models, state space models, and point processes, is a very popular and powerful framework for inference of time series driven by latent processes. Furthermore, all these models can be fitted using direct numerical maximum likelihood estimation using the so-called forward algorithm as discussed in Zucchini et al. (2016) <doi:10.1201/b20790>. However, due to their great flexibility, researchers using these models in applied work often need to build highly customized models for which standard software implementation is lacking, or the construction of such models in said software is as complicated as writing fully tailored 'R' code. While providing greater flexibility and control, the latter suffers from slow estimation speeds that make custom solutions inconvenient. We address the above issues in two ways. First, standard blocks of code, common to all these model classes, are implemented as simple-to-use functions that can be added like Lego blocks to an otherwise fully custom likelihood function, making writing custom code much easier. Second, under the hood, these functions are written in 'C++', allowing for 10-20 times faster evaluation time, and thus drastically speeding up model estimation. 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.

Authors:Jan-Ole Koslik [aut, cre]

LaMa_1.0.0.tar.gz
LaMa_1.0.0.tar.gz(r-4.5-noble)LaMa_1.0.0.tar.gz(r-4.4-noble)
LaMa_1.0.0.tgz(r-4.4-emscripten)LaMa_1.0.0.tgz(r-4.3-emscripten)
LaMa.pdf |LaMa.html
LaMa/json (API)

# Install 'LaMa' in R:
install.packages('LaMa', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/janoleko/software/issues

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library

3.78 score 15 scripts 178 downloads 22 exports 6 dependencies

Last updated 5 months agofrom:80ddd682d7. Checks:OK: 2. Indexed: no.

TargetResultDate
Doc / VignettesOKOct 03 2024
R-4.5-linux-x86_64OKOct 03 2024

Exports:calc_trackIndforwardforward_gforward_pforward_sforward_spstateprobsstateprobs_gstateprobs_pstationarystationary_ptpmtpm_conttpm_gtpm_hsmmtpm_ptpm_phsmmtpm_thinnedtrigBasisExpviterbiviterbi_gviterbi_p

Dependencies:latticeMatrixmgcvnlmeRcppRcppArmadillo

Continuous-time HMMs

Rendered fromContinuous_time_HMMs.Rmdusingknitr::rmarkdownon Oct 03 2024.

Last update: 2024-06-05
Started: 2024-06-05

Hidden semi-Markov models

Rendered fromHSMMs.Rmdusingknitr::rmarkdownon Oct 03 2024.

Last update: 2024-06-05
Started: 2024-06-05

Inhomogeneous HMMs

Rendered fromInhomogeneous_HMMs.Rmdusingknitr::rmarkdownon Oct 03 2024.

Last update: 2024-06-05
Started: 2024-06-05

Introduction to LaMa

Rendered fromIntro_to_LaMa.Rmdusingknitr::rmarkdownon Oct 03 2024.

Last update: 2024-06-05
Started: 2024-06-05

Longitudinal data

Rendered fromLongitudinal_data.Rmdusingknitr::rmarkdownon Oct 03 2024.

Last update: 2024-06-05
Started: 2024-06-05

Markov-modulated (marked) Poisson processes

Rendered fromMMMPPs.Rmdusingknitr::rmarkdownon Oct 03 2024.

Last update: 2024-06-05
Started: 2024-06-05

Periodic HMMs

Rendered fromPeriodic_HMM.Rmdusingknitr::rmarkdownon Oct 03 2024.

Last update: 2024-06-05
Started: 2024-06-05

State space models

Rendered fromState_space_models.Rmdusingknitr::rmarkdownon Oct 03 2024.

Last update: 2024-06-05
Started: 2024-06-05

Readme and manuals

Help Manual

Help pageTopics
Calculate the index of the first observation of each track based on an ID variablecalc_trackInd
Forward algorithm with homogeneous transition probability matrixforward
General forward algorithm with time-varying transition probability matrixforward_g
Forward algorithm with (only) periodically varying transition probability matrixforward_p
Forward algorithm for hidden semi-Markov models with homogeneous transition probability matrixforward_s
Forward algorithm for hidden semi-Markov models with periodically varying transition probability matricesforward_sp
Calculate conditional local state probabilities for homogeneous HMMsstateprobs
Calculate conditional local state probabilities for inhomogeneous HMMsstateprobs_g
Calculate conditional local state probabilities for periodically inhomogeneous HMMsstateprobs_p
Compute the stationary distribution of a homogeneous Markov chainstationary
Compute the periodically stationary distribution of a periodically inhomogeneous Markov chainstationary_p
Build the transition probability matrix from unconstraint parameter vectortpm
Calculation of continuous time transition probabilitiestpm_cont
Build all transition probability matrices of an inhomogeneous HMMtpm_g
Build the transition probability matrix of an HSMM-approximating HMMtpm_hsmm
Build all transition probability matrices of a periodically inhomogeneous HMMtpm_p
Build all transition probability matrices of an periodic-HSMM-approximating HMMtpm_phsmm
Compute the transition probability matrix of a thinned periodically inhomogeneous Markov chain.tpm_thinned
Trigonometric Basis ExpansiontrigBasisExp
Viterbi algorithm for decoding statesviterbi
Viterbi algorithm for decoding states of inhomogeneous HMMsviterbi_g
Viterbi algorithm for decoding states of periodically inhomogeneous HMMsviterbi_p