R Tutorial : Quantitative Risk Management in R

Alex McNeill introduces quantitative risk management in R using the QRM textbook and companion packages. The tutorial covers how to quantify portfolio risk across stocks, bonds, currencies, and commodities, then demonstrates loading and plotting S&P 500 data to show the 2008-2009 financial crisis drawdown. Exercises guide you toward computing Value-at-Risk for portfolios.
Chapters
Hello, my name is Alex McNeill and I'm going to take you through an introduction to Quantitative Risk Management. My background is in mathematical statistics, actuarial science and quantitative finance. Together with my colleagues Rudiger Frei and Paul Embrechts, I am the author of the book Quantitative Risk Concepts, Techniques and Tools published by Princeton University Press. If you want the theoretical background to this course, I recommend you take a look. Together with my co authors and with Marius Hofert, I've also created the website qrmtutorial.org which provides complementary materials to the QRM book. In particular, there's a lot of R code there which you might want to try after you've taken this course. Marius and I have two R packages which feature prominently in QRM Tutorial. These are QRM Data, which is a large collection of financial data sets for students and researchers in qrm, and QRM Tools, which is a set of useful functions. You'll use these packages in the course. In QRM, the goal is to quantify the risk of a portfolio of risky assets. Measuring the risk is the first step towards managing the risk. In the book I wrote, we consider the typical portfolios of risky assets held by banks and insurance companies, and sometimes also their liabilities. But the ideas apply equally to the portfolio of a private investor like you or me. Managing the risk can entail many things. For example, you might try to reduce the risk by selling assets, by acquiring new assets to increase the diversification of the portfolio, or by using so called hedging strategies. For the banks and insurers, an important part of managing risk is making sure they have sufficient capital to withstand large losses on their portfolios and remain solvent. For this purpose they compute measurements of the amounts that they could lose in periods of extreme market stress. A well known example of one of these risk measures is value at Risk. In this course you will work up to calculating value at risk for portfolios. To begin with, it is important to consider where the risk in a portfolio comes from. So think of a portfolio of risky assets. It might contain some stock index trackers, some individual stocks, some government bonds or Treasuries, some corporate bonds. It might contain assets denominated in domestic currency and some denominated in foreign currencies. It might contain commodities like gold. It might contain some derivative securities designed to hedge risk or speculate on price movements such as equity options. The value of this portfolio at any point in time depends on the fluctuating values of many underlying quantities, which we call risk factors. Examples of risk factors are equity indexes, individual equity prices, foreign exchange rates, interest rates for different borrowing periods in the case of bonds and commodity prices. Let's load the QRM data package and then the data set SP 500. This contains daily values of the well known equity index based on 500 of the most important US stocks. Using head and tail, the first few lines and the last few lines of the data can be displayed. Note the dates of the first few values in 1950 and the last few values up to the end of 2015. Let's plot the index. You can see it has generally gone up over time, but with some drawdowns, such as around the 2008-2009 financial crisis. Now it's your turn to work through the exercises and explore some financial risk factor data. You'll look at another stock index, some individual equity prices, and a couple of exchange rates.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







