betaFeedback

WorksMathematics

Hidden Semi-Markov Models for Fully Functional Time Series

Abstract

Functional time series have a wide range of practical applications to modeling complex datasets such as Electroencephalogram (EEG) and other biological signals. Often latent states are hidden within the data dictating how a system is behaving and changing over time. The Hidden Markov Model (HMM) is one common and highly applicable latent state space model where the hidden state sequence evolves as a Markov chain. While the HMM has had much success modeling discrete, multivariate, and fully functional time series, it is also restricted by the Markov property which causes hidden states to persist only at geometrically decaying rates. This work investigates the implementation of hidden semi-Markov models for modeling fully functional time series data. This allows for the hidden state sequence to persist in a given state for a data-driven sojourn time, which can be parametrized by a discrete distribution (e.g. negative binomial) or left non-parametric. For efficient fitting of such a model, the hidden semi-Markov chain is embedded into a larger state space Markov chain and classic methods like the Baum-Welch and Viterbi algorithms are applied. We furthermore consider functional time series in the general setting of Gaussian measures in locally convex topological vector spaces. This is applied to a time series of pediatric EEG signals collected via overnight polysomnography.

Introduction

The Hidden Markov Model (HMM) remains one of the most widely used tools for modelling sequential data. Its origins lie in the work of Leonard Baum and his colleagues [1, 2], which predates the formalization of the expectation-maximization (EM) algorithm [3, 4]. Originally developed for observations taking values in a finite alphabet, with early applications in speech recognition [5, 6, 7], the HMM has since been extended to multivariate elliptically symmetric [8] and skewed [9] emission distributions, to longitudinal data [10], to nonparametric emission densities [12] [11], and to functional data [13, 14]. Most recently, [15] extended the observation space of the HMM from Euclidean space to general locally convex topological vector spaces, in which each hidden state corresponds to a mean-shifted Gaussian measure. As there is no analogue of Lebesgue measure, and hence no probability density, in infinite-dimensional spaces, their Topological Hidden Markov Model (THMM) replaces the emission density with the Onsager–Machlup functional of the underlying Gaussian measure [16, 17]. This allows the analyst to select a Cameron–Martin space suited to the application at hand, and the THMM was shown to successfully cluster sample paths of Brownian motion with drift, fractional Brownian motion, and the Ornstein–Uhlenbeck process, as well as nonparametric curves such as the power spectral densities of electroencephalogram (EEG) signals.

For all of its flexibility in the observation space, the THMM inherits a structural restriction of the classic HMM in its hidden component. Since the hidden state sequence evolves as a homogeneous Markov chain with transition probabilities aija_{ij}, the number of consecutive time points that the chain spends in state jj, known as the dwell time or sojourn time djd_j, necessarily follows a geometric distribution,

dj(r)=P(dj=r)=ajjr−1(1−ajj),r=1,2,…(1)d_j(r) = \mathbb{P}(d_j = r) = a_{jj}^{r-1}(1-a_{jj}), \qquad r = 1,2,\ldots \tag*{(1)}

Consequently, regardless of the value of ajja_{jj}, the modal dwell time of every state is a single time step, and the probability of leaving a state does not depend on how long the chain has already occupied it [6, 18]. This memoryless behavior is unrealistic in many applications. The THMM was applied to overnight polysomnography data from pediatric patients, the Viterbi path switched between the awake and asleep states considerably more often than the sleep stages labeled by a sleep technician. [15] attributed this behavior to the geometric dwell-time assumption and identified hidden semi-Markov models as a natural remedy.

Hidden semi-Markov models (HSMMs) remove this restriction by modelling the dwell times explicitly. Upon entering state jj, the hidden process remains there for a duration drawn from an arbitrary distribution djd_j on the positive integers, after which it moves to a new state according to an embedded Markov chain with no self-transitions [5, 19, 20]. The HMM is recovered as the special case in which every dj(⋅)d_j(\cdot) is geometric. Originally proposed for speech recognition, HSMMs have since been applied to rainfall [21], financial returns [22], and animal movement [23], among many other areas; see [24] for a comprehensive review. Parameters are typically estimated via an EM algorithm adapted to the semi-Markov setting [25, 26], and implementations are available in R [27, 28]. This additional generality is not free, however. The forward–backward recursions of an HSMM must account for every possible duration, so the cost of evaluating the likelihood can grow quadratically in the length of the series in the worst case [25]. Furthermore, as state changes and state durations are modeled separately, the hidden process is no longer Markovian on the original time scale. This complicates the inclusion of covariates, forecasting, and the fitting of stationary models, and most implementations assume that the observed series begins, and possibly ends, at a state boundary.

An elegant alternative, proposed by [18] and building on earlier ideas of state aggregation [29, 30, 31, 32], is to partially embed the HSMM as an HMM on an enlarged state space. Each semi-Markov state jj is replaced by a state aggregate of mjm_j Markov substates that share a common emission distribution, and the transitions within and out of the aggregate are governed by the discrete hazard rates of the dwell-time probability mass function,

cj(r)=dj(r)1−Dj(r−1),r=1,…,mj,(2)c_j(r) = \frac{d_j(r)}{1-D_j(r-1)}, \qquad r=1,\ldots,m_j, \tag*{(2)}

where DjD_j denotes the cumulative distribution function of djd_j. The dwell-time distribution of the resulting HMM coincides with djd_j for durations of up to mjm_j time steps and has a geometric tail thereafter. Hence, the representation is exact for dwell-time distributions with finite support or with geometric tails, and it can be made arbitrarily accurate for all others by enlarging mjm_j. The expanded model has exactly as many parameters as the HSMM it represents, its likelihood can be evaluated in time linear in the length of the series, and, being an HMM, it inherits the full toolkit of HMM methodology—forward–backward recursions, Viterbi decoding, stationary initial distributions, and state prediction—without modification.

In this article, we unite these two lines of research and propose the Topological Hidden Semi-Markov Model (THSMM). As in the THMM, observations may take values in a general locally convex space, encompassing finite-dimensional data, functional data, and sample paths of stochastic processes among others. Each hidden state corresponds to a mean-shifted Gaussian measure, and emissions are evaluated through the Onsager–Machlup functional. Unlike the THMM, each hidden state is additionally endowed with its own dwell-time distribution. These may be drawn from parametric families such as the (shifted) Poisson, (shifted) negative binomial, or discretized Weibull distributions, or they may be left nonparametric, either on a finite support or with an unstructured start and a geometric tail in the spirit of [21]. The semi-Markov structure is implemented via the state-aggregate construction of [18].

A key feature of this construction is that the two extensions decouple cleanly. Since every substate in an aggregate shares the same Onsager–Machlup emission functional, the topological component of the model enters only through the emission terms, whereas the semi-Markov component enters only through the structured transition matrix. As a result, the posterior probability of occupying a given semi-Markov state is simply the sum of the posterior probabilities of its substates, and the state means are re-estimated by the same weighted criteria as in the THMM, with these aggregate posterior probabilities serving as the weights. The THMM is recovered when every dwell-time distribution is geometric, and the classic HSMM with Gaussian emissions sharing a common covariance matrix is recovered when the observation space is Rd\mathbb{R}^d.

To our knowledge, explicit modeling of state durations has received little attention outside of finite-dimensional observation spaces. Existing HMMs for functional data, such as [13, 14], do not model the state durations explicitly, while existing HSMM methodology, including Bayesian nonparametric variants [33], assumes emission distributions that admit densities with respect to Lebesgue or counting measure.

The THSMM fills this gap, allowing realistic sojourn behaviour to be modelled jointly with emissions living in infinite-dimensional spaces. We demonstrate the THSMM on simulated diffusion processes whose hidden states have non-geometric dwell times, and we revisit the pediatric obstructive sleep apnea polysomnography data of [15] to show how explicit dwell-time modelling affects the predicted sequence of sleep states.

The remainder of this article is organized as follows. § 2 outlines the general theory for using HSMMs with functional data. § 3 reviews [18] and proposes an EM framework for model fitting. § 4 explores various simulated data sets to give a comprehensive overview of the models capabilities. § 5 applies the THSMM to the identification of sleep states form pediatric EEG data. For pseudo code of algorithms and in depth derivations please reference Appendices A and § 9.

HSMM for functional data

In this section we define a HSMM that utilizes functional data (THSMM); even though this construction is quickly dissembled in the next section it is important to fully establish it. For an in depth study of the HSMM, extensions, and case studies, we refer the reader to [24].

Let O1,…,OTO_1,\ldots,O_T be a sequence of observations taking values in a locally convex topological vector space X\mathcal{X}, and let S1,…,STS_1,\ldots,S_T be an unobserved state sequence taking values in {1,…,N}\{1,\ldots,N\}. As in the THMM [15], the observations are assumed conditionally independent given the hidden states, and the conditional law of OtO_t given St=iS_t=i is a Gaussian measure on X\mathcal{X} with state-specific mean hih_i and a shared covariance structure. Unlike the THMM, the hidden process (St)(S_t) is not assumed to be a Markov chain on the original time scale; instead it is a semi-Markov chain whose dwell times are modelled explicitly, see Figure 1. We describe the hidden component in § 2.1, the emission component in § 2.2, and the resulting likelihood and its HMM representation in § 3.

Example of a semi-Markov process

Figure 1. An example of a semi-Markov process where the state process is determined by transition probability matrix Ω\Omega and stationary distribution π\pi and the duration of the stay is determined by di(r)d_i(r).

The Hidden Semi-Markov Chain

The hidden process is described by two components. The first is an embedded Markov chain governing which state is visited next, with transition probability matrix (tpm) Ω=(ωij)i,j=1N\Omega=(\omega_{ij})_{i,j=1}^{N},

ωij=P(St+1=j∣St=i),ωii=0,∑j≠iωij=1.(3)\omega_{ij}=\mathbb{P}(S_{t+1}=j\mid S_t=i),\qquad\omega_{ii}=0,\qquad\sum_{j\ne i}\omega_{ij}=1. \tag*{(3)}

That is, ωij\omega_{ij} is the probability of moving to state jj given that the process leaves state ii; self-transitions are excluded, since the time spent in a state is governed entirely by the second component. We assume Ω\Omega is irreducible and denote its stationary distribution by π\pi; i.e. π⊤Ω=π⊤\pi^\top\Omega= \pi^\top and π⊤1=1\pi^\top\mathbf{1} = 1. Note that πi\pi_i is the long-run proportion of visits to state ii, not the long-run proportion of time spent there; the two are related in Remark 2.

The second component is a collection of dwell-time (or sojourn) distributions. Let dj(r)=P(dwell time in state j=r)d_j(r) = \mathbb{P}(\text{dwell time in state }j = r), r∈Nr \in\mathbb{N}, denote the probability mass function of the dwell time in state jj, and Dj(r)=∑s=1rdj(s)D_j(r) = \sum_{s=1}^{r}d_j(s) its cumulative distribution function. Upon entering state ii, the process remains there for a random number of time steps rr with probability di(r)d_i(r) after which it moves to a new state j≠ij \ne i with probability ωij\omega_{ij}. We write

Dˉi(r)=P(Di≥r)=∑u≥rdi(u),ci(r)=P(Di=r∣Di≥r)=di(r)Dˉi(r),(4)\bar{D}_i(r) = \mathbb{P}(D_i \ge r) = \sum_{u \ge r}d_i(u), \qquad c_i(r) = \mathbb{P}(D_i = r \mid D_i \ge r) = \frac{d_i(r)}{\bar{D}_i(r)}, \tag*{(4)}

for the survival function and the discrete hazard rate of DiD_i, with the convention ci(r)=1c_i(r) = 1 whenever Dˉi(r)=0\bar{D}_i(r) = 0. The hazard ci(r)c_i(r) is the probability that a sojourn in state ii ends after exactly rr steps, given that it has lasted at least rr steps, in this sense it can be viewed as a sort of right censoring. Notice that this definition coincides with the quantity dj(r)/{1−Dj(r−1)}d_j(r)/\{1 - D_j(r - 1)\} of Equation (2). Dwell times of successive visits are independent of one another and of the embedded chain.

The dwell-time distributions may be drawn from any family on the positive integers. Those considered in this article—the geometric, (shifted) Poisson, (shifted) negative binomial, discretized Weibull, and nonparametric distributions with or without a geometric tail—are detailed in § 3. In the special case di(r)=(1−pi)r−1pid_i(r) = (1-p_i)^{r-1}p_i, the hazard ci(r)≡pic_i(r) \equiv p_i is constant, the process is memoryless, and (St)(S_t) is a homogeneous Markov chain with transition probabilities

aii=1−pi,aij=piωij(j≠i).(5)a_{ii} = 1 - p_i,\qquad a_{ij} = p_i\omega_{ij}\quad(j \ne i). \tag*{(5)}

Emissions via the Onsager–Machlup functional

The emission component is inherited unchanged from the THMM; we summarize it here and refer to [15] for details. Let γ\gamma be a centred Radon Gaussian measure on X\mathcal{X} with covariance operator RγR_{\gamma} and Cameron–Martin space H=H(γ)H = H(\gamma), equipped with norm ∣⋅∣H\lvert\cdot\rvert_H. Conditional on St=iS_t = i, the observation is modelled as

Ot=hi+Zt,Zt∼iidγ,hi∈H,(6)O_t = h_i + Z_t,\qquad Z_t \mathrel{\overset{\mathrm{iid}}{\sim}} \gamma,\qquad h_i \in H, \tag*{(6)}

so that each hidden state corresponds to a shift of the common Gaussian measure γ\gamma by a state mean hih_i in an appropriate Cameron–Martin space. Since X\mathcal{X} is in general infinite-dimensional, the law of OtO_t has no density with respect to a sigma-finite translation invariant measure (e.g. Lebesgue measure), and we instead use the Onsager–Machlup functional of γ\gamma as the emission function,

bi(Ot)=lim⁡ε→0γ(Vε+{Ot−hi})γ(Vε)=exp⁡(−12∥Πq{Ot−hi}∥H2),(7)b_i(O_t) = \lim_{\varepsilon\to0} \frac{\gamma\left(V_\varepsilon+ \{O_t-h_i\}\right)}{\gamma(V_\varepsilon)} = \exp\left(-\frac{1}{2}\left\lVert\Pi_q\{O_t-h_i\}\right\rVert_H^2\right), \tag*{(7)}

where Vε={x∈X:q(x)≤ε}V_\varepsilon= \{x \in\mathcal{X}:q(x) \le\varepsilon\} is the ε\varepsilon-ball of a seminorm qq on X\mathcal{X}, and Πq\Pi_q is the orthogonal projection in HH onto the orthogonal complement of {a∈H:q(a)=0}\{a \in H:q(a)=0\} [17 Corollary 4.7.8]. When qq is a norm, Πq\Pi_q is the identity and (7) reduces to bi(Ot)=exp⁡(−12∥Ot−hi∥H2)b_i(O_t) = \exp(-\frac{1}{2}\lVert O_t-h_i\rVert_H^2).

The choice of γ\gamma, and hence of HH, is left to the analyst. For example, when X=Rd\mathcal{X} = \mathbb{R}^d and γ=N(0,Σ)\gamma= \mathcal{N}(0,\Sigma), we have ∣h∣H2=h⊤Σ−1h\lvert h\rvert_H^2 = h^\top\Sigma^{-1}h and bib_i is, up to a constant, the Gaussian density with mean hih_i and common covariance Σ\Sigma. When γ\gamma is the Wiener measure on C0[0,1]C_0[0,1], H=W02,1[0,1]H = W_0^{2,1}[0,1] and

bi(Ot)=exp⁡(−12∫01∣O˙t(τ)−h˙i(τ)∣2 dτ).b_i(O_t) = \exp\left(-\frac{1}{2}\int_0^1\left\lvert\dot{O}_t(\tau)-\dot{h}_i(\tau)\right\rvert^2\,d\tau\right).

and analogous expressions are available for Brownian motion with drift, the Ornstein–Uhlenbeck process, and fractional Brownian motion [15] § 4.

Remark 1 (Why the Onsager–Machlup functional suffices) Fix ε>0\varepsilon> 0 and replace each emission density in the HSMM likelihood by the small-ball probability γ(Vε+{Ot−hst})\gamma(V_\varepsilon+\{O_t-h_{s_t}\}). Every time point contributes exactly one emission factor, regardless of how the sequence s1,…,sTs_1,\ldots,s_T is partitioned into sojourns, so dividing this small-ball likelihood by γ(Vε)T\gamma(V_\varepsilon)^T—a constant free of all model parameters—and letting ε→0\varepsilon\to0 term by term in the finite sum over state sequences yields the analogue of the likelihood in Equation (12) below, in which each emission is the Onsager–Machlup functional (7). Hence the justification of [15] carries over to the semi-Markov setting without modification: the semi-Markov structure alters only the weights placed on each state sequence, not the emission terms.

HMM Embedding

The work of [18] consider specially structured HMMs that capture — up to an approximation — the sojourn distribution component of a HSMM. Below we give a brief summary of the technique, the advantages and disadvantages associated, and an extension for the use of the Baum-Welch algorithm for parameter estimation as opposed to the numerical maximization approach used in the original work.

HMMs with Arbitrary State Dwell-Time Distributions

We begin by outlining the technique. Let the NN-state HSMM be represented by Ψ=(Ω,di(r),bi(xt))\Psi= (\Omega, d_i(r), b_i(x_t)), a state dependent process X1:TX_{1:T} with realizations x1:Tx_{1:T} and Markov chain S1:TS_{1:T} with realizations j∈{1,…,N}j \in\{1, \ldots, N\} prescribing to tpm Ω\Omega. For each state jj define the size of a state aggregate mi∈N>0m_i \in\mathbb{N}^{>0}, i=1,…,Ni = 1, \ldots, N with m0=0m_0 = 0. Consider the HMM with state dependent process X1:T⋆X^{\star}_{1:T}, Markov chain S1:T⋆S^{\star}_{1:T} with states {1,2,…,∑i=1Nmi}\{1, 2, \ldots, \sum_{i=1}^{N} m_i\}. Refer to the sets

Ik={n∣∑i=0k−1mi<n≤∑i=0kmi}I_k = \left\{n \mid\sum_{i=0}^{k-1} m_i < n \le\sum_{i=0}^{k} m_i\right\}

as state aggregates and define iˉk:=min⁡(Ik)\bar{i}_k := \min(I_k) and ik+:=max⁡(Ik)i_k^{+} := \max(I_k). The state aggregate IkI_k is the index set corresponding to HMM states associated with state kk of the HSMM. Assume that HMM states in aggregate IkI_k are associated with the same emission distribution bk(⋅)b_k(\cdot), that is

P(Xt⋆∣St⋆∈Ik)=P(Xt∣St=k).\mathbb{P}(X_t^{\star} \mid S_t^{\star} \in I_k) = \mathbb{P}(X_t \mid S_t = k).

Define the hazard rate function ck(r)c_k(r) by:

ck(r):={dk(r)1−Dk(r−1)for Dk(r−1)<1,1for Dk(r−1)=1.c_k(r) := \begin{cases} \frac{d_k(r)}{1-D_k(r-1)} & \text{for } D_k(r-1) < 1,\\ 1 & \text{for } D_k(r-1) = 1. \end{cases}

Where Dk(r)=∑s≤rdk(s)D_k(r) = \sum_{s \le r} d_k(s), and Dˉk(r)=1−Dk(r−1)=P(dwell≥r)\bar{D}_k(r) = 1-D_k(r-1) = P(\text{dwell} \ge r) the censoring factor. The hazard rate is how the sojourn distribution is embedded in the HMM construction.

Denote the HMM tpm by Γ\Gamma and construct it as follows. Build a N×NN \times N block matrix (8) whose (i,j)(i,j)th block is size mi×mjm_i \times m_j. We populate the blocks (9) and (10) using the hazard rates in such a way that the sojourn distribution is exactly embedded in the HMMs Markov chain up to a duration less than or equal to its respective aggregate size.

Γ=[Γ11⋯Γ1m⋮⋱⋮Γm1⋯Γmm](8)\Gamma= \begin{bmatrix} \Gamma_{11} & \cdots& \Gamma_{1m} \\ \vdots& \ddots& \vdots\\ \Gamma_{m1} & \cdots& \Gamma_{mm} \end{bmatrix} \tag*{(8)}

The mi×mim_i \times m_i diagonal block Γii\Gamma_{ii}, i=1,…,mi=1,\ldots,m are defined, for mi≥2m_i \ge2, as

Γii=[01−ci(1)0⋯0001−ci(2)0⋯00⋱⋯001−ci(r)00⋱001−ci(mi−1)01−ci(mi)](9)\Gamma_{ii} = \begin{bmatrix} 0 & 1-c_i(1) & 0 & \cdots& 0 \\ 0 & 0 & 1-c_i(2) & 0 & \cdots& 0 \\ 0 & & \ddots& & \cdots& 0 \\ 0 & & & 1-c_i(r) & & 0 \\ 0 & & & & \ddots& 0 \\ 0 & & & & & 1-c_i(m_i-1) \\ 0 & & & & & 1-c_i(m_i) \end{bmatrix} \tag*{(9)}

where the entries 1−ci(1)1-c_i(1) to 1−ci(mi−1)1-c_i(m_i-1) are along the super diagonal. The mi×mjm_i \times m_j off diagonal blocks Γij\Gamma_{ij} are defined as

Γij=[ci(1)ωij0⋯0ci(2)ωij0⋯0⋮⋮⋮ci(mi)ωij0⋯0].(10)\Gamma_{ij} = \begin{bmatrix} c_i(1)\omega_{ij} & 0 & \cdots& 0 \\ c_i(2)\omega_{ij} & 0 & \cdots& 0 \\ \vdots& \vdots& & \vdots\\ c_i(m_i)\omega_{ij} & 0 & \cdots& 0 \end{bmatrix}. \tag*{(10)}

There are two important consequences of this construction. Firstly the state transitions between aggregates in the HMM align with the state transitions in the HSMM. Specifically, for i≠ji \ne j, 1≤i,j≤N1 \le i,j \le N, P(St+1∗∈Ij∣St∗∈Ii,St+1∗∉Ii)=P(St+1=j∣St=i,St+1≠i)\mathbb{P}(S^*_{t+1} \in I_j \mid S^*_t \in I_i, S^*_{t+1} \notin I_i) = \mathbb{P}(S_{t+1}=j \mid S_t=i, S_{t+1} \ne i). Furthermore, the duration with state aggregate kk corresponds to the sojourn distribution for state kk up to a duration mim_i and has geometric decay thereafter. That is, for any k∈{1,…,N}k \in\{1,\ldots,N\}

dk∗(r)={dk(r)for r≤mi,dk(mk)(1−ck(mk))r−mkfor r>mk.d_k^*(r) = \begin{cases} d_k(r) & \text{for } r \le m_i, \\ d_k(m_k)(1-c_k(m_k))^{r-m_k} & \text{for } r > m_k. \end{cases}

The geometric decay is a direct consequence of Markov chain behavior. One can see that the difference between dk∗d_k^* and dkd_k can be made arbitrarily small by choosing mim_i sufficiently large. Also, any sojourn distribution with finite support can be exactly recreated by choosing mkm_k to be the maximum dwell time in state kk having a non-zero probability.

Let Θ:=(Ω,d1,…,dN,h1,…,hN,δ)\Theta:= (\Omega, d_1, \ldots, d_N, h_1, \ldots, h_N, \delta) be the collection of model parameters. A state sequence s=(s1,…,sT)s = (s_1, \ldots, s_T) may be written uniquely as a sequence of MM sojourns (j1,r1),…,(jM,rM)(j_1,r_1),\ldots,(j_M,r_M), where jmj_m is the state visited in the mm-th sojourn, rmr_m its length, jm+1≠jmj_{m+1} \ne j_m, and r1+⋯+rM=Tr_1+\cdots+r_M=T. If the series is assumed to begin at the start of a sojourn, with P(S1=i)=δi\mathbb{P}(S_1=i)=\delta_i, the probability of ss is

P(s)=δj1{∏m=1M−1djm(rm)ωjmjm+1}D‾jM(rM),(11)\mathbb{P}(s)=\delta_{j_1}\left\{\prod_{m=1}^{M-1}d_{j_m}(r_m)\omega_{j_mj_{m+1}}\right\}\overline{D}_{j_M}(r_M), \tag*{(11)}

where the survival function in the final factor accounts for the last sojourn being right-censored at time TT. The log likelihood of the THSMM is then

l(Θ∣X1,…,T)=log⁡∑s∈{1,…,N}TP(s)∏t=1Tbst(Xt).(12)l(\Theta\mid X_{1,\ldots,T})=\log\sum_{s\in\{1,\ldots,N\}^{T}}\mathbb{P}(s)\prod_{t=1}^{T}b_{s_t}(X_t). \tag*{(12)}

Direct evaluation of (12) through the semi-Markov forward recursion requires summing over all possible sojourn lengths at each time step, at a cost that grows quadratically in TT in the worst case [25]. Moreover, (11) requires the series to begin at a sojourn boundary; relaxing this is awkward because (St)(S_t) is not Markov on the original time scale. Both issues are resolved by the state-aggregate representation.

Remark 2 (Stationarity) Let μi∗=∑r≥1rdi∗(r)\mu_i^*=\sum_{r\geq1}r d_i^*(r) denote the mean dwell time in aggregate IiI_i, and suppose ci(Ki)>0c_i(K_i)>0 for every ii. The stationary distribution δ∗\delta^* of Γ\Gamma is

δ(i,r)∗∝{πiD‾i(r),r<Ki,πiD‾i(Ki)/ci(Ki),r=Ki,\delta^*_{(i,r)} \propto\begin{cases} \pi_i\overline{D}_i(r), & r<K_i,\\ \pi_i\overline{D}_i(K_i)/c_i(K_i), & r=K_i, \end{cases}

normalized to sum to one. Summing over each aggregate, the stationary probability of hidden state ii is

P(St=i)=∑r=1Kiδ(i,r)∗=πiμi∗∑k=1Nπkμk∗,\mathbb{P}(S_t=i)=\sum_{r=1}^{K_i}\delta^*_{(i,r)}=\frac{\pi_i\mu_i^*}{\sum_{k=1}^{N}\pi_k\mu_k^*},

so that the long-run proportion of time spent in state ii is the proportion of visits to state ii under the embedded chain, reweighted by the mean dwell time of state ii.

The usefulness of such a construction is that by porting a HSMM into a HMM the user immediately gains access to a wide array of well established HMM theory. Of particular interest is that it greatly simplifies the likelihood of a HSMM and in turn the maximization of such a likelihood. One now has a greatly simplified modular framework that supports a wide range of sojourn distributions without the need for custom infrastructure. This is well demonstrated in [18] where a maximization of a HSMM over many different sojourn distributions can be done with a simple numerical maximization of the constructed HMM likelihood without the need for significant tailoring of the algorithm. One simply needs to build the hazard rate equations for any specific sojourn they wish to use.

The expanded state space does not increase the size of the parameter space as the HMM formulation of Γ\Gamma a deterministic function of Ω\Omega and the dwell parameters from the HSMM and therefore there are as many constrained parameters in both models. Computational slowdown in this expanded state space can be mitigated via sparse matrix computations (in C++ or in R using package TMB [34]) yielding speedups in runtime over the naive implementation.

Model Fitting Via Baum-Welch (EM algorithm):

Unlike in the original work of [18] we fit the HSMM (embedded into a HMM) via the Baum-Welch algorithm. This is for two reasons: the first being that direct numerical maximization of the parameters for a measure in an infinite dimensional space is often ill-posed whereas the M-step in Baum-Welch provides a closed form solution. Additionally, we can derive closed for updates for the hazard rates and in turn the tpm Ω\Omega, and weighted least square estimates (WLSE) for sojourn distributions. Throughout the optimization there is no need to construct Γ\Gamma circumventing the issue of doing computations with large matrices.

In the proceeding discussion we introduce the following notation to describe state transitions in Γ\Gamma. Define Γ((i,l)→(j,k))\Gamma((i,l) \to(j,k)) to be the probability of transitioning from the ll-th entry of state aggregate ii to the kk-th entry of state aggregate jj. There are only two such transitions, advance within a state aggregate ii with probability:

(j,s)→(j,s+),s+=min⁡(s+1,mj),probability 1−cj(s),(j,s) \to(j,s^{+}), \qquad s^{+} = \min(s+1,m_j), \qquad\text{probability } 1-c_j(s),

or advance to a new aggregate jj with probability

Γ((i,r)→(j,1))=ωi,jci(r),j≠i.\Gamma((i,r) \to(j,1)) = \omega_{i,j}c_i(r), \qquad j \ne i.

All remaining entries of Γ\Gamma being equal to zero. Note that we need the construction s+s^{+} to appropriately deal with the geometric tail of a state aggregate.

The forward (α\alpha) and backwards (β\beta) equations handle the expectation step of the Baum-Welch algorithm and are defined as follows:

αt(i,r)=P(x1:t,St=(i,r))βt(i,r)=P(xt+1:T∣St=(i,r))\begin{aligned} \alpha_t(i,r) &= \mathbb{P}(x_{1:t}, S_t=(i,r))\\ \beta_t(i,r) &= \mathbb{P}(x_{t+1:T}\mid S_t=(i,r)) \end{aligned}

Before calculating these probabilities it is useful to define the following:

Ft(i)=∑r=1miαt(i,r)ci(r),(13)F_t(i) = \sum_{r=1}^{m_i}\alpha_t(i,r)c_i(r), \tag*{(13)}
Gt(i)=∑i≠jωi,jbt+1(j,1)βt+1(j,1).(14)G_t(i) = \sum_{i\ne j}\omega_{i,j}b_{t+1}(j,1)\beta_{t+1}(j,1). \tag*{(14)}

Where Equation (13) can be seen as the total probability mass leaving aggregate ii at time tt weighted by the hazard and summed over the substates, and Equation (14) can be seen as the probability of all the data after time tt given that state ii ends at time tt. We then formulate the recursions for the α\alpha and β\beta passes as follows:

αt+1(j,l)=bt+1(j,l)[∑s:s+=lαt(j,s){1−cj(s)}+1{l=1}∑i≠jωi,jFt(i)](15)\alpha_{t+1}(j,l)=b_{t+1}(j,l)\left[\sum_{s:s+=l}\alpha_t(j,s)\{1-c_j(s)\}+1\{l=1\}\sum_{i\ne j}\omega_{i,j}F_t(i)\right] \tag*{(15)}
βt(i,r)={1−ci(r)}bt+1(i,r+)βt+1(i,r+)+ci(r)Gt(i).(16)\beta_t(i,r)=\{1-c_i(r)\}b_{t+1}(i,r^+)\beta_{t+1}(i,r^+)+c_i(r)G_t(i). \tag*{(16)}

Case by case we have the following situations for αt+1(j,l)\alpha_{t+1}(j,l):

αt+1(j,1)=bt+1(j,1)[∑i≠jωi,jFt(i)+1{mj=1}αt(j,1){1−cj(1)}],\alpha_{t+1}(j,1)=b_{t+1}(j,1)\left[\sum_{i\ne j}\omega_{i,j}F_t(i)+1\{m_j=1\}\alpha_t(j,1)\{1-c_j(1)\}\right],
αt+1(j,l)=bt+1(j,l)αt(j,l−1){1−cj(l−1)},2≤l<mj,\alpha_{t+1}(j,l)=b_{t+1}(j,l)\alpha_t(j,l-1)\{1-c_j(l-1)\},\qquad2\le l<m_j,
αt+1(j,mj)=bt+1(j,mj)[αt(j,mj−1){1−cj(mj−1)}+αt(j,mj){1−cj(mj)}],mj≥2.\alpha_{t+1}(j,m_j)=b_{t+1}(j,m_j)\left[\alpha_t(j,m_j-1)\{1-c_j(m_j-1)\}+\alpha_t(j,m_j)\{1-c_j(m_j)\}\right],\qquad m_j\ge2.

The first form of each pass handles the probability of advancing within a state aggregate and the second term handles the probability of leaving an aggregate. Using the Equations (15) and (16), we can iteratively produce the necessary posterior probabilities that act as weights in the maximization step.

To derive estimates for the hazard rates and the HSMM tpm entries we need to keep track of two things, how often the chain remained in a state and how often the chain left a state. We define the following counts:

ηi(r)=1P(x1:T)∑t=1T−1αt(i,r)βt(i,r),\eta_i(r)=\frac{1}{\mathbb{P}(x_{1:T})}\sum_{t=1}^{T-1}\alpha_t(i,r)\beta_t(i,r),
Δi(r)=ci(r)P(x1:T)∑t=1T−1αt(i,r)Gt(i),\Delta_i(r)=\frac{c_i(r)}{\mathbb{P}(x_{1:T})}\sum_{t=1}^{T-1}\alpha_t(i,r)G_t(i),
N(i,j)=1P(x1:T)∑t=1T−1ωi,jbt+1(j,1)βt+1(j,1)Ft(i).N(i,j)=\frac{1}{\mathbb{P}(x_{1:T})}\sum_{t=1}^{T-1}\omega_{i,j}b_{t+1}(j,1)\beta_{t+1}(j,1)F_t(i).

Where ηi(r)\eta_i(r) represents the number of visits to state (i,r)(i,r), Δi(r)\Delta_i(r) represents the number of departures from state ii that happened at duration rr, and N(i,j)N(i,j) the total number of jumps from state ii to state jj. In addition, let the smoothed posterior probabilities be

ιt(i,r)=αt(i,r)βt(i,r)P(x1:T) and ιt(i)=∑r=1miιt(i,r)=P(St∈i∣x1:T)[1].\iota_t(i,r)=\frac{\alpha_t(i,r)\beta_t(i,r)}{\mathbb{P}(x_{1:T})}\text{ and }\iota_t(i)=\sum_{r=1}^{m_i}\iota_t(i,r)=\mathbb{P}(S_t\in i\mid x_{1:T})[^1].

Denote the full log likelihood of the HMM by log⁡P(S,x)\log P(S,x):

log⁡P(S,x)=∑i∑r1[S1=(i,r)]log⁡δ(i,r)+∑i∑j≠i[∑t=1T−1∑r1[St=(i,r),St+1=(j,1)]]log⁡ω(i,j)+∑i∑r=1mi{[∑t=1T−1∑j≠i1[St=(i,r),St+1=(j,1)]]log⁡ci(r)+[∑t=1T−11[St=(i,r),stay]]log⁡(1−ci(r))}+∑i∑t=1T[∑r1[St=(i,r)]]log⁡f(xt;θi)\begin{aligned} \log P(S,x)={}&\sum_i\sum_r \mathbf{1}[S_1=(i,r)]\log\delta(i,r)\\ &+\sum_i\sum_{j\ne i}\left[\sum_{t=1}^{T-1}\sum_r\mathbf{1}[S_t=(i,r),S_{t+1}=(j,1)]\right]\log\omega(i,j)\\ &+\sum_i\sum_{r=1}^{m_i}\left\{\left[\sum_{t=1}^{T-1}\sum_{j\ne i}\mathbf{1}[S_t=(i,r),S_{t+1}=(j,1)]\right]\log c_i(r)\right.\\ &\qquad\left.+\left[\sum_{t=1}^{T-1}\mathbf{1}[S_t=(i,r),\mathrm{stay}]\right]\log(1-c_i(r))\right\}\\ &+\sum_i\sum_{t=1}^{T}\left[\sum_r\mathbf{1}[S_t=(i,r)]\right]\log f(x_t;\theta_i) \end{aligned}

We then define QQ as the expected value of the log likelihood Q(Θ∣Θ(k))=EΘ(k)[log⁡P(S,x;Θ)∣x1:T]Q(\Theta\mid\Theta^{(k)})=\mathbb{E}_{\Theta^{(k)}}[\log P(S,x;\Theta)\mid x_{1:T}]:

Q=∑i∑rι1(i,r)log⁡δ(i,r)+∑i∑j≠iN(i,j)log⁡ω(i,j)+∑i∑r=1mi[Δi(r)log⁡ci(r)+(ηi(r)−Δi(r))log⁡(1−ci(r))]+∑i∑t=1Tιt(i)log⁡b(xt;θi)\begin{aligned} Q={}&\sum_i\sum_r\iota_1(i,r)\log\delta(i,r) +\sum_i\sum_{j\ne i}N(i,j)\log\omega(i,j)\\ &+\sum_i\sum_{r=1}^{m_i}\left[\Delta_i(r)\log c_i(r)+(\eta_i(r)-\Delta_i(r))\log(1-c_i(r))\right]\\ &+\sum_i\sum_{t=1}^{T}\iota_t(i)\log b(x_t;\theta_i) \end{aligned}

Estimates are then found by maximizing the specific summand of QQ corresponding to those respective parameters and any constraints surrounding them.

HSMM transition probabilities ωi,j\omega_{i,j} are updated by maximizing QωQ_\omega subject to the constraint ∑j≠iωi,j=1\sum_{j\ne i}\omega_{i,j}=1 and are calculated as follows:

ω^i,j=N(i,j)∑l≠iN(i,l).(17)\hat{\omega}_{i,j}=\frac{N(i,j)}{\sum_{l\ne i}N(i,l)}. \tag*{(17)}

One can then either find the stationary distribution of the HSMM or update the initial distribution for the HMM via the EM. Assuming the initial distribution puts mass only on the first substate of each state, that is δ(i,1)=δi\delta(i,1)=\delta_i and δ(i,r)=0\delta(i,r)=0 for r>1r > 1, we can rewrite QinitQ_{init} as:

Qinit=∑iι1(i,1)log⁡(δi).Q_{init} = \sum_i \iota_1(i,1)\log(\delta_i).

Which can be maximized subject to the constrain that ∑iδi=1\sum_i \delta_i = 1, yielding:

δ^i=ι1(i,1)=α1(i,1)β1(i,1)/P(x1:T)\hat{\delta}_i = \iota_1(i,1) = \alpha_1(i,1)\beta_1(i,1)/\mathbb{P}(x_{1:T})

Emission functions are updated the same as in [15] and we refer to the reader there for a detailed summary of derivations. A condensed update schema can be found in B for each functional emission satisfying:

θ^i=arg⁡max⁡θ∑t=1Tνt(i)log⁡f(xt;θ).\hat{\theta}_i = \underset{\theta}{\arg\max}\sum_{t=1}^{T}\nu_t(i)\log f(x_t;\theta).

The final component is to maximize the sojourn parameters. Recall the component of QQ that corresponds to sojourn distributions:

Qdwell=∑i∑r=1mi[Δi(r)log⁡ci(r)+(ηi(r)−Δi(r))log⁡(1−ci(r))].Q_{dwell} = \sum_i\sum_{r=1}^{m_i}\left[\Delta_i(r)\log c_i(r)+\left(\eta_i(r)-\Delta_i(r)\right)\log\left(1-c_i(r)\right)\right].

At each duration rr there are ηi(r)\eta_i(r) “trials” and di(r)d_i(r) “successes” with the probability of success (a departure) being ci(r)c_i(r). In this view this is the log likelihood of a Binomial distribution. We can then develop update equations for families of sojourn distributions.

Non-Parametric (NP) Sojourn Distribution Updates: Each ci(r)c_i(r) is a free parameter that can be maximized individually. We start by finding the hazard rate update:

c^i(r)=Δi(r)/ηi(r),\hat{c}_i(r)=\Delta_i(r)/\eta_i(r),

then convert back to probabilities:

p^i(r)=c^i(r)∏s<r(1−c^i(s)).(18)\hat{p}_i(r)=\hat{c}_i(r)\prod_{s<r}\left(1-\hat{c}_i(s)\right). \tag*{(18)}

When the NP sojourn has no tail, the process must leave the state at or before duration mim_i. Thus,

ci(mi)=1⇒c^i(mi)=1,c_i(m_i)=1\Rightarrow\hat{c}_i(m_i)=1,

yielding the desired property of no tail. When the NP sojourn has a tail, the decay of staying within the state is a geometric distribution, and we have:

c^i(mi)=Δi(mi)/ηi(mi).\hat{c}_i(m_i)=\Delta_i(m_i)/\eta_i(m_i).

If ci(r)=0c_i(r)=0, then the Markov chain has an absorbing state in aggregate ii duration r+1r+1. For numerical stability, it is best to initialize the parameters away form zero as the EM algorithm will not be able to move it.

Geometric Sojourn Distribution Updates: A single hazard ci(r)=pic_i(r)=p_i governs the probabilities of transitions. Thus we have:

c^i(r)=∑rΔi(r)∑rηi(r).(19)\hat{c}_i(r)=\frac{\sum_r \Delta_i(r)}{\sum_r \eta_i(r)}. \tag*{(19)}

Parametric Sojourn Distribution Updates: Here we encompass various families such as Poisson, Negative Binomial, and Weibull. In the case of a sojourn distribution that follows one of the preceding distributions, the hazard rate is a curve ci(r)=h(r;ϕi)c_i(r)=h(r;\phi_i) or hr,ih_{r,i} for short parameterized by a vector ϕi\phi_i. This QdwellQ_{dwell} becomes:

Qdwell=∑i∑r=1mi[Δi(r)log⁡h(r;ϕi)+(ηi(r)−Δi(r))log⁡(1−h(r;ϕi))].Q_{dwell}=\sum_i\sum_{r=1}^{m_i}\left[\Delta_i(r)\log h(r;\phi_i)+\left(\eta_i(r)-\Delta_i(r)\right)\log\left(1-h(r;\phi_i)\right)\right].

We can now update each ϕi\phi_i via Iteratively Reweighted Least Squares (IRLS). Differentiating a single term of Qdwell,iQ_{dwell,i} with respect to ϕi\phi_i gives:

ddϕiQdwell,i=[Δi(r)hr,i+ηi(r)−Δi(r)1−hr,i]h˙r,i,\frac{d}{d\phi_i}Q_{dwell,i}=\left[\frac{\Delta_i(r)}{h_{r,i}}+\frac{\eta_i(r)-\Delta_i(r)}{1-h_{r,i}}\right]\dot{h}_{r,i},

and summing over rr gives the score:

U(ϕi)=∑r=1miΔi(r)−ηi(r)hr,ihr,i(1−hr,i)h˙r,i.U(\phi_i)=\sum_{r=1}^{m_i}\frac{\Delta_i(r)-\eta_i(r)h_{r,i}}{h_{r,i}(1-h_{r,i})}\dot{h}_{r,i}.

Using the reasoning above and treating Δi(r)\Delta_i(r) as a Binomial(n=ηi(r),p=ci(r)n=\eta_i(r),p=c_i(r)), we can compute the Hessian and the resulting Fisher information as follows.

d2dϕ2Qdwell,i=[−drhr,i2−ηi−Δi(1−hr,i)2]h˙r,ih˙r,iT+[drhr,i−ηi−Δi1−hr,i]h¨r,i.\frac{d^2}{d\phi^2}Q_{dwell,i}=\left[-\frac{d_r}{h_{r,i}^2}-\frac{\eta_i-\Delta_i}{(1-h_{r,i})^2}\right]\dot{h}_{r,i}\dot{h}_{r,i}^{T}+\left[\frac{d_r}{h_{r,i}}-\frac{\eta_i-\Delta_i}{1-h_{r,i}}\right]\ddot{h}_{r,i}.

Summing over rr yields the Hessian:

H(ϕi)={∑r=1mi[−drhr,i2−ηi−Δi(1−hr,i)2]h˙r,ih˙r,iT+[drhr,i−ηi−Δi1−hr,i]h¨r,i}.H(\phi_i)=\left\{\sum_{r=1}^{m_i}\left[-\frac{d_r}{h_{r,i}^2}-\frac{\eta_i-\Delta_i}{(1-h_{r,i})^2}\right]\dot{h}_{r,i}\dot{h}_{r,i}^{T}+\left[\frac{d_r}{h_{r,i}}-\frac{\eta_i-\Delta_i}{1-h_{r,i}}\right]\ddot{h}_{r,i}\right\}.

Finally the Fisher information matrix is:

I(ϕi)=−E[H(ϕi)]=∑r=1miηr(r)hr,i(1−hr,i)h˙r,ih˙r,iT.\mathcal{I}(\phi_i)=-\mathbb{E}[H(\phi_i)]=\sum_{r=1}^{m_i}\frac{\eta_r(r)}{h_{r,i}(1-h_{r,i})}\dot{h}_{r,i}\dot{h}_{r,i}^{T}.

Writing wr=ηi(r)/{hr,i(1−hr,i)}≥0w_r=\eta_i(r)/\{h_{r,i}(1-h_{r,i})\}\ge0, the Fisher information is I(ϕi)=∑rwrh˙r,ih˙r,iT\mathcal{I}(\phi_i)=\sum_r w_r\dot{h}_{r,i}\dot{h}_{r,i}^{T}, a nonnegative combination of rank-one positive semi-definite matrices.

Hence v⊤I(ϕi)v=∑rwr(h˙r,i⊤v)2≥0v^{\top}\mathcal{I}(\phi_i)v=\sum_r w_r(\dot{h}_{r,i}^{\top}v)^2\ge0, so I(ϕi)\mathcal{I}(\phi_i) is positive semi-definite. It is positive definite, and therefore invertible, if and only if the gradients {h˙r,i:wr>0}\{\dot{h}_{r,i}:w_r>0\} span the parameter space; this requires at least dim⁡ϕi\dim\phi_i durations with ηi(r)>0\eta_i(r)>0 and 0<hr,i<10<h_{r,i}<1. In that case Δ=I(ϕi)−1U(ϕi)\Delta=\mathcal{I}(\phi_i)^{-1}U(\phi_i) is an ascent direction for Qdwell,iQ_{\mathrm{dwell},i}, since U⊤Δ=U⊤I−1U>0U^{\top}\Delta=U^{\top}\mathcal{I}^{-1}U>0 whenever U≠0U\ne0. In practice a small ridge, I+ϵI\mathcal{I}+\epsilon I, guards against near-singularity. The IRLS update for ϕi\phi_i is then:

ϕi(k+1)=ϕi(k)+I(ϕi(k))−1U(ϕi(k))(20)\phi_i^{(k+1)}=\phi_i^{(k)}+\mathcal{I}(\phi_i^{(k)})^{-1}U(\phi_i^{(k)}) \tag*{(20)}

The above equations entail all the necessary components for THSMM model fitting via the Baum-Welch algorithm. For details please refer to Appendix A. For pseudo-code of the implementation please refer to B.

Remark 3 (IRLS and EM guarantee) [3] show that the observed-data log-likelihood satisfies ℓ(θ)−ℓ(θ(t))≥Q(θ∣θ(t))−Q(θ(t)∣θ(t))\ell(\theta)-\ell(\theta^{(t)})\ge Q(\theta\mid\theta^{(t)})-Q(\theta^{(t)}\mid\theta^{(t)}), so, any update that does not decrease QQ also does not decrease ℓ\ell. This motivates the generalized EM (GEM) algorithm, which relaxes the M step from fully maximizing QQ to merely increasing it. IRLS, initialized at the current estimate θ(t)\theta^{(t)}, satisfies this condition provided each step increases QQ; this holds when QQ is concave in the regression parameters (e.g., under a canonical link) or can be enforced by step-halving. Hence IRLS need not be run to convergence, and even a single safeguarded step yields a valid GEM iteration.

Simulation Experiments

In the following sections we stress test the THSMM in a variety of settings. To focus on comparability and keep results concise we keep our attention to emission distributions of nonparametric L2L^2 mean curves with various sojourn distributions. Further simulations can be found in the repository where we extensively test homogeneous mixtures of Brownian motion with linear drift, the Ornstein-Uhlenbeck process, and fractional Brownian motion with linear drift where the hidden process is a semi-Markov process. These simulations confirm that imposing the geometric distribution on the THSMM semi-Markov sojourn does computationally agree with the model fitted by the THMM—via the funHMM CRAN package—as expected mathematically. They also demonstrate how the THSMM can outperform other models when the sojourn distribution is correctly specified or left as nonparametric.

For each scenario we perform 50 replications. Each replicate has its own seed for data generation reproducibility. To evaluate model performance, we analyze overall performance accuracy and quality of parameter recovery. For performance accuracy, we use the adjusted Rand index (ARI) as our performance metric. The ARI is a popular method of measuring the agreement between two sets of labels and is computed in R via the adjustedRandIndex() function in the mclust package [35]. An ARI value of 1 indicates a perfect match whereas an ARI value of 0 indicates random guessing. We secondly compare clustering accuracy using cross entropy as an alternative measurement. To assess the parameter recovery, we calculate bias, standard deviation, and root mean squared error (RMSE), of fitted values from the 50 replications. Note that this is not a bootstrapped estimate as a fresh synthetic data set is generated from the same set of base parameters for each replicate. We point the reader to the repository for code to build and fit a THSMM as well as further simulations (repository link).

Data Generation Procedures

Each dataset has three states and transitions are uniform across states (jump from state ii to j≠ij \ne i with probability 1/21/2 for i,j∈{1,2,3}i,j \in\{1,2,3\}). Given its hidden state jj, each observation is a curve on 100 equispaced points of [0,1][0,1] of the form

O(τ)=hj(τ)+∑m=116ξm2sin⁡(mπτ)mπ,ξm∼iidN(0,0.42),O(\tau) = h_j(\tau) + \sum_{m=1}^{16} \xi_m \frac{\sqrt{2}\sin(m\pi\tau)}{m\pi}, \qquad\xi_m \overset{\mathrm{iid}}{\sim} N(0,0.4^2),

so that the noise is a smooth Brownian bridge truncated to 16 terms of its Karhunen–Loève expansion and is the same for every state. The state mean curves are h1(τ)=asin⁡(2πτ)h_1(\tau)=a\sin(2\pi\tau), h2(τ)=a(2τ−1)h_2(\tau)=a(2\tau-1) and h3(τ)=a{cos⁡(2πτ)+1}h_3(\tau)=a\{\cos(2\pi\tau)+1\}, where a=0.15a=0.15, 0.20.2 and 0.30.3 give low, medium and high separation between the states. Each of the proceeding sections then modifies the sojourn distributions for each state in order to better test the question at hand. For Sections 4.1 and 4.2 use a homogeneous mixture of sojourns and in Section 4.3 we also consider a heterogeneous mixture of sojourns where each state has its own unique distribution. See Figure 2 for an example of a synthetic data set where we used geometric sojourn distributions with low separation between observations within states.

Figure 2. Synthetic non parametric L2L^2 curves generated with low separation.

Remark 4 (Mixtures of Sojourn Distributions) The current implementation of THSMM supports the choice of a unique sojourn distribution for each state; e.g. the user could specify shifted Poisson, Geometric, and Negative Binomial for states 1, 2, and 3, respectively. In practice, this is useful as each family has its own benefits. For example, if in our data we see two states with long and consistent sojourn distributions then we may want to use a Shifted Poisson or a Negative Binomial for those states. But if we see that a specific state has a very unstable sojourn then it may be the case that a nonparametric or a geometric sojourn is more suitable. Thus the combination of sojourns will yield the most natural parameterization. This obviously comes at the expense of doing quite a bit of data analytics before fitting the model (but this is often the case anyways). Future work is aimed at building initialization procedures that can suggest or even automatically choose the the most suitable sojourn distribution for each state.

THMM Recovery

A natural question to ask is if the THSMM can recover a THMM. To this extent we generate synthetic data where each state has a geometric sojourn distribution. We then fit three models, a THMM, a THSMM with homogeneous geometric sojourn distributions, and a THSMM with homogeneous negative binomial distributions, where an aggregate size of m=30m = 30 was used for each state of the THSMM. In this sense the THSMM with geometric sojourns should be able to exactly recover the THMM and the THSMM with negative binomial should be able to get quite close, as a geometric distribution is a special case of a binomial distribution. See Table C2 for various statistics of the fitted models over 50 replications. As expected, the THSMM reproduces the THMM exactly when geometric sojourns are used, see Figure 3 for plots of the fitted sojourns.

Fitted sojourn distribution per state for THMM, and THSMMs on nonparametric $L^2$ curves with geometric sojourn distributions

Figure 3. Fitted sojourn distribution per state for THMM, and THSMMs on nonparametric L2L^2 curves with geometric sojourn distributions.

Sep.MethodStateParameterTrueMeanBiasSDRMSE
lowTHMM1mean curve RMSE00.1480.1480.06830.162
lowTHMM1mean dwell2.52.11-0.3911.011.07
lowTHMM1prob0.40.5560.1560.1910.245
lowTHMM1TV dwell00.2270.2270.1150.254
lowTHMM2mean curve RMSE00.06950.06950.02830.0749
lowTHMM2mean dwell45.821.822.793.31
lowTHMM2prob0.250.243-0.007280.1670.165
lowTHMM2TV dwell00.2460.2460.09670.264
lowTHMM3mean curve RMSE00.04320.04320.02150.0482
lowTHMM3mean dwell6.675.57-1.092.943.11
lowTHMM3prob0.150.260.110.1690.2
lowTHMM3TV dwell00.2230.2230.1870.29
lowTHSMM-G1mean curve RMSE00.1480.1480.06830.162
lowTHSMM-G1mean dwell2.52.11-0.3911.011.07
lowTHSMM-G1prob0.40.5560.1560.1910.245
lowTHSMM-G1TV dwell00.2270.2270.1150.254
lowTHSMM-G2mean curve RMSE00.06950.06950.02830.0749
lowTHSMM-G2mean dwell45.821.822.793.31
lowTHSMM-G2prob0.250.243-0.007280.1670.165
lowTHSMM-G2TV dwell00.2460.2460.09670.264
lowTHSMM-G3mean curve RMSE00.04320.04320.02150.0482
lowTHSMM-G3mean dwell6.675.57-1.092.943.11
lowTHSMM-G3prob0.150.260.110.1690.2
lowTHSMM-G3TV dwell00.2230.2230.1870.29
lowTHSMM-NB1mean curve RMSE00.1480.1480.06890.163
lowTHSMM-NB1mean dwell2.52.25-0.2521.291.3
lowTHSMM-NB1prob0.40.5740.1740.1960.261
lowTHSMM-NB1size115.614.698.898.9
lowTHSMM-NB1TV dwell00.2680.2680.1220.294
lowTHSMM-NB2mean curve RMSE00.06770.06770.02680.0727
lowTHSMM-NB2mean dwell46.32.33.113.85
lowTHSMM-NB2prob0.250.3790.1290.210.244
lowTHSMM-NB2size12.75e+082.75e+081.95e+091.95e+09
lowTHSMM-NB2TV dwell00.3780.3780.1310.4
lowTHSMM-NB3mean curve RMSE00.04470.04470.02310.0502
lowTHSMM-NB3mean dwell6.675.73-0.9343.243.34
lowTHSMM-NB3prob0.150.3730.2230.2270.316
lowTHSMM-NB3size11.35e+111.35e+119.54e+119.54e+11
lowTHSMM-NB3TV dwell00.3170.3170.1540.352
mediumTHMM1mean curve RMSE00.05010.05010.08640.0991
mediumTHMM1mean dwell2.52.760.2620.5480.602
mediumTHMM1prob0.40.383-0.01680.1130.114
mediumTHMM1TV dwell00.09840.09840.07740.125
mediumTHMM2mean curve RMSE00.02410.02410.02080.0317
mediumTHMM2mean dwell45.391.390.9311.67
mediumTHMM2prob0.250.19-0.05960.02930.0663
mediumTHMM2TV dwell00.1170.1170.06390.133
mediumTHMM3mean curve RMSE00.01760.01760.01660.0241
mediumTHMM3mean dwell6.677.140.4781.841.88
mediumTHMM3prob0.150.1640.01420.1020.102
mediumTHMM3TV dwell00.09680.09680.1250.157
mediumTHSMM-G1mean curve RMSE00.05010.05010.08640.0991
mediumTHSMM-G1mean dwell2.52.760.2620.5480.602
mediumTHSMM-G1prob0.40.383-0.01680.1130.114
mediumTHSMM-G1TV dwell00.09840.09840.07740.125
mediumTHSMM-G2mean curve RMSE00.02410.02410.02080.0317
Sep.MethodStateParameterTrueMeanBiasSDRMSE
mediumTHSMM-G2mean dwell45.391.390.9311.67
mediumTHSMM-G2prob0.250.19-0.05960.02930.0663
mediumTHSMM-G2TV dwell00.1170.1170.06390.133
mediumTHSMM-G3mean curve RMSE00.01760.01760.01660.0241
mediumTHSMM-G3mean dwell6.677.140.4781.841.88
mediumTHSMM-G3prob0.150.1640.01420.1020.102
mediumTHSMM-G3TV dwell00.09680.09680.1250.157
mediumTHSMM-NB1mean curve RMSE00.050.050.08540.0982
mediumTHSMM-NB1mean dwell2.52.880.3770.5760.684
mediumTHSMM-NB1prob0.40.4920.09170.1580.181
mediumTHSMM-NB1size12.181.181.722.07
mediumTHSMM-NB1TV dwell00.1620.1620.08490.183
mediumTHSMM-NB2mean curve RMSE00.02430.02430.02070.0318
mediumTHSMM-NB2mean dwell45.631.630.9341.87
mediumTHSMM-NB2prob0.250.2890.03890.0970.104
mediumTHSMM-NB2size11.920.9180.9041.28
mediumTHSMM-NB2TV dwell00.2070.2070.06790.218
mediumTHSMM-NB3mean curve RMSE00.01790.01790.01750.0249
mediumTHSMM-NB3mean dwell6.677.360.6921.952.05
mediumTHSMM-NB3prob0.150.2120.06210.1450.157
mediumTHSMM-NB3size11.520.5240.7440.903
mediumTHSMM-NB3TV dwell00.1550.1550.1220.197
highTHMM1mean curve RMSE00.01060.01060.003610.0112
highTHMM1mean dwell2.52.580.08020.2460.257
highTHMM1prob0.40.391-0.008850.03860.0393
highTHMM1TV dwell00.03940.03940.02650.0473
highTHMM2mean curve RMSE00.009010.009010.003510.00965
highTHMM2mean dwell44.180.1770.4040.437
highTHMM2prob0.250.242-0.008310.02450.0257
highTHMM2TV dwell00.03570.03570.02670.0445
highTHMM3mean curve RMSE00.006880.006880.002690.00737
highTHMM3mean dwell6.676.70.0290.7860.779
highTHMM3prob0.150.1510.00130.01710.017
highTHMM3TV dwell00.03570.03570.02810.0453
highTHSMM-G1mean curve RMSE00.01060.01060.003610.0112
highTHSMM-G1mean dwell2.52.580.08020.2460.256
highTHSMM-G1prob0.40.391-0.008850.03860.0393
highTHSMM-G1TV dwell00.03940.03940.02650.0473
highTHSMM-G2mean curve RMSE00.009010.009010.003510.00965
highTHSMM-G2mean dwell44.180.1770.4040.437
highTHSMM-G2prob0.250.242-0.008310.02450.0257
highTHSMM-G2TV dwell00.03570.03570.02670.0445
highTHSMM-G3mean curve RMSE00.006880.006880.002690.00737
highTHSMM-G3mean dwell6.676.70.0290.7860.779
highTHSMM-G3prob0.150.1510.00130.01710.017
highTHSMM-G3TV dwell00.03570.03570.02810.0453
highTHSMM-NB1mean curve RMSE00.01070.01070.003640.0113
highTHSMM-NB1mean dwell2.52.580.08480.2490.261
highTHSMM-NB1prob0.40.4320.03190.07910.0845
highTHSMM-NB1size11.240.2350.3790.443
highTHSMM-NB1TV dwell00.06130.06130.0330.0695
highTHSMM-NB2mean curve RMSE00.009030.009030.003520.00968
highTHSMM-NB2mean dwell44.190.1860.4070.444
highTHSMM-NB2prob0.250.2640.01410.05390.0552
highTHSMM-NB2size11.150.1510.2950.328
highTHSMM-NB2TV dwell00.06360.06360.03430.0722
highTHSMM-NB3mean curve RMSE00.006880.006880.002690.00738
highTHSMM-NB3mean dwell6.676.70.03440.7860.779
highTHSMM-NB3prob0.150.1660.0160.0350.0382
highTHSMM-NB3size11.120.1250.2370.266
highTHSMM-NB3TV dwell00.06240.06240.02630.0676

Table C2. Geometric truth (n=50n = 50 replicates per cell): estimates of matched states (leave probability prob, negative binomial size and prob, mean dwell, TV distance between fitted and true dwell pmfs, RMSE of the fitted mean curve), by separation; geo(pp) = 1 + NB(size = 1, prob = pp). All dwell distributions are geometric. Methods: THMM = THMM (funHMM); THSMM-G = THSMM, geometric; THSMM-NB = THSMM, negative binomial.

An interesting takeaway is that separation of the observations drives the estimation quality. As separation increases, the total variation (TV) distance between the fitted and the true dwell pmfs falls from about 0.22 – 0.25 at low separation, to 0.10 – 0.12 at medium, to under 0.04 at high. Root means square error (RMSE) falls similarly, from 0.04 – 0.15 to below 0.011. Suggesting — at least in the case of geometric sojourn distributions — the when states overlap, a short visit to a state may get absorbed by a neighboring state, conversely long visits may unnecessarily transition out of a state; this is a known consequence for HMMs in a continuous and discrete data setting but now highlighted clearly for functional data.

Fitting the negative binomial when the truth is known to be geometric highlights how the THSMM behaves with an unnecessarily flexible dwell family. At low separation the size parameter estimates range from 15.6 to 101110^{11} with standard deviation estimates much larger. Meaning that in some replicates the size parameter diverges towards the Poisson limit. At medium separation the size estimates begin to stabilize but remain upwardly biased (1.5 − 2.2 against a true value of 1) and at high separation they are close to the truth (1.12 − 1.24). The extra flexibility does not noticeably effect the fitted emission distributions as the mean curve RMSEs are almost identical to the geometric fits. The cost is a modest loss of precision in the dwell distribution and an unidentified size parameter when separation is low.

In conclusion, the THSMM recovers the THMM exactly when the dwell family is geometric. When the dwell family is more flexible that it needs to be, the THSMM still estimates mean dwells and state mean curves as well as the correctly specified model.

THSMM Sojourn Recovery

We now seek to answer the main question at hand, if the THSMM can recover the true sojourn distribution when we know that it is not geometric. Here we simulate nonparametric L2L^2 curves with low, medium, and high separation using two sojourn schemes, a shifted Poisson with shift (3, 2, 4) for states 1, 2, and 3, respectively, and negative binomial. See Table C3 for various statistics of the fitted models over 50 replications. Note, we refer to the “true model” as the one whose sojourn distributions match that of the ones used to generate the data.

Sep.MethodStateParameterTrueMeanBiasSDRMSE
True dwell distribution: negative binomial
lowTHMM1mean curve RMSE00.05510.05510.05340.0764
lowTHMM1mean dwell43.69-0.3141.111.15
lowTHMM1TV dwell00.2530.2530.1550.296
lowTHMM2mean curve RMSE00.03580.03580.03170.0476
lowTHMM2mean dwell65.68-0.3241.881.89
lowTHMM2TV dwell00.3450.3450.150.376
lowTHMM3mean curve RMSE00.02380.02380.007830.0251
lowTHMM3mean dwell7.677.47-0.1951.051.06
lowTHMM3TV dwell00.3780.3780.04310.381
lowTHSMM-SP1mean curve RMSE00.03210.03210.01820.0368
lowTHSMM-SP1mean dwell44.670.6680.7260.981
lowTHSMM-SP1TV dwell00.2640.2640.0750.274
lowTHSMM-SP2mean curve RMSE00.0190.0190.007830.0205
lowTHSMM-SP2mean dwell66.930.9260.8321.24
lowTHSMM-SP2TV dwell00.2620.2620.07460.272
lowTHSMM-SP3mean curve RMSE00.01820.01820.00450.0188
lowTHSMM-SP3mean dwell7.678.410.7430.8451.12
lowTHSMM-SP3TV dwell00.1940.1940.0660.205
lowTHSMM-NB1mean curve RMSE00.04990.04990.05270.0722
lowTHSMM-NB1mean dwell44.120.1171.261.26
lowTHSMM-NB1prob0.50.6460.1460.1740.226
lowTHSMM-NB1size39.556.5511.513.1
lowTHSMM-NB1TV dwell00.2280.2280.1670.282
lowTHSMM-NB2mean curve RMSE00.03150.03150.0310.044
lowTHSMM-NB2mean dwell66.30.2992.032.03
lowTHSMM-NB2prob0.50.6340.1340.1930.233
lowTHSMM-NB2size51.19e+111.19e+115.18e+115.27e+11
lowTHSMM-NB2TV dwell00.2470.2470.1990.316
lowTHSMM-NB3mean curve RMSE00.01950.01950.008660.0213
lowTHSMM-NB3mean dwell7.678.270.61.111.25
lowTHSMM-NB3prob0.60.6770.07690.2270.237
lowTHSMM-NB3size109.12e+109.12e+104.09e+114.15e+11
lowTHSMM-NB3TV dwell00.1330.1330.1030.168
lowTHSMM-NP1mean curve RMSE00.04020.04020.05170.0651
lowTHSMM-NP1mean dwell44.70.7041.031.24
lowTHSMM-NP1TV dwell00.5250.5250.1110.536
lowTHSMM-NP2mean curve RMSE00.02290.02290.02140.0312
lowTHSMM-NP2mean dwell67.091.091.341.71
lowTHSMM-NP2TV dwell00.5550.5550.08890.562
lowTHSMM-NP3mean curve RMSE00.0180.0180.004690.0185
lowTHSMM-NP3mean dwell7.678.660.9890.6731.19
lowTHSMM-NP3TV dwell00.4850.4850.07510.49
mediumTHMM1mean curve RMSE00.01310.01310.004540.0138
mediumTHMM1mean dwell44.140.1450.3350.362
mediumTHMM1TV dwell00.1770.1770.0060.177
mediumTHMM2mean curve RMSE00.0110.0110.003430.0115
mediumTHMM2mean dwell66.040.03570.4490.446
mediumTHMM2TV dwell00.2740.2740.003120.274
mediumTHMM3mean curve RMSE00.01090.01090.003770.0115
mediumTHMM3mean dwell7.677.770.1080.4570.465
mediumTHMM3TV dwell00.3690.3690.00220.369
mediumTHSMM-SP1mean curve RMSE00.01380.01380.004850.0146
mediumTHSMM-SP1mean dwell44.380.3780.3890.539
mediumTHSMM-SP1TV dwell00.2050.2050.03580.208
mediumTHSMM-SP2mean curve RMSE00.01090.01090.003130.0113
mediumTHSMM-SP2mean dwell66.320.3240.4830.577
mediumTHSMM-SP2TV dwell00.1910.1910.03010.193
Sep.MethodStateParameterTrueMeanBiasSDRMSE
mediumTHSMM-SP3mean curve RMSE00.01010.01010.003630.0107
mediumTHSMM-SP3mean dwell7.677.970.3080.4380.532
mediumTHSMM-SP3TV dwell00.1440.1440.02450.146
mediumTHSMM-NB1mean curve RMSE00.01280.01280.004380.0135
mediumTHSMM-NB1mean dwell44.360.360.390.528
mediumTHSMM-NB1prob0.50.6220.1220.1170.169
mediumTHSMM-NB1size36.523.523.885.21
mediumTHSMM-NB1TV dwell00.1060.1060.04940.116
mediumTHSMM-NB2mean curve RMSE00.01040.01040.00310.0109
mediumTHSMM-NB2mean dwell66.330.3350.4630.568
mediumTHSMM-NB2prob0.50.5670.06730.1360.15
mediumTHSMM-NB2size59.294.298.989.88
mediumTHSMM-NB2TV dwell00.08140.08140.04780.0942
mediumTHSMM-NB3mean curve RMSE00.009960.009960.003610.0106
mediumTHSMM-NB3mean dwell7.6780.3380.4560.564
mediumTHSMM-NB3prob0.60.6620.06220.1320.145
mediumTHSMM-NB3size102.99e+072.99e+072.11e+082.11e+08
mediumTHSMM-NB3TV dwell00.07420.07420.0350.0819
mediumTHSMM-NP1mean curve RMSE00.0130.0130.004140.0137
mediumTHSMM-NP1mean dwell44.50.4980.3740.621
mediumTHSMM-NP1TV dwell00.2770.2770.06470.285
mediumTHSMM-NP2mean curve RMSE00.01060.01060.003070.011
mediumTHSMM-NP2mean dwell66.440.4430.4860.653
mediumTHSMM-NP2TV dwell00.2960.2960.06340.302
mediumTHSMM-NP3mean curve RMSE00.009860.009860.003620.0105
mediumTHSMM-NP3mean dwell7.678.080.4090.480.627
mediumTHSMM-NP3TV dwell00.2680.2680.06020.274
highTHMM1mean curve RMSE00.009320.009320.004310.0103
highTHMM1mean dwell44.040.03860.3380.337
highTHMM1TV dwell00.1770.1770.006620.177
highTHMM2mean curve RMSE00.007450.007450.002570.00788
highTHMM2mean dwell66.140.1350.5050.518
highTHMM2TV dwell00.2750.2750.005490.275
highTHMM3mean curve RMSE00.006470.006470.003480.00733
highTHMM3mean dwell7.677.720.05490.390.39
highTHMM3TV dwell00.3680.3680.001790.368
highTHSMM-SP1mean curve RMSE00.009520.009520.004270.0104
highTHSMM-SP1mean dwell44.090.09150.360.368
highTHSMM-SP1TV dwell00.1830.1830.02790.185
highTHSMM-SP2mean curve RMSE00.007410.007410.002610.00785
highTHSMM-SP2mean dwell66.190.1880.5220.55
highTHSMM-SP2TV dwell00.1860.1860.02990.188
highTHSMM-SP3mean curve RMSE00.006530.006530.003470.00737
highTHSMM-SP3mean dwell7.677.730.06460.3930.395
highTHSMM-SP3TV dwell00.1330.1330.01220.134
highTHSMM-NB1mean curve RMSE00.009380.009380.004290.0103
highTHSMM-NB1mean dwell44.070.07090.3460.349
highTHSMM-NB1prob0.50.5420.04180.1070.113
highTHSMM-NB1size34.111.112.42.62
highTHSMM-NB1TV dwell00.06490.06490.03580.0739
highTHSMM-NB2mean curve RMSE00.007420.007420.002580.00785
highTHSMM-NB2mean dwell66.170.1720.5110.535
highTHSMM-NB2prob0.50.5390.03860.1090.115
highTHSMM-NB2size56.751.753.483.87
highTHSMM-NB2TV dwell00.06770.06770.04250.0797
highTHSMM-NB3mean curve RMSE00.00650.00650.003470.00735
highTHSMM-NB3mean dwell7.677.730.06060.3870.388
highTHSMM-NB3prob0.60.6210.02080.1330.133
highTHSMM-NB3size1020.510.540.141.1
highTHSMM-NB3TV dwell00.05850.05850.03180.0664
highTHSMM-NP1mean curve RMSE00.00940.00940.004380.0104
highTHSMM-NP1mean dwell44.070.07230.360.364
highTHSMM-NP1TV dwell00.170.170.04680.176
highTHSMM-NP2mean curve RMSE00.00740.00740.002590.00783
Sep.MethodStateParameterTrueMeanBiasSDRMSE
highTHSMM-NP2mean dwell66.180.180.5210.547
highTHSMM-NP2TV dwell00.2030.2030.04620.208
highTHSMM-NP3mean curve RMSE00.006490.006490.003470.00734
highTHSMM-NP3mean dwell7.677.720.05630.3830.383
highTHSMM-NP3TV dwell00.1930.1930.04020.197
True dwell distribution: shifted Poisson
lowTHMM1mean curve RMSE00.03980.03980.02140.0451
lowTHMM1mean dwell43.25-0.7480.4630.877
lowTHMM1TV dwell00.6220.6220.04510.624
lowTHMM2mean curve RMSE00.05650.05650.0240.0613
lowTHMM2mean dwell42.96-1.040.5421.17
lowTHMM2TV dwell00.4840.4840.08320.491
lowTHMM3mean curve RMSE00.05070.05070.009040.0515
lowTHMM3mean dwell53.68-1.320.4681.4
lowTHMM3TV dwell00.7090.7090.02510.709
lowTHSMM-SP1λ\lambda11.070.06520.1330.147
lowTHSMM-SP1mean curve RMSE00.0150.0150.004850.0158
lowTHSMM-SP1mean dwell44.090.08520.1520.173
lowTHSMM-SP1shift33.020.020.1410.141
lowTHSMM-SP1TV dwell00.04990.04990.05470.0737
lowTHSMM-SP2λ\lambda21.45-0.550.4620.715
lowTHSMM-SP2mean curve RMSE00.01880.01880.005810.0197
lowTHSMM-SP2mean dwell44.070.07010.210.22
lowTHSMM-SP2shift22.620.620.490.787
lowTHSMM-SP2TV dwell00.1340.1340.07660.154
lowTHSMM-SP3λ\lambda11.060.06480.1830.193
lowTHSMM-SP3mean curve RMSE00.01650.01650.004550.0171
lowTHSMM-SP3mean dwell55.040.04480.1390.145
lowTHSMM-SP3shift43.98-0.020.1410.141
lowTHSMM-SP3TV dwell00.04410.04410.04040.0595
lowTHSMM-NB1mean curve RMSE00.02640.02640.01740.0315
lowTHSMM-NB1mean dwell42.76-1.240.3761.29
lowTHSMM-NB1TV dwell00.5170.5170.0850.523
lowTHSMM-NB2mean curve RMSE00.03840.03840.01940.0429
lowTHSMM-NB2mean dwell43.14-0.8650.4950.994
lowTHSMM-NB2TV dwell00.2990.2990.1250.324
lowTHSMM-NB3mean curve RMSE00.03630.03630.0110.0379
lowTHSMM-NB3mean dwell54.05-0.950.5431.09
lowTHSMM-NB3TV dwell00.4890.4890.08830.497
lowTHSMM-NP1mean curve RMSE00.01470.01470.004830.0155
lowTHSMM-NP1mean dwell44.080.07870.1480.166
lowTHSMM-NP1TV dwell00.2240.2240.1070.248
lowTHSMM-NP2mean curve RMSE00.0190.0190.005990.0199
lowTHSMM-NP2mean dwell44.10.0980.2020.223
lowTHSMM-NP2TV dwell00.2770.2770.09540.292
lowTHSMM-NP3mean curve RMSE00.01640.01640.004750.0171
lowTHSMM-NP3mean dwell55.020.02210.190.19
lowTHSMM-NP3TV dwell00.1690.1690.07810.186
mediumTHMM1mean curve RMSE00.01330.01330.004560.014
mediumTHMM1mean dwell43.75-0.2540.1330.286
mediumTHMM1TV dwell00.5990.5990.001870.599
mediumTHMM2mean curve RMSE00.01570.01570.005320.0166
mediumTHMM2mean dwell43.75-0.2480.1860.309
mediumTHMM2TV dwell00.430.430.002840.43
mediumTHMM3mean curve RMSE00.01530.01530.004340.0159
mediumTHMM3mean dwell54.73-0.2740.1470.31
mediumTHMM3TV dwell00.6810.6810.001270.681
mediumTHSMM-SP1λ\lambda12.051.050.1921.06
mediumTHSMM-SP1mean curve RMSE00.01010.01010.003810.0107
mediumTHSMM-SP1mean dwell44.150.1470.2350.275
mediumTHSMM-SP1shift32.1-0.90.3030.949
mediumTHSMM-SP1TV dwell00.2130.2130.02310.215
mediumTHSMM-SP2λ\lambda22.070.06650.2540.26
Sep.MethodStateParameterTrueMeanBiasSDRMSE
mediumTHSMM-SP2mean curve RMSE00.01130.01130.004770.0123
mediumTHSMM-SP2mean dwell44.050.04650.1730.178
mediumTHSMM-SP2shift21.98-0.020.1410.141
mediumTHSMM-SP2TV dwell00.04090.04090.0310.0511
mediumTHSMM-SP3λ\lambda12.451.450.3371.48
mediumTHSMM-SP3mean curve RMSE00.01020.01020.003460.0108
mediumTHSMM-SP3mean dwell55.330.3270.2660.42
mediumTHSMM-SP3shift42.88-1.120.3281.17
mediumTHSMM-SP3TV dwell00.260.260.04070.263
mediumTHSMM-NB1mean curve RMSE00.01130.01130.004160.0121
mediumTHSMM-NB1mean dwell43.2-0.8010.2110.828
mediumTHSMM-NB1TV dwell00.430.430.03650.431
mediumTHSMM-NB2mean curve RMSE00.01340.01340.005070.0143
mediumTHSMM-NB2mean dwell43.2-0.8010.3270.864
mediumTHSMM-NB2TV dwell00.2740.2740.06190.281
mediumTHSMM-NB3mean curve RMSE00.01220.01220.004020.0128
mediumTHSMM-NB3mean dwell54.1-0.90.3590.967
mediumTHSMM-NB3TV dwell00.4740.4740.05450.477
mediumTHSMM-NP1mean curve RMSE00.009460.009460.003610.0101
mediumTHSMM-NP1mean dwell43.99-0.01020.1210.12
mediumTHSMM-NP1TV dwell00.120.120.05190.131
mediumTHSMM-NP2mean curve RMSE00.01150.01150.004420.0123
mediumTHSMM-NP2mean dwell44.050.05080.1830.188
mediumTHSMM-NP2TV dwell00.1370.1370.04970.145
mediumTHSMM-NP3mean curve RMSE00.009120.009120.003510.00975
mediumTHSMM-NP3mean dwell54.97-0.03160.120.123
mediumTHSMM-NP3TV dwell00.1020.1020.04090.11
highTHMM1mean curve RMSE00.008970.008970.00360.00965
highTHMM1mean dwell440.0010.1010.1
highTHMM1TV dwell00.5970.5970.0004880.597
highTHMM2mean curve RMSE00.008790.008790.003610.00949
highTHMM2mean dwell43.95-0.05430.1520.16
highTHMM2TV dwell00.4280.4280.001210.428
highTHMM3mean curve RMSE00.007580.007580.003260.00824
highTHMM3mean dwell54.98-0.01680.1060.107
highTHMM3TV dwell00.6790.6790.0003930.679
highTHSMM-SP1λ\lambda12.841.840.1861.85
highTHSMM-SP1mean curve RMSE00.008990.008990.003590.00967
highTHSMM-SP1mean dwell44.440.4420.3670.572
highTHSMM-SP1shift31.6-1.40.4951.48
highTHSMM-SP1TV dwell00.310.310.02050.31
highTHSMM-SP2λ\lambda22.960.960.1530.972
highTHSMM-SP2mean curve RMSE00.008720.008720.003570.00941
highTHSMM-SP2mean dwell43.96-0.03960.1530.157
highTHSMM-SP2shift21-101
highTHSMM-SP2TV dwell00.1090.1090.006950.109
highTHSMM-SP3λ\lambda13.762.760.1932.76
highTHSMM-SP3mean curve RMSE00.007540.007540.003250.0082
highTHSMM-SP3mean dwell55.580.5760.3070.651
highTHSMM-SP3shift41.82-2.180.3882.21
highTHSMM-SP3TV dwell00.3610.3610.01860.361
highTHSMM-NB1mean curve RMSE00.008990.008990.003590.00967
highTHSMM-NB1mean dwell43.91-0.08990.09950.133
highTHSMM-NB1TV dwell00.3570.3570.003230.357
highTHSMM-NB2mean curve RMSE00.008740.008740.003570.00943
highTHSMM-NB2mean dwell43.89-0.110.1430.179
highTHSMM-NB2TV dwell00.1640.1640.001810.164
highTHSMM-NB3mean curve RMSE00.007550.007550.003250.0082
highTHSMM-NB3mean dwell54.76-0.2410.09380.258
highTHSMM-NB3TV dwell00.4080.4080.003890.408
highTHSMM-NP1mean curve RMSE00.009010.009010.003560.00967
highTHSMM-NP1mean dwell44.010.01440.1010.101
highTHSMM-NP1TV dwell00.08350.08350.03180.0892
highTHSMM-NP2mean curve RMSE00.008760.008760.003570.00944
Sep.MethodStateParameterTrueMeanBiasSDRMSE
highTHSMM-NP2mean dwell43.97-0.03320.1540.156
highTHSMM-NP2TV dwell00.0970.0970.03170.102
highTHSMM-NP3mean curve RMSE00.007520.007520.003260.00819
highTHSMM-NP3mean dwell54.99-0.01230.1050.105
highTHSMM-NP3TV dwell00.08050.08050.02990.0858

Table C3. Non-geometric truths (n=50n = 50 replicates per cell): dwell and mean-curve estimates of matched states, by separation. Methods: THMM = THMM (funHMM); THSMM-SP = THSMM, shifted Poisson; THSMM-NB = THSMM, negative binomial; THSMM-NP = THSMM, nonparametric.

The low separation setting with shifted Poisson dwell times shows most clearly how much the dwell specifications matter when the states are hard to tell apart, see Figure 4. All three true distributions put no mass below a minimum sojourn length of sj∈{3,2,4}s_j \in\{3, 2, 4\}. As expected the THMM cannot represent this minimum and underestimates every mean dwell time giving (3.25, 2.96, 3.68) against the true values of (4, 4, 5). The negative binomial family also has poor performance with its mean dwell times having a downwards bias, due to the constraint of needing to put some mass in the first four dwell times. The non-parametric sojourn recovers mean dwell very accurately however at the cost of having a much higher TV distance, which is expected when estimating an unstructured pmf. Finally, the shifted poisson gives the most accurate fit, it recovers the shift for each state within 0.02, and estimates every mean dwell to within 0.09.

Figure 4. Fitted sojourn distributions per state for THMM and various THSMMs on nonparametric L2L^2 curves with shifted Poisson sojourn distributions. In pink the estimated 10 – 90% band over 50 replications of the fitted Poisson sojourns.

In the low separation setting when the true dwell times are negative binomial, there is no definitive winner between models. The true distributions are overdispersed and lie much closer to the geometric family than the shifted Poisson, leaving more “wiggle room” for various sojourn distributions to fit, see Figure 3. The shifted Poisson THSMM trades bias for stability as its shape is completely dictated by a single parameter. The cost comes at an upwards bias towards mean dwell times where they were overestimated by 0.68 – 0.93. However, this added stability allows for it to produce the most accurate emission distributions from among the models. By assigning zero probability to sojourns shorter than s^j\hat{s}_j, it suppresses spurious short state visits in the forward–backward recursions. The posterior state weights used in the emission update are therefore less contaminated by observations from overlapping states. Nonparametric sojourn distributions struggle in this setting as overlapping states plague the increased flexibility of the distribution with numerical instability. In Figure 5, the nonparametric sojourns are quite rough and have erratic behaviors. Finally, the negative binomial distribution recovers the shape of the sojourn the best. However, individual parameters are poorly identified. In some cases the size degenerated to the Poisson limit and the pjp_j estimates are biased upwards to compensate. This can be seen in the 10–90% bands in the plot, with the large spike indicates a misspecified fit.

Fitted sojourn distributions per state for THMM and various THSMMs on nonparametric $L^2$ curves with negative binomial sojourn distributions

Figure 5. Fitted sojourn distributions per state for THMM and various THSMMs on nonparametric L2L^2 curves with negative binomial sojourn distributions. In orange the estimated 10 – 90% band over 50 replications of the fitted negative binomial sojourn.

Many more results can be found in the accompanying repository. First, the negative binomial cannot recover the under-dispersion that the shifted Poisson can tackle; conversely, the shifted Poisson is typically upwardly biased in mean state duration estimates. Second, the nonparametric sojourn distribution estimates become more stable as the separation of the data increases, see Table C3. This suggests that more data could also remedy stability. Finally, the importance of running many repetitions to achieve a model with adequately stable estimates is necessary when data separation is low.

In conclusion, The THMM’s geometric assumption creates a dwell error of known size that more data cannot remove. Any non-geometric THSMM reduces it, and a correctly specified family nearly eliminates it at moderate separation. The nonparametric THSMM is a useful default that makes no assumption about form, provided the states are reasonably well separated. When they are not, a parametric family with the right dispersion direction is the better choice. When the states are hard to distinguish, the dwell model also improves the recovered state mean curves.

THSMM Comparative Performance

We investigate Viterbi performance between THMM and THSMM models. This is of quite some importance as it can be argued that the actual usefulness of either of these models (or any latent state space model) is to decode the hidden state sequence of observations. As before we simulate nonparametric L2L^2 curves at low, medium, and high separation, under shifted Poisson and negative binomial sojourn distributions. Additionally to form a more comprehensive study we further simulate Brownian motion (BM), Ornstein-Uhlenbeck (OU) Process, and fractional Brownian Motion (fBM), under shifted Poisson, negative binomial, Weibull and a mixed family setting where each of the preceding is the sojourn for an individual state.

See Table 1 for ARIs of the nonparametric L2L^2 curve setting used in the previous subsections. First, the most meaningful gains to ARI occurred in the low separation setting. This is where the semi-Markov structure is most useful. When states overlap, a THSMM’s probability of leaving a state depends on how long the process has already spent there, so an ambiguous observation early in a sojourn is attributed to the current state rather than treated as evidence of a transition. The mechanism is clearest through the dwell hazard

Dwell truthSep.THMM (funHMM)THSMM-GTHSMM-true
Negative binomiallow0.665 (0.131)0.665 (0.131)0.710 (0.137)
medium0.950 (0.017)0.950 (0.017)0.948 (0.018)
high0.997 (0.003)0.997 (0.003)0.995 (0.003)
Shifted Poissonlow0.519 (0.091)0.519 (0.091)0.864 (0.031)
medium0.950 (0.015)0.950 (0.015)0.970 (0.010)
high0.998 (0.002)0.998 (0.002)0.999 (0.002)

Table 1. Viterbi ARI against the true states (mean (sd) over 50 replicates) by dwell truth and separation. THSMM-G is the THMM fitted by the THSMM code (geometric dwell); THSMM-true uses the true dwell family.

cj(r)=P(Dj=r∣Dj≥r)=dj(r)1−∑u<rdj(u)c_j(r) = P(D_j = r \mid D_j \ge r) = \frac{d_j(r)}{1 - \sum_{u<r} d_j(u)}

which gives the probability of leaving state jj after rr time steps, given that it has not left before then. In the expanded-state representation, cj(r)c_j(r) is precisely the exit probability from the rr-th substate of state jj’s aggregate. At each time step, the forward–backward recursions weigh this prior exit probability against the emission evidence: the posterior log-odds of a transition combine log⁡{cj(r)/(1−cj(r))}\log\{c_j(r)/(1-c_j(r))\} with the log-likelihood ratio of the observation under the competing states. When states overlap, that likelihood ratio is close to zero, so the dwell term dominates the decision. As observations become more well separated the semi-Markov dynamics play less of a roll and emission densities take over the state assignment from the Viterbi algorithm. This is not a detriment to the THSMM. Classically best model fitting practice suggest to fit a model with the fewest number of parameters while not sacrificing accuracy. Therefore, in a setting where the data is well separated the user should take an Occam’s razor approach to model fitting (which is historically the most commonly accepted approach) and choose a THMM instead of a THSMM.

To extend the study and confirm that gains are not made solely on the emission emission distributions, we repeat the comparison with BM, OU, and fBM, emission distributions as well. See Figure C1, Figure C2, Figure C3, and Figure C4 for examples of plotted emission distributions with various sojourn distributions.

Figure C1. Simulated Brownian motion with drift form a three state semi-Markov process where sojourn distributions are shifted Poisson.

Figure C2. Simulated Brownian motion with drift form a three state semi-Markov process where sojourn distributions are a mixture of families.

Figure C3. Simulated OU from a three state semi-Markov process where sojourn distributions are negative binomial.

Figure C4. Simulated Fractional BM with drift from a three state semi-Markov process where sojourn distributions are Weibull.

The oracle choice for the sojourn distribution is optimal, which is seen in all twelve process–scenario combinations in Table 2. Nevertheless, the nonparametric THSMM keeps most of this advantage without knowing the dwell family. Its gains are 0.10–0.14 for shifted Poisson, 0.03–0.05 for Weibull and 0.02–0.06 for mixed families, typically 0.01–0.03 below the true family. The exception is the peaked negative binomial. There the nonparametric THSMM is no better than the THMM: its mean differences range from −0.018 to 0.007, and it is better in only 34–52% of replicates. This matches § 2, where the nonparametric model struggled to estimate diffuse negative binomial dwell distributions. Overall, a correctly specified parametric family gives the best decoding. When the family is unknown, the nonparametric THSMM is a safe default that never decodes meaningfully worse than the THMM and is often substantially better.

ProcessScenarioTHMMTHSMM-GTHSMM-NPTHSMM-true
BMShifted Poisson0.640 (0.059)0.647 (0.055)0.760 (0.055)0.789 (0.048)
Peaked NB0.681 (0.054)0.688 (0.058)0.669 (0.054)0.709 (0.064)
Weibull0.678 (0.059)0.685 (0.058)0.718 (0.049)0.724 (0.050)
Mixed families0.678 (0.047)0.677 (0.050)0.718 (0.052)0.739 (0.052)
OUShifted Poisson0.657 (0.046)0.661 (0.052)0.758 (0.051)0.786 (0.051)
Peaked NB0.677 (0.066)0.687 (0.052)0.683 (0.054)0.723 (0.041)
Weibull0.679 (0.043)0.681 (0.044)0.717 (0.048)0.723 (0.048)
Mixed families0.655 (0.078)0.654 (0.092)0.711 (0.063)0.729 (0.073)
fBMShifted Poisson0.631 (0.064)0.632 (0.059)0.767 (0.051)0.793 (0.047)
Peaked NB0.674 (0.052)0.673 (0.058)0.676 (0.057)0.703 (0.068)
Weibull0.671 (0.059)0.677 (0.057)0.721 (0.044)0.727 (0.047)
Mixed families0.672 (0.066)0.676 (0.065)0.698 (0.072)0.748 (0.060)

Table 2. Viterbi ARI under non-geometric dwell times, BM / OU / fBM emissions at low separation (mean (sd) over 50 replicates). THSMM-G is the THMM fitted by the THSMM code (geometric dwell); THSMM-NP is nonparametric; THSMM-true uses the true dwell family. Peaked NB = peaked negative binomial; Weibull has increasing hazard. Failed fits are excluded.

In conclusion, the advantage of modeling the sojourn distribution comes from the dwell structure, not from any particular emission process. And we can confirm that the THSMM even if misspecified will give no worse decoding accuracy than the THMM when the sojourn distributions are not geometric.

Summary

Taken together, the simulations support three conclusions. First, the THSMM is a strict generalisation of the THMM. With geometric dwell times, it reproduces the THMM’s parameter estimates and Viterbi paths exactly, and fitting a more flexible family than needed costs only a modest loss of precision in the dwell distribution, with no effect on the mean dwells or state mean curves. Second, the THMM’s geometric assumption causes a dwell error that more data cannot remove. Any non-geometric THSMM reduces this error, and a correctly specified family nearly eliminates it at moderate separation. Misspecified parametric families still improve on the THMM, especially when their dispersion is in the right direction. The nonparametric THSMM is a robust default when the family is unknown, but it needs reasonable separation to estimate diffuse distributions. Third, these gains carry over to state decoding. The size of the gain depends on how far the dwell distribution is from geometric and on how hard the states are to distinguish. Under the shifted Poisson truth at low separation, the mean ARI rises from 0.52 to 0.86. Under Brownian motion, Ornstein–Uhlenbeck and fractional Brownian motion emissions, the true-family THSMM decodes significantly better than the THMM in every scenario. The common mechanism is the dwell hazard. When emissions overlap, a dwell distribution with an increasing hazard suppresses the spurious short visits that the geometric model favours a priori. This improves both segmentation and emission estimation, and the advantage fades only once the emissions alone separate the states.

Pediatric Obstructive Sleep Apnea Data

The gold standard for diagnosis of obstructive sleep apnea in children is by overnight polysomnography in a hospital or sleep clinic. Polysomnography provides multichannel time series including an electroencephalogram (EEG), electrocardiography (ECG), electrooculography (EOG), and electromyography (EMG). Even for a single patient, this data is vast and should eventually be considered jointly to label sleep states and identify sleep disorders. For simplicity we choose one channel of EEG from one patient labeled as CF076 to be used as a proof of concept. This patient was selected from a group of seventy four pediatric patients with potential obstructive sleep apnea in a clinical study, Pro00057638, approved by University of Alberta. An in-depth analysis of this data can be found in [36]. The sampling rate for EEG is 512 samples per second. Each signal was split into a sequence of epochs, i.e. 30 second intervals. These signals were transformed into power spectral densities (PSD) using Welch’s method for each epoch. The reason for dividing time series into 30 second intervals is to group them with respect to five sleep stages: wake, rapid eye-movement (REM), and non-rapid eye-movement (NREM). The NREM category is further divided into three states: NREM1, NREM2, NREM3. The sleep stages are labelled per epoch by a sleep technician. For every sleep stage not labelled as wake, the patient is considered to be asleep. The spectral densities for each epoch may then be used to identify possible underlying states such as the sleep stages. There were 948 epochs in patient CF050.

Markov models and HMMs have a long history of being applied to the modelling of sleep states [37, 38, 39]. The work of [40] considered an HMM with Gaussian observations for EEG analysis. This was followed by similar analyses in [41, 42]. More recent work includes [43, 44, 45]. Typically, these approaches are based on various discretization and feature selection methods whose output is then fed into the classic HMM. The novelty of the THMM [15] is that it takes the entire power spectral density curve into account and hence obviates the need for such feature selection steps. However it still restricts modelling to the geometric sojourn distribution whereas the recent work of [46] suggest that the negative binomial sojourn may be more appropriate for modeling sleep cycles.

We begin by fitting various THSMMs and THMMs, focousing on THSMMs with Shifted Poisson sojourn distributions and nonparametric functional emission distributions. We choose Shifted Poisson for two reason; first, both models have the same number of free parameters thus they only vary in the shape of the sojourn distribution; second, we found that throughout the exploratory process the Shifted Poisson has the most stable fitted parameters likely due to the fact that the distribution is parameterized only by the mean.

To vary how strongly the emissions drive the posterior relative to the dwell model, we scale the emission variance by a multiplier c∈{1,0.3,0.1}c \in\{1, 0.3, 0.1\}, taking σc=σ1/c\sigma_c = \sigma_1/\sqrt{c}. Smaller cc flattens the emission likelihood allowing for a larger contribution of the sojourn distributions2. Each model was fitted from 51 starts: a k-means baseline plus 50 random perturbations of it. We kept the fit with the highest likelihood and obtained a decoded state sequence with the Viterbi algorithm. We then matched the fitted states to the scored stages and compute accuracy and the adjusted Randi Index (ARI).

Both models recover sleep structure well beyond chance. Permuting the scored labels gives ARI ≈0.000\approx0.000 (99th percentile 0.015). Every selected fit reaches ARI ≥0.32\geq0.32 (moderate to weak) (see Table 3).

ccModelAccuracyBal. acc.ARISojourns (scored: 71)Epochs differing
1.0THMM0.5320.4870.325101–
1.0THSMM0.5280.4780.323958%
0.3THMM0.5450.5030.33149–
0.3THSMM0.6140.5100.4316660%
0.1THMM0.5480.4900.39724–
0.1THSMM0.6090.5040.4415552%

Table 3. Viterbi agreement with the scored states for the highest likelihood fit at each cc.

We see that the dwell time modeling matters most when emission are not decisive. At c=1c = 1, the emission dominates. The two Viterbi paths differ on only 8% of epochs, and the THSMM and THMM are indistinguishable. As cc decreases, the dwell model shapes the decoded path more. The THSMM then improves accuracy by 6–7 points and ARI by 0.04–0.10. The THMM responds to weaker emissions by collapsing into very few long runs and its fitted mean dwell for NREM1 grows from 15 to 48 epochs against a scored 2.7. Notice the 49 sojourns at c=0.3c = 0.3 and 24 at c=0.1c = 0.1 (see Table 3). The THSMM keeps a sojourn count close to the scored one (66 at c=0.3c = 0.3). It also fits short NREM1 sojourns (6.7 epochs) together with long NREM2 and NREM3 sojourns (20.9 and 35.7). A single geometric rate per state cannot produce that contrast. See Figure 6 for plots of the fitted sojourn distributions, were we see that the Poisson sojourn is adapting much better to dwells of longer lengths than that of the geometric. See D for plotted Viterbi state sequences for the fitted models when c=1.0,0.3,0.1c = 1.0, 0.3, 0.1.

Fitted emission distributions for the THSMM when $c = 0.3$

Figure 6. Fitted emission distributions for the THSMM when c=0.3c = 0.3.

Both models identify NREM3 well (recall 0.73–0.96). Neither recovers NREM1, which is short, rare (5% of epochs) and has a PSD closely resembling the states around it (recall ≤0.24\le0.24). Most of the THSMM’s improvement comes from NREM2, whose recall rises from about 0.41 to 0.68–0.72 at c≤0.3c \le0.3. The main persistent error is between Awake and REM, whose smoothed PSDs are similar and is the major cause of low ARI scores for both models. Whichever of the two the models label correctly, most epochs of the other are assigned to it: REM is mostly labelled Awake by the THSMM at c=0.3c = 0.3, and Awake is mostly labelled REM in most of the other fits. A single EEG channel is unlikely to separate these stages without EOG or EMG. For plots of the fitted emission distributions see Figure 7 and see Figure 8 for fitted emissions overlaid on the data (where observations are coloured by decoded states from the specified model).

Fitted emission distributions for the THMM and THSMM when $c = 0.3$

Figure 7. Fitted emission distributions for the THMM and THSMM when c=0.3c = 0.3.

Observations labelled by score and predicted state from Viterbi for the THMM and THSMM

Figure 8. Observations labelled by score and predicted state from Viterbi for the THMM and THSMM when c=0.3c = 0.3.

In summary, replacing the sojourn dynamic gives no benefit when the functional emissions alone determine the path. When we temper the emission distributions, the sojourn distributions have a meaningful impact on likelihood and yield a better calibrated model with higher agreement with the technician scoring. The moderate ARI scores can likely be improved by implementing multiple signals into the emission distributions and is something to consider in future work.

Conclusion

We develop a new model framework THSMM, by incorporating a semi-Markov component to the already existing THMM. By embedding the semi-Markov chain into the THMM transition probability matrix, we obtain Markov chain dynamics whose state durations can follow arbitrary distributions, approximating any known duration family up to length mm. Furthermore, the implementation of THSMM is greatly simplified due to this framework as we have immediate access to the standard (T)HMM toolkit such as the Viterbi algorithm; this can be extended to further results such as THSMMs with covariates, in the state dependent process or the latent process, something we look forward to implementing in the future. Our EM framework yields closed-form updates for the functional distribution parameters during model fitting, a problem that is ill-posed for direct numerical optimization.

As demonstrated in the synthetic data setting the added flexibility yields a tangible improvement to decoded state accuracy; in particular when emission distributions have a strong overlap, the semi-Markov dynamics produce more stable Viterbi sequences. When applied to EEG data from patient CF076, a particularly challenging case to model, the THSMM again improves stability, achieving higher accuracy and ARI than its THMM counterpart.

The THSMM thus extends the THMM to arbitrary duration distributions at little additional computational cost, with clear gains in settings where state emissions overlap, and dwell times are not geometric.

Funding, Conflicts of interests, and AI Usage

The authors would like to thank the Natural Sciences and Engineering Research Council of Canada (NSERC) and the McIntyre Memorial fund from the School of Dentistry at the University of Alberta for their grant funding in support of this research. We declare that their are no conflicts of interest to report in regard to this research project. The ideas and work contained in this paper came solely from the authors. The original research code was written by the authors in R and subsequently translated into C and optimized by Claude Opus. This LLM written C code was carefully checked for accuracy and compared to the original R code by the authors.

Derivations for EM Equations

In the following we note that the time t=Tt = T is excluded. Although there has been much work dedicated to right censoring of semi-Markov processes ([47]). For ease of notation we denote L=P(x1:T)L = \mathbb{P}(x_{1:T}) as the likelihood.

Derivation of ηi(r)\eta_i(r): We want to find

ηi(r)=∑t=1T1{St=(i,r)},\eta_i(r) = \sum_{t=1}^{T} \mathbb{1}\{S_t = (i,r)\},

but we do not have access to SS so we use the forward and backwards probabilities.

E[1[St=(i,r)]∣X1:T]=P(St=(i,r)∣X1:T=x1:T)=P(St=(i,r),x1:T)P(x1:T)=αt(i,r)βt(i,r)L\begin{aligned} \mathbb{E}[\mathbb{1}[S_t = (i,r)]\mid X_{1:T}] &= \mathbb{P}(S_t = (i,r)\mid X_{1:T} = x_{1:T}) \\ &= \frac{\mathbb{P}(S_t = (i,r),x_{1:T})}{\mathbb{P}(x_{1:T})} \\ &= \frac{\alpha_t(i,r)\beta_t(i,r)}{L} \end{aligned}

Summing over all time then gives

ηi(r)=∑t=1T−1αt(i,r)βt(i,r)L\eta_i(r) = \sum_{t=1}^{T-1} \frac{\alpha_t(i,r)\beta_t(i,r)}{L}

Derivation of Δi(r)\Delta_i(r): Begin with:

P(X1:T,St=(i,r),St+1=(j,1))=αt(i,r)ωi,jci(r)bt+1(j,1)βt+1(j,1)\mathbb{P}(X_{1:T}, S_t = (i,r), S_{t+1} = (j,1)) = \alpha_t(i,r)\omega_{i,j}c_i(r)b_{t+1}(j,1)\beta_{t+1}(j,1)

We do not care which jj we jump to only that we left state ii, therefore we sum over j≠ij \ne i, finally summing over time and dividing by LL yields the expectation:

Δi(r)=∑t=1Tαt(i,r)ci(r)∑j≠iωi,jbt+1(j,1)βt+1(j,1)L=ci(r)∑t=1Tαt(i,r)Gt(i)L.\begin{aligned} \Delta_i(r) &= \sum_{t=1}^{T} \frac{\alpha_t(i,r)c_i(r)\sum_{j\ne i}\omega_{i,j}b_{t+1}(j,1)\beta_{t+1}(j,1)}{L} \\ &= c_i(r)\sum_{t=1}^{T} \frac{\alpha_t(i,r)G_t(i)}{L}. \end{aligned}

Derivation of N(i,j)N(i,j): It is easiest to immediately start by taking the expected value of N(i,j)N(i,j):

E[∑t=1T∑r=1mi1[St=(i,r),St+1=(j,1)]∣X1:T=x1:T]=∑t=1T∑r=1miP(St=(i,r),St+1=(j,1)∣X1:T=x1:T)\begin{aligned} \mathbb{E}\left[\sum_{t=1}^{T}\sum_{r=1}^{m_i}\mathbb{1}[S_t = (i,r), S_{t+1} = (j,1)]\mid X_{1:T} = x_{1:T}\right] \\ &= \sum_{t=1}^{T}\sum_{r=1}^{m_i}\mathbb{P}(S_t = (i,r), S_{t+1} = (j,1)\mid X_{1:T} = x_{1:T}) \end{aligned}
=∑t=1T∑r=1miP(St=(i,r),St+1=(j,1),x1:T)L=∑t=1T∑r=1miαt(i,r)ωi,jci(r)bt+1(j,1)βt+1(j,1)L=∑t=1Tωi,jbt+1(j,1)βt+1(j,1)Ft(i)L\begin{aligned} &= \sum_{t=1}^{T} \sum_{r=1}^{m_i} \frac{P(S_t = (i,r), S_{t+1} = (j,1), x_{1:T})}{L} \\ &= \sum_{t=1}^{T} \sum_{r=1}^{m_i} \frac{\alpha_t(i,r)\omega_{i,j}c_i(r)b_{t+1}(j,1)\beta_{t+1}(j,1)}{L} \\ &= \sum_{t=1}^{T} \frac{\omega_{i,j}b_{t+1}(j,1)\beta_{t+1}(j,1)F_t(i)}{L} \end{aligned}

Derivation of γt(i,r)\gamma_t(i,r): Corresponds to the regular EM update for a HMM except not we only focus on non zero entries using forward and backwards probabilities. Yielding:

γt(i,r)=αt(i,r)βt(i,r)L\gamma_t(i,r) = \frac{\alpha_t(i,r)\beta_t(i,r)}{L}

Throughout all the derivations above the forward and backwards passes produce α\alpha, β\beta, FF, and GG, which are used to create ηi(r)\eta_i(r), di(r)d_i(r), and N(i,j)N(i,j).

EM Pseudo Code

Algorithm 1 The THSMM EM algorithm

Require: Observations x1,…,xTx_1,\ldots,x_T; number of states KK; for each state ii a dwell-time family pi(⋅ ;ϕ)p_i(\cdot\,;\phi), aggregate size mim_i and emission functional f(⋅ ;θ)f(\cdot\,;\theta); tolerance ϵ\epsilon.

  1. Initialize δi\delta_i, ωi,j\omega_{i,j} (with ωi,i=0\omega_{i,i}=0), ϕi\phi_i, θi\theta_i for i,j=1,…,Ki,j=1,\ldots,K.

    Substates are pairs (i,r)(i,r) with r=1,…,mir=1,\ldots,m_i, and r+=min⁡(r+1,mi)r^+=\min(r+1,m_i).

  2. repeat ▹\triangleright iteration k=1,2,…k=1,2,\ldots

    Model quantities

  1. ci(r)←pi(r;ϕi)1−Fi(r−1;ϕi)c_i(r)\leftarrow\dfrac{p_i(r;\phi_i)}{1-F_i(r-1;\phi_i)} for r=1,…,mir=1,\ldots,m_i ▹\triangleright hazards, Eq. (2)

  2. ℓt(i)←log⁡f(xt;θi)\ell_t(i)\leftarrow\log f(x_t;\theta_i), Mt←max⁡iℓt(i)M_t\leftarrow\max_i\ell_t(i), b~t(i)←exp⁡{ℓt(i)−Mt}\tilde{b}_t(i)\leftarrow\exp\{\ell_t(i)-M_t\} ▹\triangleright offset emissions

    Forward pass

  1. α~1(i,r)←δib~1(i)1{r=1}\tilde{\alpha}_1(i,r)\leftarrow\delta_i\tilde{b}_1(i)\mathbf{1}\{r=1\}; u1←∑i,rα~1(i,r)u_1\leftarrow\sum_{i,r}\tilde{\alpha}_1(i,r); α^1←α~1/u1\hat{\alpha}_1\leftarrow\tilde{\alpha}_1/u_1

  2. for t=2,…,Tt=2,\ldots,T do

  3. F^t−1(i)←∑r=1miα^t−1(i,r)ci(r)\hat{F}_{t-1}(i)\leftarrow\sum_{r=1}^{m_i}\hat{\alpha}_{t-1}(i,r)c_i(r) ▹\triangleright exit flux, Eq. (13)

  4. α~t(j,1)←∑i≠jωi,jF^t−1(i)\tilde{\alpha}_t(j,1)\leftarrow\sum_{i\ne j}\omega_{i,j}\hat{F}_{t-1}(i), α~t(j,r)←0\tilde{\alpha}_t(j,r)\leftarrow0 for r>1r>1 ▹\triangleright enter jj

  5. α~t(j,r+)←α~t(j,r+)+α^t−1(j,r){1−cj(r)}\tilde{\alpha}_t(j,r^+)\leftarrow\tilde{\alpha}_t(j,r^+)+\hat{\alpha}_{t-1}(j,r)\{1-c_j(r)\} for all (j,r)(j,r) ▹\triangleright remain in jj

  6. α~t(j,r)←b~t(j)α~t(j,r)\tilde{\alpha}_t(j,r)\leftarrow\tilde{b}_t(j)\tilde{\alpha}_t(j,r); ut←∑j,rα~t(j,r)u_t\leftarrow\sum_{j,r}\tilde{\alpha}_t(j,r); α^t←α~t/ut\hat{\alpha}_t\leftarrow\tilde{\alpha}_t/u_t

  7. end for

  8. log⁡L(k)←∑t=1T(log⁡ut+Mt)\log L^{(k)}\leftarrow\sum_{t=1}^{T}(\log u_t+M_t) ▹\triangleright =log⁡P(x1:T)=\log P(x_{1:T})

    Backward pass β^T(i,r)←1\hat{\beta}_T(i,r)\leftarrow1 for all (i,r)(i,r)

  1. for t=T−1,…,1t=T-1,\ldots,1 do

  2. e^t(j)←b~t+1(j)β^t+1(j,1)ut+1\hat{e}_t(j)\leftarrow\dfrac{\tilde{b}_{t+1}(j)\hat{\beta}_{t+1}(j,1)}{u_{t+1}} ▹\triangleright value of entering jj

  3. G^t(i)←∑j≠iωi,je^t(j)\hat{G}_t(i)\leftarrow\sum_{j\ne i}\omega_{i,j}\hat{e}_t(j) ▹\triangleright exit value, Eq. (14)

  4. β^t(i,r)←{1−ci(r)}b~t+1(i)β^t+1(i,r+)ut+1+ci(r)G^t(i)\hat{\beta}_t(i,r)\leftarrow\{1-c_i(r)\}\dfrac{\tilde{b}_{t+1}(i)\hat{\beta}_{t+1}(i,r^+)}{u_{t+1}}+c_i(r)\hat{G}_t(i)

  5. end for

    Expected sufficient statistics

  1. ιt(i,r)←α^t(i,r)β^t(i,r)\iota_t(i,r)\leftarrow\hat{\alpha}_t(i,r)\hat{\beta}_t(i,r), ιt(i)←∑r=1miιt(i,r)\iota_t(i)\leftarrow\sum_{r=1}^{m_i}\iota_t(i,r) ▹\triangleright posterior occupancy

  2. ηi(r)←∑t=1T−1ιt(i,r)\eta_i(r)\leftarrow\sum_{t=1}^{T-1}\iota_t(i,r) ▹\triangleright expected visits

  3. Δi(r)←ci(r)∑t=1T−1α^t(i,r)G^t(i)\Delta_i(r)\leftarrow c_i(r)\sum_{t=1}^{T-1}\hat{\alpha}_t(i,r)\hat{G}_t(i) ▹\triangleright expected departures

  4. N(i,j)←ωi,j∑t=1T−1F^t(i)e^t(j)N(i,j)\leftarrow\omega_{i,j}\sum_{t=1}^{T-1}\hat{F}_t(i)\hat{e}_t(j) ▹\triangleright expected i→ji\to j jumps

    Maximization

  1. δi←ι1(i,1)\delta_i\leftarrow\iota_1(i,1); ωi,j←N(i,j)∑l≠iN(i,l)\omega_{i,j}\leftarrow\dfrac{N(i,j)}{\sum_{l\ne i}N(i,l)} for i≠ji\ne j ▹\triangleright ω\omega fixed when K=2K=2

  2. for i=1,…,Ki=1,\ldots,K do

  3. if pip_i is nonparametric then

  4. ci(r)←Δi(r)/ηi(r)c_i(r)\leftarrow\Delta_i(r)/\eta_i(r), r=1,…,mir=1,\ldots,m_i ▹\triangleright no tail: ci(mi)=1c_i(m_i)=1

  5. pi(r)←ci(r)∏s<r{1−ci(s)}p_i(r)\leftarrow c_i(r)\prod_{s<r}\{1-c_i(s)\}

  6. else if pip_i is geometric then

  7. ci←∑rΔi(r)∑rηi(r)c_i\leftarrow\dfrac{\sum_r\Delta_i(r)}{\sum_r\eta_i(r)}

  8. else

  9. ϕi←DwellScoring⁡(ϕi,Δi,ηi)\phi_i\leftarrow\operatorname{DwellScoring}(\phi_i,\Delta_i,\eta_i) ▹\triangleright Algorithm 2

  10. end if

  11. θi←arg⁡max⁡θ∑t=1Tιt(i)log⁡f(xt;θ)\theta_i\leftarrow\arg\max_\theta\sum_{t=1}^{T}\iota_t(i)\log f(x_t;\theta) ▹\triangleright Table B1

  12. end for

  13. until k>1k>1 and ∣log⁡L(k)−log⁡L(k−1)∣<ϵ(1+∣log⁡L(k)∣)\left|\log L^{(k)}-\log L^{(k-1)}\right|<\epsilon\left(1+\left|\log L^{(k)}\right|\right)

  14. return δ,ω,ϕ,θ\delta,\omega,\phi,\theta

EmissionFunctional and update
Brownian motion with drift; fractional BM (Hurst ν\nu)log⁡f(xt;θi)=θiSt−12θi2Q\log f(x_t;\theta_i)=\theta_iS_t-\frac{1}{2}\theta_i^2Q<br>θ^i=∑tιt(i)StQWi\hat{\theta}_i=\frac{\sum_t\iota_t(i)S_t}{QW_i}
Ornstein–Uhlenbeck, mean b0i/b1ib_{0i}/b_{1i}log⁡f(xt;θi)=b0iZt−b1iIt−12(b0i2sL−2b0ib1iMt(1)+b1i2Mt(2))\log f(x_t;\theta_i)=b_{0i}Z_t-b_{1i}I_t-\frac{1}{2}\left(b_{0i}^2s_L-2b_{0i}b_{1i}M_t^{(1)}+b_{1i}^2M_t^{(2)}\right)<br>b^1i=max⁡{0,Mˉ1Zˉ−sˉIˉsˉMˉ2−Mˉ12}\hat{b}_{1i}=\max\left\{0,\frac{\bar{M}_1\bar{Z}-\bar{s}\bar{I}}{\bar{s}\bar{M}_2-\bar{M}_1^2}\right\}<br>b^0i=Zˉ+Mˉ1b^1isˉ\hat{b}_{0i}=\frac{\bar{Z}+\bar{M}_1\hat{b}_{1i}}{\bar{s}}
Nonparametric mean μi∈H(γ)\mu_i\in H(\gamma)log⁡f(xt;θi)=−12∥xt−μi∥2\log f(x_t;\theta_i)=-\frac{1}{2}\lVert x_t-\mu_i\rVert^2<br>μ^i=∑tιt(i)xtWi\hat{\mu}_i=\frac{\sum_t\iota_t(i)x_t}{W_i}
Gaussian on R\mathbb{R}log⁡f(xt;θi)=−log⁡σi−(xt−μi)22σi2\log f(x_t;\theta_i)=-\log\sigma_i-\frac{(x_t-\mu_i)^2}{2\sigma_i^2}<br>μ^i=∑tιt(i)xtWi\hat{\mu}_i=\frac{\sum_t\iota_t(i)x_t}{W_i}<br>σ^i2=∑tιt(i)(xt−μ^i)2Wi\hat{\sigma}_i^2=\frac{\sum_t\iota_t(i)(x_t-\hat{\mu}_i)^2}{W_i}

Table B1. Weighted M-step updates θi=arg⁡max⁡θ∑t=1Tιt(i)log⁡f(xt;θ)\theta_i=\mathop{\arg\max}_{\theta}\sum_{t=1}^{T}\iota_t(i)\log f(x_t;\theta) in Algorithm 1, where Wi=∑t=1Tιt(i)W_i=\sum_{t=1}^{T}\iota_t(i). Each entry gives log⁡f(xt;θi)\log f(x_t;\theta_i) up to terms free of θi\theta_i, then the update.

Algorithm 2 Dwell-time M-step for a parametric family (Fisher scoring)

  1. function DWELLSCORING(ϕi\phi_i, Δi\Delta_i, ηi\eta_i)

  2. ψ←\psi\leftarrow unconstrained transform of ϕi\phi_i ▷ e.g. log⁡λ\log\lambda; shifts held fixed

  3. Let Qdwell,i(ψ)=∑r=1mi[Δi(r)log⁡h(r;ψ)+{ηi(r)−Δi(r)}log⁡{1−h(r;ψ)}]Q_{\mathrm{dwell},i}(\psi) = \sum_{r=1}^{m_i} \left[\Delta_i(r)\log h(r;\psi) + \{\eta_i(r)-\Delta_i(r)\}\log\{1-h(r;\psi)\}\right]

  4. for s=1,…,Ss = 1,\ldots,S do ▷ a few steps per EM iteration suffice

  5. hr,i←h(r;ψ)h_{r,i} \leftarrow h(r;\psi), h˙r,i←∂h(r;ψ)/∂ψ\dot{h}_{r,i} \leftarrow\partial h(r;\psi)/\partial\psi, for r∈R={r:ηi(r)>0, 0<hr,i<1}r \in\mathcal{R} = \{r:\eta_i(r)>0,\ 0<h_{r,i}<1\}

  6. U←∑r∈RΔi(r)−ηi(r)hr,ihr,i(1−hr,i)h˙r,iU \leftarrow\sum_{r\in\mathcal{R}} \frac{\Delta_i(r)-\eta_i(r)h_{r,i}}{h_{r,i}(1-h_{r,i})}\dot{h}_{r,i} ▷ score

  7. I←∑r∈Rηi(r)hr,i(1−hr,i)h˙r,ih˙r,iTI \leftarrow\sum_{r\in\mathcal{R}} \frac{\eta_i(r)}{h_{r,i}(1-h_{r,i})}\dot{h}_{r,i}\dot{h}_{r,i}^{\mathsf{T}} ▷ expected information

  8. Δψ←I−1U\Delta\psi\leftarrow I^{-1}U; λ←1\lambda\leftarrow1

  9. while Qdwell,i(ψ+λΔψ)<Qdwell,i(ψ)Q_{\mathrm{dwell},i}(\psi+\lambda\Delta\psi)<Q_{\mathrm{dwell},i}(\psi) do

  10. λ←λ/2\lambda\leftarrow\lambda/2 ▷ step-halving keeps EM monotone

  11. end while

  12. ψ←ψ+λΔψ\psi\leftarrow\psi+\lambda\Delta\psi

  13. end for

  14. return ϕi(ψ)\phi_i(\psi)

  15. end function

Curves are observed on a grid τ1<⋯<τL\tau_1<\cdots<\tau_L, with increments Δxt,k=xt(τk+1)−xt(τk)\Delta x_{t,k}=x_t(\tau_{k+1})-x_t(\tau_k). Brownian motion: ν=12−ν\nu=\frac{1}{2}-\nu, κ=Γ(ν+1)/Γ(2ν+1)\kappa=\Gamma(\nu+1)/\Gamma(2\nu+1), elapsed time sk=τk−τ1s_k=\tau_k-\tau_1, St=∑kgˉkΔxt,kS_t=\sum_k\bar{g}_k\Delta x_{t,k} with cell averages gˉk=κ(sk+1ν+1−skν+1)/((ν+1)(sk+1−sk))\bar{g}_k=\kappa(s_{k+1}^{\nu+1}-s_k^{\nu+1})/((\nu+1)(s_{k+1}-s_k)), and Q=κ2sL2ν+1/(2ν+1)Q=\kappa^2s_L^{2\nu+1}/(2\nu+1); for ν=12\nu=\frac{1}{2}, St=xt(τL)−xt(τ1)S_t=x_t(\tau_L)-x_t(\tau_1) and Q=sLQ=s_L. Ornstein–Uhlenbeck (left-point sums): Zt=∑kΔxt,kZ_t=\sum_k\Delta x_{t,k}, It=∑kxt(τk)Δxt,kI_t=\sum_kx_t(\tau_k)\Delta x_{t,k}, Mt(1)=∑kxt(τk)(τk+1−τk)M_t^{(1)}=\sum_kx_t(\tau_k)(\tau_{k+1}-\tau_k) and Mt(2)=∑kxt(τk)2(τk+1−τk)M_t^{(2)}=\sum_kx_t(\tau_k)^2(\tau_{k+1}-\tau_k); Zˉ,Iˉ,Mˉ1,Mˉ2\bar{Z},\bar{I},\bar{M}_1,\bar{M}_2 are their ιt(i)\iota_t(i)-weighted sums and sˉ=WisL\bar{s}=W_is_L. Nonparametric: the update is exact for the L2L^2, W02,1W_0^{2,1} and W02,2W_0^{2,2} norms (unique up to the null space of the latter two seminorms) and a heuristic for the sup norm.

Simulation Details

Pediatric Obstructive Sleep Apnea Details

Decoded state sequence from Viterbi algorithm for the THMM and THSMM

Figure D5. Decoded state sequence from Viterbi algorithm for the THMM and THSMM when c=1.0c = 1.0.

Decoded state sequence from Viterbi algorithm for the THMM and THSMM when $c = 0.3$

Figure D6. Decoded state sequence from Viterbi algorithm for the THMM and THSMM when c=0.3c = 0.3.

Decoded state sequence from Viterbi algorithm for the THMM and THSMM when $c = 0.1$

Figure D7. Decoded state sequence from Viterbi algorithm for the THMM and THSMM when c=0.1c = 0.1.

References

  1. [1]Baum, L.E., Petrie, T.: Statistical inference for probabilistic functions of finite state Markov chains. The annals of mathematical statistics 37(6), 1554–1563 (1966)DOI
  2. [2]Baum, L.E., Petrie, T., Soules, G., Weiss, N.: A maximization technique occurring in the statistical analysis of probabilistic functions of Markov chains. The annals of mathematical statistics 41(1), 164–171 (1970)DOI
  3. [3]Dempster, A.P., Laird, N.M., Rubin, D.B.: Maximum likelihood from incomplete data via the em algorithm. Journal of the Royal Statistical Society: Series B (Methodological) 39(1), 1–22 (1977)DOI
  4. [4]Wu, C.J.: On the convergence properties of the em algorithm. The Annals of statistics, 95–103 (1983)DOI
  5. [5]Ferguson, J.: Hidden markov analysis: an introduction. Proceedings of the Symposium on the Application of Hidden Markov Models to Text and Speech (1980)
  6. [6]Rabiner, L.R.: A tutorial on Hidden Markov Models and selected applications in speech recognition. Proceedings of the IEEE 77(2), 257–286 (1989)
  7. [7]Juang, B.H., Rabiner, L.R.: Hidden Markov models for speech recognition. Technometrics 33(3), 251–272 (1991)DOI
  8. [8]Liporace, L.A.: Maximum likelihood estimation for multivariate observations of Markov sources. IEEE Transactions on Information Theory 28(5), 729–734 (1982)DOI
  9. [9]Chatzis, S.P.: Hidden markov models with nonlinearly contoured state densities. IEEE transactions on pattern analysis and machine intelligence 32(12), 2297–2304 (2010)DOI
  10. [10]Altman, R.M.: Mixed hidden markov models: an extension of the hidden markov [11] Alexandrovich, G., Holzmann, H., Leister, A.: Nonparametric identification and maximum likelihood estimation for hidden markov models. Biometrika 103, 423–434 (2016) https://doi.org/10.1093/biomet/asw001
  11. [12]Gassiat, E., Rousseau, J.: Nonparametric finite translation hidden markov models and extensions. Bernoulli 22, 193–212 (2016) https://doi.org/10.3150/14-BEJ631
  12. [13]Martino, A., Guatteri, G., Paganoni, A.M.: Hidden markov models for multivariate functional data. Statistics & Probability Letters 167, 108917 (2020)DOI
  13. [14]Sidrow, E., Heckman, N., Fortune, S.M., Trites, A.W., Murphy, I., Auger-Méthé, M.: Modelling multi-scale, state-switching functional data with hidden markov models. Canadian Journal of Statistics (2021)DOI
  14. [15]Kashlak, A.B., Loliencar, P., Heo, G.: Topological hidden Markov models. Journal of Machine Learning Research 24(340), 1–49 (2023)arxiv.org/abs/2205.13608
  15. [16]Onsager, L., Machlup, S.: Fluctuations and irreversible processes. Phys. Rev. 91, 1505–1512 (1953) https://doi.org/10.1103/PhysRev.91.1505
  16. [17]Bogachev, V.I.: Gaussian Measures vol. 62. American Mathematical Society Providence, ??? (1998)
  17. [18]Langrock, R., Zucchini, W.: Hidden markov models with arbitrary state dwell-time distributions. Computational Statistics & Data Analysis 55(1), 715–724 (2011) https://doi.org/10.1016/j.csda.2010.06.015
  18. [19]Levinson, S.E.: Continuously variable duration hidden markov models for automatic speech recognition. Computer Speech & Language 1(1), 29–45 (1986) https://doi.org/10.1016/S0885-2308(86)80009-2
  19. [20]Yu, S.-Z.: Hidden semi-markov models. Artificial Intelligence 174(2), 215–243 (2010) https://doi.org/10.1016/j.artint.2009.11.011 . Special Review Issue
  20. [21]Sansom, J., Thomson, P.: Fitting hidden semi-markov models to breakpoint rainfall data. Journal of Applied Probability 38(A), 142–157 (2001) https://doi.org/10.1239/jap/1085496598
  21. [22]Bulla, J., Bulla, I.: Stylized facts of financial time series and hidden semi-markov models. Computational Statistics & Data Analysis 51, 2192–2209 (2006) https://doi.org/10.1016/j.csda.2006.07.021
  22. [23]Langrock, R., King, R., Matthiopoulos, J., Thomas, L., Fortin, D., Morales, J.M.: Flexible and practical modeling of animal telemetry data: hidden Markov models and extensions. Ecology 93(11), 2336–2342 (2012) https://doi.org/10.1890/11-2241.1
  23. [24]Yu, S.-Z.: Hidden Semi-Markov Models: Theory, Algorithms and Applications. Elsevier Academic Press, London, UK (2015)
  24. [25]Guédon, Y.: Estimating hidden semi-Markov chains from discrete sequences. Journal of Computational and Graphical Statistics 12(3), 604–639 (2003) https://doi.org/10.1198/1061860032030
  25. [26]Yu, S.-Z., Kobayashi, H.: An efficient forward-backward algorithm for an explicit-duration hidden markov model. IEEE Signal Processing Letters 10, 11–14 (2003) https://doi.org/10.1109/LSP.2002.806705
  26. [27]Bulla, J., Bulla, I., Nenadić, O.: hsmm — an r package for analyzing hidden semi-markov models. Computational Statistics & Data Analysis 54(3), 611–619 (2010) https://doi.org/10.1016/j.csda.2008.08.025 . Second Special Issue on Statistical Algorithms and Software
  27. [28]O’Connell, J., Højgaard, S.: Hidden semi markov models for multiple observation sequences: The mhsmm package for r. Journal of Statistical Software 39(4), 1–22 (2011) https://doi.org/10.18637/jss.v039.i04
  28. [29]Cox, D.R., Miller, H.D.: The Theory of Stochastic Processes. Chapman and Hall, London (1965)
  29. [30]Russell, M.J., Cook, A.E.: Experimental evaluation of duration modelling techniques for automatic speech recognition. In: Proceedings of the IEEE International Conference on Acoustics, Speech, and Signal Processing (ICASSP), pp. 2376–2379 (1987)DOI
  30. [31]Guédon, Y.: Hidden hybrid Markov/semi-Markov chains. Computational Statistics & Data Analysis 49(3), 663–688 (2005) https://doi.org/10.1016/j.csda.2004.05.033
  31. [32]Johnson, M.T.: Capacity and complexity of HMM duration modeling techniques. IEEE Signal Processing Letters 12(5), 407–410 (2005) https://doi.org/10.1109/LSP.2005.845598
  32. [33]Johnson, M.J., Willsky, A.S.: Bayesian nonparametric hidden semi-markov models. Journal of Machine Learning Research 14(20), 673–701 (2013)arxiv.org/abs/1203.1365
  33. [34]Kristensen, K., Nielsen, A., Berg, C.W., Skaug, H.J., Bell, B.: TMB: Automatic differentiation and laplace approximation. Journal of Statistical Software 70(5), 1–21 (2016) https://doi.org/10.18637/jss.v070.i05
  34. [35]Scrucca, L., Fop, M., Murphy, T.B., Raftery, A.E.: mclust 5: clustering, classification and density estimation using Gaussian finite mixture models. The R Journal 8(1), 289–317 (2016)pubmed.ncbi.nlm.nih.gov/27818791
  35. [36]Chalifour, M.: Comparison of sleep state classification performance using random forests, hidden markov models, and non-homogeneous hidden markov models. Master’s thesis, University of Alberta (2020)DOI
  36. [37]Zung, W.W.K., Naylor, T.H., Gianturco, D.T., Wilson, W.P.: Computer simulation of sleep eeg patterns with a markov chain model. In: Wortis, J. (ed.) Recent Advances in Biological Psychiatry: The Proceedings of the Twentieth Annual Convention and Scientific Program of the Society of Biological Psychiatry, New York City, April 30–May 2,1965, pp. 335–355. Springer, Boston, MA (1966). https://doi.org/10.1007/978-1-4899-7313-9_36
  37. [38]Yang, M.C., Hursch, C.J.: The semi-markov model for describing sleep patterns. Biometries 29(4), 667–676 (1973)pubmed.ncbi.nlm.nih.gov/4785232
  38. [39]Kemp, B., Kamphuisen, H.: Simulation of human hypnograms using a markov chain model. Sleep 9(3), 405–414 (1986) https://doi.org/10.1093/sleep/9.3.405
  39. [40]Penny, W.D., Roberts, S.J.: Gaussian observation hidden markov models for eeg analysis. Imperial College TR-98-12, London, UK, Tech. Rep (1998)
  40. [41]Flexerand, A., Dorffner, G., Sykacekand, P., Rezek, I.: An automatic, continuous and probabilistic sleep stager based on a hidden markov model. Applied Artificial Intelligence 16(3), 199–207 (2002) https://doi.org/10.1080/088395102753559271 https://doi.org/10.1080/088395102753559271
  41. [42]Flexer, A., Gruber, G., Dorffner, G.: A reliable probabilistic sleep stager based on a single eeg signal. Artificial Intelligence in Medicine 33(3), 199–207 (2005) https://doi.org/10.1016/j.artmed.2004.04.004
  42. [43]Doroshenkov, L., Konyshev, V., Selishchev, S.: Classification of human sleep stages based on eeg processing using hidden markov models. Biomedical Engineering 41(1), 25–28 (2007)pubmed.ncbi.nlm.nih.gov/17419342
  43. [44]Pan, S.-T., Kuo, C.-E., Zeng, J.-H., Liang, S.-F.: A transition-constrained discrete hidden markov model for automatic sleep staging. Biomedical engineering online 11(1), 52 (2012)DOI
  44. [45]Chen, Y., Zhu, X., Chen, W.: Automatic sleep staging based on ecg signals using hidden markov models. In: 2015 37th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC), pp. 530–533 (2015). IEEEDOI
  45. [46]Fischer, M., Kashlak, A.B., Chalifour, M., Heo, G.: Optimal semi-markov model selection for pediatric obstructive sleep apnea patient data. Data Analysis in the AI Era: Models, Methods and Techniques 14, 31–41 (2026)
  46. [47]Bulla, J.: Application of hidden markov models and hidden semi-markov models to financial time series. PhD thesis, Georg-August-Universität Göttingen, Göttingen, Germany (2006). https://doi.org/10.53846/geodiss-3687 . https://ediss.uni-goettingen.de/handle/11858/00-1735-0000-000D-F27C-7

Paper details

vlnc:W_au8cpt2s
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Mathematics

Not recorded for this paper

View statement
Looking for related papers…
Contents