forward_hsmm {LaMa} | R Documentation |
Forward algorithm for homogeneous hidden semi-Markov models
Description
Calculates the (approximate) log-likelihood of a sequence of observations under a homogeneous hidden semi-Markov model using a modified forward algorithm.
Usage
forward_hsmm(
dm,
omega,
allprobs,
trackID = NULL,
delta = NULL,
eps = 1e-10,
report = TRUE
)
Arguments
dm |
list of length N containing vectors of dwell-time probability mass functions (PMFs) for each state. The vector lengths correspond to the approximating state aggregate sizes, hence there should be little probablity mass not covered by these. |
omega |
matrix of dimension c(N,N) of conditional transition probabilites, also called embedded transition probability matrix. Contains the transition probabilities given that the current state is left. Hence, the diagonal elements need to be zero and the rows need to sum to one. Can be constructed using |
allprobs |
matrix of state-dependent probabilities/ density values of dimension c(n, N) which will automatically be converted to the appropriate dimension. |
trackID |
optional vector of length n containing IDs If provided, the total log-likelihood will be the sum of each track's likelihood contribution.
In this case, |
delta |
optional vector of initial state probabilities of length N By default, the stationary distribution is computed (which is typically recommended). |
eps |
small value to avoid numerical issues in the approximating transition matrix construction. Usually, this should not be changed. |
report |
logical, indicating whether initial distribution, approximating transition probability matrix and |
Details
Hidden semi-Markov models (HSMMs) are a flexible extension of HMMs, where the state duration distribution is explicitly modelled by a distribution on the positive integers.
For direct numerical maximum likelhood estimation, HSMMs can be represented as HMMs on an enlarged state space (of size M
) and with structured transition probabilities.
This function is designed to be used with automatic differentiation based on the R
package RTMB
. It will be very slow without it!
Value
log-likelihood for given data and parameters
References
Langrock, R., & Zucchini, W. (2011). Hidden Markov models with arbitrary state dwell-time distributions. Computational Statistics & Data Analysis, 55(1), 715-724.
Koslik, J. O. (2025). Hidden semi-Markov models with inhomogeneous state dwell-time distributions. Computational Statistics & Data Analysis, 209, 108171.
See Also
Other forward algorithms:
forward()
,
forward_g()
,
forward_ihsmm()
,
forward_p()
,
forward_phsmm()
Examples
# currently no examples