Get startedGet started for free

Analyzing volatility

1. Analyzing volatility

Hi, and welcome to the course on GARCH models in R. On Wall Street "there are old traders, and bold traders, but there are very few old bold traders". That's because the bold traders suffer large losses when ignoring the risk of their investments.

2. About the instructor

My name is Kris Boudt. My goal is to give you a hands on experience in using GARCH models in R. I have a PhD on forecasting financial risk and use GARCH models to win by not losing much. My favorite R package is the rugarch package of Alexios Ghalanos which will be the workhorse for the entire course.

3. Calculating returns

To get started, you need returns. Take for example the price of a stock and denote this by capital P. Its daily return equals today's price minus yesterday's price, divided by yesterday's price. The CalculateReturns function in the package PerformanceAnalytics makes it easy to compute those returns. It takes the price series as an input, and provides you the corresponding returns.

4. Daily S&P 500 returns

In case of the S&P 500 you can see that the average daily return is close to zero, and that its variability changes over time. There are periods with a low variability, and periods with a high variability. You can quantify this variability by computing the return standard deviation. Investors call this the return volatility and denote it by the Greek character sigma with the index t to emphasize that its value changes every day.

5. Standard deviation and likelihood of making large losses (and gains)

You need to take those changes into account, since they heavily influence the probability of losing money. The plot shows this by comparing the return distribution on a turbulent day in blue with the distribution on a calm day in red. On a calm day, there is almost no chance of losing more than 5%, but on a turbulent day it becomes likely to lose more than 5%.

6. How to estimate return volatility

Getting the volatility right is thus of utmost importance. You can estimate the return standard deviation in R by applying the function sd() to the return series. For the daily S&P 500 returns this gives you a daily volatility of around 1%. The underlying formula is that the standard deviation equals the square root of the average squared deviation of the return from its mean.

7. Annualized volatility

Financial traders annualize the daily volatility by multiplying it with the square root of the number of trading days in a year, namely 252. This gives you the standard deviation you can expect on yearly returns. For the S&P 500, you get a 17% annualized volatility.

8. Dynamics of the return distribution

When you compute this annualized standard deviation on subsamples of one year, you get different numbers through time: they vary between a low of 7% and high of 41%.

9. Rolling volatility estimation

In a similar fashion, you can compute volatility on rolling estimation samples. You then roll the sample through time by adding the most recent observation and removing the most distant one. A practical question is then to choose the length of the estimation window. Typically the window length is a multiple of 22, which is the number of trading days in a month.

10. Function chart.RollingPerformance()

In R you can do this rolling calculation with the function chart-dot-RollingPerformance. As arguments, it requires the return series, the size of the window, the estimation function and the number of trading days in a year.

11. Rolling window volatility

You see here the corresponding rolling volatility estimates. Note the switches between periods of low and high volatility.

12. About GARCH models in R

This rolling approach is too simple in practice. You will later discover that a higher accuracy is achieved when using a GARCH model.

13. Let's refresh the basics of computing rolling standard deviations in R

But first, we refresh the basics of estimating standard deviations in R.