# Identify different periods of variance in a time series

I have a time series $x_t$ which may go through different phases of volatility. One example might be some stock that has high variance from 9 AM to 11 AM, low variance from 11 AM to 2 PM, and then high variance again afterwards. Is there a way to identify these different periods of variance?

I am thinking of taking a sliding window of length $L$, computing the variance in that window and running change point detection on that, but I think this requires me to know the distribution of the estimated variance. Another idea I had was to take the variance of the windows and try to fit a Markov chain to it, but I don't know beforehand how many states there should be.

Sorry, the motivating example is not just in finance. I would like to have a way to model "risk" in a time series, which might be risk associated with a financial asset. Another example is in wind energy production - energy produced from wind turbines is highly volatile and unpredictable, but it would be nice to have a learning algorithm that could identify what days of the month is variance of wind energy production high and when is it low

• You can fit a Markov Regime-switching model and test for the number of states. I have also heard good things about autoregressive conditional duration, but am not that familiar with the ins and outs of high frequency analysis. This question would also be appropriate at quant.stackexchange.com. – John Sep 18 '12 at 4:23
• One quick dirty fix would be to square centered time series and then test for changes in mean. – mpiktas Sep 18 '12 at 6:12
• I like mpiktas' suggestion which I think should be an answer. +! for an interesting question. It does seem that you are looking for changes in variance that make the series non-stationary. As you point out formal hypothesis testing requires knowledge of the null distribution for the estimated variance. This would seem to apply to mpiktas' approach too. – Michael Chernick Sep 18 '12 at 10:39
• @mpiktas sorry what do you mean by square centering a time series? And would I test for changes in mean using a change point detection? – JCWong Sep 18 '12 at 23:37

Suppose your initial data is $X_i$, then define $Y_i=(X_i-\mu)^2$, where $\mu$ is the mean. Then the change in mean of $Y_i$, $EY_i=E(X_i-\mu)^2=Var(X_i)$ will be a change of variance in $X_i$.
The changepoint package in R has a cpt.var function that can calculate changes in variance. There are two tests in that function one for data that can be assumed to be Normal distributed (default option dist="Normal") and one for nonparametric testing (option dist="CSS"). The CSS approach is Cumulative Sum of Squares and is detailed in Inclan & Tiao (1994) paper - further details in ?cpt.var.