Using Value-at-Risk and Expected Tail Loss Packages in R.

Alec Wright
3 min readJan 11, 2022

An Important Error to Look Out for During Analysis

Authors: Vivian Wang, Alec Wright

A Tale of Two VaRs

Anyone performing quantitative analysis on financial data will have encountered the metrics Value-at-Risk and Expected Tail Loss. These provide a quick and effective synopsis of the left tail data distribution and simulate what a “Xth” percentile worst day looks like. They are commonly referred to as ‘downside risk’ and used to protect against or prepare for what a strategy’s worst days will look like.

As is common when working with R, it is often more efficient to see if anyone online has written a package that performs the tasks you need done, rather than trying to write the code from scratch. When working on real estate analysis with my colleague we ran into a peculiar issue that typically doesn’t arise when working with equity data; some of the data timespans we analyzed had no negative values. The performanceanalytics package is often used for quantitative financial analysis within R, and we used the ETL() and VaR() functions within the package for our analysis. The package automatically removes all positive VaR’s and ETL’s.

Here is an example using the performanceanalytics functions.

Performance Analytics Value at Risk from Jan 2020 to June 2021

Here is our output with the recreated VaR and ETL functions using percentiles.

Custom Value at Risk (percentiles) from Jan 2020 to June 2021

While Value at Risk is typically used in a downside loss context (hence the ‘risk’ part), we believe that there are instances in which showing positive VaR gives valuable insights. For example, when looking at the original display in our real estate price analysis, many states are left out. This is a misleading graphic because it implies that either more than half the states are missing data for this time frame, or only negative values are worth observing. Viewing the full scope of the data is essential because of the story that it tells.

In our case, the full scope VaR shows us that the worst 5% of months over this timespan were harsh in equity markets, but in over half of the states in the USA, housing prices actually experienced only positive returns. This implies a growing bubble in the post covid housing markets in many states, and also directly shows the hottest housing markets in states such as Utah, Arizona, Idaho and others that experienced an influx as people bid up prices to escape from the cities during the pandemic. This is a hard insight to derive without seeing the whole spectrum of data.

Conclusions

Data is only as powerful as the actionable insights that are drawn from it. Amazingly rich data can be ruined by poor analysis, and incorrect conclusions can be drawn simply by the method of display. It is our duty as data analysts to make sure that our data visualizations are honest and give the full picture of what the data is telling us. When working with downside risk in the future, we will always make sure to ask ourselves whether it makes sense to focus only on the downside, or if there is an important story to tell with positive values as well.

--

--

Alec Wright

Master’s in Quantitative Management Student at the Fuqua School of Business