LaMa2.0.6 package

Fast Numerical Maximum Likelihood Estimation for Latent Markov Models

calc_trackInd

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

cosinor

Evaluate trigonometric basis expansion

ddwell

State dwell-time distributions of periodically inhomogeneous Markov ch...

dgmrf2

Reparametrised multivariate Gaussian distribution

dirichlet

Dirichlet 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

gdeterminant

Computes generalised determinant

generator

Build the generator matrix of a continuous-time Markov chain

grapes-sp-grapes

Sparsity-retaining matrix multiplication

LaMa-package

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

logLik.qremlModel

Extract log-likelihood from qremlModel object

make_matrices_dens

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

make_matrices_old

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

make_matrices

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

minmax

AD-compatible minimum and maximum functions

minmax0_smooth

Smooth approximations to max(x, 0) and min(x, 0)

penalty_uni

Penalty approximation of unimodality constraints for univariates smoot...

penalty

Computes penalty based on quadratic form

penalty2

Computes generalised quadratic-form penalties

plot.LaMaResiduals

Plot pseudo-residuals

pred_matrix

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

predict.LaMa_matrices

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

process_hid_formulas

Process and standardise formulas for the state process of hidden Marko...

pseudo_res_discrete

Calculate pseudo-residuals for discrete-valued observations

pseudo_res

Calculate pseudo-residuals

qreml_old

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

qreml

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

sdreport_outer

Report uncertainty of the estimated smoothing parameters or variances

sdreportMC

Monte Carlo version of sdreport

skewnorm

Skew normal distribution

smooth_dens_construct

Build the design and penalty matrices for smooth density estimation

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

Periodically stationary distribution of a periodically inhomogeneous M...

stationary_sparse

Sparse version of stationary

stationary

Compute the stationary distribution of a homogeneous Markov chain

summary.qremlModel

Summary method for qremlModel objects

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_g2

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

wrpcauchy

wrapped Cauchy distribution

zero_inflate

Zero-inflated density constructer

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.