Chapter 9 Composite time series models

9.1 Markov switching models

Following the definitions of autoregressive models and hidden Markov models, a natural extension is a combination of both: a time-series model where the observed variable \(y_t\) is explained by a hidden state \(x_t\) and by a regression of its own previous value \(y_{t-1}\). These models are called autoregressive hidden Markov models (AR-HMM) (Murphy (2002)) or Markov switching models (MSM) (Wolf et al. (2019)).

Markov switching model

Figure 9.1: Markov switching model

Similar to an HMM, an MSM is defined by a matrix of transition probabilities \(\left(a_{ij}(t)\right) = p\left(z_t=j |z_{t-1}=i\right)\) whose terms can be conditioned on explanatory variables (time, day, weather…) and by emission probabilities. Rather than being only conditioned on \(x_t\), the emission probability can be a function of previous observations. This is an example of AR(1) process: \[\begin{equation} p(y_t | z_t=j) = \alpha_j + \phi_j y_{t-1} + w_{t,j} \tag{9.1} \end{equation}\] where the intercept \(\alpha_j\), slope \(\phi_j\) and noise \(w_{t,j}\) depend on the state \(z_t\), and may have as many different values as the number of possible states. In a more complicated example, one could implement a whole ARMAX model (Eq. (7.3)) into the observation probability of a Markov switching model.

An MSM can be trained with the same Baum-Welch algorithm and decoded with the same Viterbi algorithm as an HMM. The only difference is in the expression of the emission probabilities, which do not change the structure of the algorithms because \(y_t\) is conditionally independent on \(x_{t-1}\) given \(x_t\) and \(y_{t-1}\).

9.2 Hidden Markov energy signature

Another extension of the HMM structure was proposed by the author (Rouchier (2022)) and called hidden Markov energy signature model. It is a HMM where the emission probability functions are energy signature (ES) models (see chapter 5):

  • The energy use \(y_t\) of a building at time \(t\) follows a different ES model for each possible occupancy state \(z_t \in \left[1,...,K\right]\). This is how we allow the parameters of the ES model \(\left\{E_0, T_1, T_2, H_1, H_2, \sigma\right\}\) to depend on the occupancy. \[\begin{equation} b_{i}(y_t) = p(y_t|\theta, T_a, z_t=i) = N\left[E_{0,i} + H_{1,i}\left(T_{1,i}-T_a\right)^+ + H_{2,i}\left(T_a-T_{2,i}\right)^+, \sigma_i \right] \tag{9.2} \end{equation}\]
  • The occupancy state at each time \(t\) is unknown, and described by a hidden Markov chain. We define a transition probability matrix for each hour of the day \(h\) and day of the week \(d\) \[\begin{equation} a_{ij}(h,d)=p\left(z_{h,d}=j |z_{h-1,d}=i\right) \tag{9.3} \end{equation}\]

This formulation can be described as follows: at every hour \(h\) and day \(d\), the building has a probability \(a_{ij}(h,d)\) to switch from the occupancy state \(i\) to state \(j\). Then, if the building is in the occupancy state \(i\), then its energy use follows one of \(K\) possible ES models \(b_i(y_t)\).


Murphy, Kevin Patrick. 2002. “Dynamic Bayesian Networks: Representation, Inference and Learning.”
———. 2022. “Bayesian Workflow and Hidden Markov Energy-Signature Model for Measurement and Verification.” Energies 15 (10): 3534.
Wolf, Sebastian, Jan Kloppenborg Møller, Magnus Alexander Bitsch, John Krogstie, and Henrik Madsen. 2019. “A Markov-Switching Model for Building Occupant Activity Estimation.” Energy and Buildings 183: 672–83.