LaMa2.0.2 package

Fast Numerical Maximum Likelihood Estimation for Latent Markov Models

buildSmoothDens

Build the design and penalty matrices for smooth density estimation

calc_trackInd

Calculate the index of the first observation of each track based on an...

dgmrf2

Reparametrised multivariate Gaussian distribution

forward_g

General [forward algorithm](https://www.taylorfrancis.com/books/mono/1...

forward_hsmm

[Forward algorithm](https://www.taylorfrancis.com/books/mono/10.1201/b...

forward_ihsmm

[Forward algorithm](https://www.taylorfrancis.com/books/mono/10.1201/b...

forward_p

[Forward algorithm](https://www.taylorfrancis.com/books/mono/10.1201/b...

forward_phsmm

[Forward algorithm](https://www.taylorfrancis.com/books/mono/10.1201/b...

forward_s

[Forward algorithm](https://www.taylorfrancis.com/books/mono/10.1201/b...

forward_sp

[Forward algorithm](https://www.taylorfrancis.com/books/mono/10.1201/b...

forward

[Forward algorithm](https://www.taylorfrancis.com/books/mono/10.1201/b...

gamma2

Reparametrised gamma distribution

generator

Build the generator matrix of a continuous-time Markov chain

LaMa-package

LaMa: Fast Numerical Maximum Likelihood Estimation for Latent Markov M...

make_matrices_dens

Build a standardised P-Spline design matrix and the associated P-Splin...

make_matrices

Build the design matrix and the penalty matrix for models involving pe...

penalty

Computes penalty based on quadratic form

pred_matrix

Build the prediction design matrix based on new data and model_matrice...

pseudo_res_discrete

Calculate pseudo-residuals for discrete-valued observations

pseudo_res

Calculate pseudo-residuals

qreml

Quasi restricted maximum likelihood (qREML) algorithm for models with ...

sdreportMC

Monte Carlo version of sdreport

stateprobs_g

Calculate conditional local state probabilities for inhomogeneous HMMs

stateprobs_p

Calculate conditional local state probabilities for periodically inhom...

stateprobs

Calculate conditional local state probabilities for homogeneous HMMs

stationary_cont

Compute the stationary distribution of a continuous-time Markov chain

stationary_p_sparse

Sparse version of stationary_p

stationary_p

Compute the periodically stationary distribution of a periodically inh...

stationary_sparse

Sparse version of stationary

stationary

Compute the stationary distribution of a homogeneous Markov chain

tpm_cont

Calculate continuous time transition probabilities

tpm_emb_g

Build all embedded transition probability matrices of an inhomogeneous...

tpm_emb

Build the embedded transition probability matrix of an HSMM from uncon...

tpm_g

Build all transition probability matrices of an inhomogeneous HMM

tpm_hsmm

Builds the transition probability matrix of an HSMM-approximating HMM

tpm_hsmm2

Build the transition probability matrix of an HSMM-approximating HMM

tpm_ihsmm

Builds all transition probability matrices of an inhomogeneous-HSMM-ap...

tpm_p

Build all transition probability matrices of a periodically inhomogene...

tpm_phsmm

Builds all transition probability matrices of an periodic-HSMM-approxi...

tpm_phsmm2

Build all transition probability matrices of an periodic-HSMM-approxim...

tpm_thinned

Compute the transition probability matrix of a thinned periodically in...

tpm

Build the transition probability matrix from unconstrained parameter v...

trigBasisExp

Compute the design matrix for a trigonometric basis expansion

viterbi_g

Viterbi algorithm for state decoding in inhomogeneous HMMs

viterbi_p

Viterbi algorithm for state decoding in periodically inhomogeneous HMM...

viterbi

Viterbi algorithm for state decoding in homogeneous HMMs

vm

von Mises distribution

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.