View source: R/forward_algorithms.R
| forward_phsmm | R Documentation |
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. This function can be used to fit HSMMs where the state-duration distribution and/ or the conditional transition probabilities vary with covariates.
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 can be used to fit HSMMs where the state-duration distribution and/ or the conditional transition probabilities vary periodically.
In the special case of periodic variation (as compared to arbitrary covariate influence), this version is to be preferred over forward_ihsmm because it computes the correct periodically stationary distribution and no observations are lost for the approximation.
This function is designed to be used with automatic differentiation based on the R package RTMB. It will be very slow without it!
forward_phsmm(
dm,
omega,
allprobs,
tod,
trackID = NULL,
delta = NULL,
eps = 1e-10,
report = TRUE
)
dm |
list of length If the dwell-time PMFs are constant, the vectors are the PMF of the dwell-time distribution fixed in time. The vector lengths correspond to the approximating state aggregate sizes, hence there should be little probablity mass not covered by these. If the dwell-time PMFs are inhomogeneous, the matrices need to have L rows, where L is the cycle length. The number of columns again correpond to the size of the approximating state aggregates. |
omega |
matrix of dimension It contains the transition probabilities given the current state is left. Hence, the diagonal elements need to be zero and the rows need to sum to one. Such a matrix can be constructed using |
allprobs |
matrix of state-dependent probabilities/ density values of dimension |
tod |
(Integer valued) variable for cycle indexing in 1, ..., L, mapping the data index to a generalised time of day (length |
trackID |
optional vector of length If provided, the total log-likelihood will be the sum of each track's likelihood contribution.
Instead of a single vector |
delta |
Optional vector of initial state probabilities of length |
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 |
Calculates the (approximate) log-likelihood of a sequence of observations under a periodically inhomogeneous hidden semi-Markov model using a modified forward algorithm.
HSMM log-likelihood for given data and parameters
Koslik, J. O. (2025). Hidden semi-Markov models with inhomogeneous state dwell-time distributions. Computational Statistics & Data Analysis, 209, 108171.
Other forward algorithms:
forward(),
forward_g(),
forward_hsmm(),
forward_ihsmm(),
forward_p()
# currently no examples
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.