Package: LaMa 2.0.2

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.

Authors:Jan-Ole Koslik [aut, cre]

LaMa_2.0.2.tar.gz
LaMa_2.0.2.zip(r-4.5)LaMa_2.0.2.zip(r-4.4)LaMa_2.0.2.zip(r-4.3)
LaMa_2.0.2.tgz(r-4.4-x86_64)LaMa_2.0.2.tgz(r-4.4-arm64)LaMa_2.0.2.tgz(r-4.3-x86_64)LaMa_2.0.2.tgz(r-4.3-arm64)
LaMa_2.0.2.tar.gz(r-4.5-noble)LaMa_2.0.2.tar.gz(r-4.4-noble)
LaMa_2.0.2.tgz(r-4.4-emscripten)LaMa_2.0.2.tgz(r-4.3-emscripten)
LaMa.pdf |LaMa.html
LaMa/json (API)

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

Peer review:

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

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
Datasets:
  • nessi - Loch Ness Monster Acceleration Data
  • trex - T-Rex Movement Data

On CRAN:

7.59 score 7 stars 35 scripts 244 downloads 51 exports 14 dependencies

Last updated 9 hours agofrom:8e995e2fdf. Checks:OK: 9. Indexed: yes.

TargetResultDate
Doc / VignettesOKNov 21 2024
R-4.5-win-x86_64OKNov 21 2024
R-4.5-linux-x86_64OKNov 21 2024
R-4.4-win-x86_64OKNov 21 2024
R-4.4-mac-x86_64OKNov 21 2024
R-4.4-mac-aarch64OKNov 21 2024
R-4.3-win-x86_64OKNov 21 2024
R-4.3-mac-x86_64OKNov 21 2024
R-4.3-mac-aarch64OKNov 21 2024

Exports:buildSmoothDenscalc_trackInddgamma2dgmrf2dvmforwardforward_gforward_hsmmforward_ihsmmforward_pforward_phsmmforward_sforward_spgeneratormake_matricesmake_matrices_denspenaltypgamma2pred_matrixpseudo_respseudo_res_discretepvmqgamma2qremlrgamma2rvmsdreportMCstateprobsstateprobs_gstateprobs_pstationarystationary_contstationary_pstationary_p_sparsestationary_sparsetpmtpm_conttpm_embtpm_emb_gtpm_gtpm_hsmmtpm_hsmm2tpm_ihsmmtpm_ptpm_phsmmtpm_phsmm2tpm_thinnedtrigBasisExpviterbiviterbi_gviterbi_p

Dependencies:bootCircStatscircularlatticeMASSMatrixmgcvmvtnormnlmeRcppRcppArmadilloRcppEigenRTMBTMB

Continuous-time HMMs

Rendered fromContinuous_time_HMMs.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-10-30
Started: 2024-02-26

Hidden semi-Markov models

Rendered fromHSMMs.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-11-07
Started: 2024-02-23

Inhomogeneous HMMs

Rendered fromInhomogeneous_HMMs.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-10-30
Started: 2024-04-02

Introduction to LaMa

Rendered fromIntro_to_LaMa.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-11-12
Started: 2024-04-02

LaMa and RTMB

Rendered fromLaMa_and_RTMB.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-11-12
Started: 2024-08-06

Longitudinal data

Rendered fromLongitudinal_data.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-11-07
Started: 2024-04-23

Markov-modulated (marked) Poisson processes

Rendered fromMMMPPs.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-10-30
Started: 2024-02-23

Penalised splines

Rendered fromPenalised_splines.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-11-21
Started: 2024-10-30

Periodic HMMs

Rendered fromPeriodic_HMMs.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-10-31
Started: 2024-10-31

State-space models

Rendered fromState_space_models.Rmdusingknitr::rmarkdownon Nov 21 2024.

Last update: 2024-11-18
Started: 2024-01-24

Readme and manuals

Help Manual

Help pageTopics
Build the design and penalty matrices for smooth density estimationbuildSmoothDens
Calculate the index of the first observation of each track based on an ID variablecalc_trackInd
Reparametrised multivariate Gaussian distributiondgmrf2
Forward algorithm with homogeneous transition probability matrixforward
General forward algorithm with time-varying transition probability matrixforward_g
Forward algorithm for homogeneous hidden semi-Markov modelsforward_hsmm
Forward algorithm for hidden semi-Markov models with inhomogeneous state durations and/ or conditional transition probabilitiesforward_ihsmm
Forward algorithm with for periodically varying transition probability matricesforward_p
Forward algorithm for hidden semi-Markov models with periodically inhomogeneous state durations and/ or conditional transition probabilitiesforward_phsmm
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
Reparametrised gamma distributiondgamma2 gamma2 pgamma2 qgamma2 rgamma2
Build the generator matrix of a continuous-time Markov chaingenerator
Build the design matrix and the penalty matrix for models involving penalised splines based on a formula and a data setmake_matrices
Build a standardised P-Spline design matrix and the associated P-Spline penalty matrixmake_matrices_dens
Loch Ness Monster Acceleration Datanessi
Computes penalty based on quadratic formpenalty
Build the prediction design matrix based on new data and model_matrices object created by 'make_matrices'pred_matrix
Calculate pseudo-residualspseudo_res
Calculate pseudo-residuals for discrete-valued observationspseudo_res_discrete
Quasi restricted maximum likelihood (qREML) algorithm for models with penalised splines or simple i.i.d. random effectsqreml
Monte Carlo version of 'sdreport'sdreportMC
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 stationary distribution of a continuous-time Markov chainstationary_cont
Compute the periodically stationary distribution of a periodically inhomogeneous Markov chainstationary_p
Sparse version of 'stationary_p'stationary_p_sparse
Sparse version of 'stationary'stationary_sparse
Build the transition probability matrix from unconstrained parameter vectortpm
Calculate continuous time transition probabilitiestpm_cont
Build the embedded transition probability matrix of an HSMM from unconstrained parameter vectortpm_emb
Build all embedded transition probability matrices of an inhomogeneous HSMMtpm_emb_g
Build all transition probability matrices of an inhomogeneous HMMtpm_g
Builds the transition probability matrix of an HSMM-approximating HMMtpm_hsmm
Build the transition probability matrix of an HSMM-approximating HMMtpm_hsmm2
Builds all transition probability matrices of an inhomogeneous-HSMM-approximating HMMtpm_ihsmm
Build all transition probability matrices of a periodically inhomogeneous HMMtpm_p
Builds all transition probability matrices of an periodic-HSMM-approximating HMMtpm_phsmm
Build all transition probability matrices of an periodic-HSMM-approximating HMMtpm_phsmm2
Compute the transition probability matrix of a thinned periodically inhomogeneous Markov chain.tpm_thinned
T-Rex Movement Datatrex
Compute the design matrix for a trigonometric basis expansiontrigBasisExp
Viterbi algorithm for state decoding in homogeneous HMMsviterbi
Viterbi algorithm for state decoding in inhomogeneous HMMsviterbi_g
Viterbi algorithm for state decoding in periodically inhomogeneous HMMsviterbi_p
von Mises distributiondvm pvm rvm vm