State-space models (SSMs) with regime switching can efficiently identify recurring patterns of
variation and recurring dynamics in nonstationary multivariate time series. These models have
been successfully applied in various fields such as econometrics, signal processing, control
engineering, and object tracking. In this work we focus on the implementation of switching
SSMs in high dimension via the Expectation-Maximization (EM) algorithm. The EM algorithm
provides a relatively simple way to compute the maximum likelihood estimator (MLE) of the
model parameters. However, in switching SSMs, exact calculations are intractable as they grow
exponentially with the time series length. Even approximate calculations are burdensome with
high dimensional data. In addition, the EM algorithm has a tendency to get stuck in non-optimal
stationary points of the likelihood function, a tendency further compounded in high-dimension.
Considering two common switching SSMs, one with switching dynamics and the other with
switching observation process, we make several practical contributions: 1) we propose novel
robust initialization methods for the EM algorithm, 2) we develop a parametric bootstrap
procedure for statistical inference, 3) we provide an efficient implementation of the EM
algorithm for all discussed models in a comprehensive MATLAB package publicly available at
https://github.com/ddegras/switch-ssm. These contributions make it possible to reliably
calculate the MLE in a reasonable time, even with very long and/or high-dimensional time
series. We evaluate the statistical performance of the MLE in a simulation study and compare it
to a popular alternative approach (sliding windows correlation followed by k-means clustering).
We also present applications to the study of dynamic functional connectivity in large
electroencephalography (EEG) datasets.