# State-Space Regime Switching

Gibbs sampling for regime switching analysis of financial time series.

At the beginning of my adventure in the mathematical world I worked with Professor Luca di Persio in the field of mathematical finance.

We investigated the usability of stochastic regime switching models in the analysis of the U.S. stock market in the 2007-2014 period. In particular, we formulated a general switching-mean and switching-variance model which defines the volatility of the time series is treated as a state variable in order to describe the abrupt changes in the behaviour of financial time series whichcan be implied, e.g., by social, political or economic factors. The model reads as follows

\[\begin{cases} y_t = \mu_{S_t} + \epsilon_t, \quad t=1,2,\dots,T\\ \epsilon_t = \text{i.i.d. }\mathcal{N}(0,\sigma_{S_t}^2),\\ \mu_{S_t} = \mu_1 S_{1,t} + \mu_2 S_{2,t} + \mu_3 S_{3,t} + \mu_4 S_{4,t},\\ \sigma_{S_t} = \sigma_1 S_{1,t} + \sigma_2 S_{2,t} + \sigma_3 S_{3,t} + \sigma_4 S_{4,t},\\ S_t \in \left\{1,2,3,4\right\}\\ p_{ij} = \mathbb{P}\left(S_t=j | S_{t-1}=i\right) \quad i,j=1,2,3,4. \end{cases}\]and we employed it in the estimation of the volatility (Std) of the S&P500 index, comparing the obtained result against the VIX.