Disclaimer: The content of this RMarkdown note came from a course (chapter 2) called Introduction to Portfolio Analysis in R in datacamp.

Balancing risk and reward

A risk-averse investor would prefer an investment that has the highest average return with the lowest volatility.

Non-normality of the return distribution

  1. When we use the standard deviation as a measure of risk, we assume that portfolio returns have a normal distribution. It means that large gains (positive extremes) are as equally likely as large losses (negative extremes) of the same magnitude.
  2. In reality, returns are skewed to the left with fatter tails: negative returns are more likely.
  3. Hence, need for additional risk measures.
    • Semi-deviation, Value at risk, and 5% expected short fall
  4. Additional measures
    • Skewness, kurtosis
  5. measure of the worst case risk
    • the portfolio’s drawdowns, or peak-to-trough decline in cumulative returns.
    • The metrics discussed above do not do a great job at describing the worst case risk of buying at a peak, and selling at a trough.

Detecting non-normality using skewness and kurtosis

Two metrics key to understanding the distribution of non-normal returns:

  • Skewness (is it symmetric?)
  • Excess kurtosis (does it have fat-tails?)

Skewness

  • Zero: symmetric
  • Negative: large negative returns occur more often
  • Positive: large positive returns occur more often

Kurtosis

  • Zero: normal distribution
  • Greater than zero: large returns of both positive and negative occur more often
# Load packages  
library(PerformanceAnalytics)
library(quantmod)
library(xts)

Alternative 2: Import data with getSymbols()

data.MSFT <- getSymbols("MSFT", from = "1985-12-31", to = "2016-08-01", auto.assign = FALSE)

sp500_monthly <- to.monthly(data.MSFT, indexAt = "startof") 
# to.monthly documentation https://www.rdocumentation.org/packages/xts/versions/0.10-0/topics/to.period
sp500_monthly <- sp500_monthly[, "data.MSFT.Adjusted"]
head(sp500_monthly)
##            data.MSFT.Adjusted
## 1986-03-13           0.063419
## 1986-04-01           0.074373
## 1986-05-01           0.080715
## 1986-06-02           0.070914
## 1986-07-01           0.065725
## 1986-08-01           0.065725

Measure Skewness and Kurtosis

# Calcuate net returns
sp500_monthly <- Return.calculate(sp500_monthly)
sp500_monthly <- sp500_monthly[-1, ]
colnames(sp500_monthly) <- "sp500"
head(sp500_monthly)
##                   sp500
## 1986-04-01  0.172724262
## 1986-05-01  0.085272881
## 1986-06-02 -0.121427244
## 1986-07-01 -0.073173139
## 1986-08-01  0.000000000
## 1986-09-02 -0.008763789

#  Compute the skewness  
skewness(sp500_monthly)  
## [1] 0.67842

# Compute the excess kurtois
kurtosis(sp500_monthly)
## [1] 2.413123

Interpreation

  • Interpretation: The skewness is positive .68 and the kurtosis is 2.41. The large positive kurtosis would mean that there would be large returns of both positive and negative occurring more often. The positive skewness would mean there would be large positive returns occurring more often as well. No, this is not a normal distribution of returns.

Downside risk measures

When the return distribution is asymmetric (skewed), investors use additional risk measures that focus on describing the potential losses.

  • Semi-deviation: the variability of returns below the mean return
  • Value-at-Risk (or VaR): the 5% quantile of the return distribution, meaning that a more negative return can only happen with a probability of 5%. For example, you might ask: “what is the largest loss I could potentially take within the next quarter, with 95% confidence?”
  • Expected Shortfall: the average of the 5% (p = 0.05) or 2.5% (p = 0.025) most negative returns
# Calculate the SemiDeviation
SemiDeviation(sp500_monthly)
##                     sp500
## Semi-Deviation 0.06663768

# Calculate the value at risk
VaR(sp500_monthly, p = 0.025)
##          sp500
## VaR -0.1534668
VaR(sp500_monthly, p = 0.05)
##          sp500
## VaR -0.1185257

# Calculate the expected shortfall
ES(sp500_monthly, p = 0.025)
##         sp500
## ES -0.1534668
ES(sp500_monthly, p = 0.05)
##         sp500
## ES -0.1431922

Interpreation

  • Semi-Deviation of 0.067 means that the standard deviation of returns below the mean return is 0.067.
  • VaR of - 0.119 means that – 11.9 % is the largest loss one could expect with 95% confidence. Is it possible that you could lose more than 11.9%? Yes. What’s the odd? 5%. In other word, a more negative return can only happen with a probability of 5%.
  • ES of – 0.143 means that – 14.3% is the average of the 5% (p = 0.05) most negative returns.

Drawdowns due to buying high, selling low

The volatility, semi-deviation, value-at-risk, and expected shortfall are all measures that describe risk over 1 period. These metrics do not do a great job at describing the worst case risk of buying at a peak, and selling at a trough. This sort of risk can be quantified by analyzing the portfolio’s drawdowns, or peak-to-trough decline in cumulative returns.

The function table.Drawdowns() in PerformanceAnalytics reports the five largest drawdown episodes over a sample period. The package also has another function chart.Drawdown() to visualize the evolution of the drawdowns from each peak over time.

# Table of drawdowns
table.Drawdowns(sp500_monthly)
##         From     Trough         To   Depth Length To Trough Recovery
## 1 2000-01-03 2009-02-02 2014-07-01 -0.6670    175       110       65
## 2 1987-10-01 1987-11-02 1988-06-01 -0.3245      9         2        7
## 3 1988-07-01 1988-11-01 1989-09-01 -0.2948     15         5       10
## 4 1992-12-01 1993-07-01 1994-05-02 -0.2054     18         8       10
## 5 1986-06-02 1986-09-02 1986-10-01 -0.1929      5         4        1

# Plot of drawdowns
chart.Drawdown(sp500_monthly)

Interpreation MSFT: * The worst cumulative loss from peak value happened over the 110-months period from January 2000 to February 2009. * The asset lost more than half of its value during the period. * It took 65 months to recover to the previous peak value.

Interpretation of which is better - S&P500 or MSFT: Microsoft would be riskier than S&P 500 during the period because there are greater negative returns possible with a positive skewness and a large positive kurtosis. Looking at our other measures, you will see that the SD is also higher for MSFT.

MSFT: Value at risk - -11.8% - one should greater loss from MSFT because their vaR is almost 4% higher than the loss you could expect from GSPC. Expected shortfall- -14.3% - the average of most negative returns is almost 3% higher than the average negative return one could receive from GSPC.

GSPC: Vale at risk - -7.1% Expected shortfall- -11.8%

When examining the drawdowns you will see the MSFT experiences a much deeper trough that lead to a loss of over half their value. On the other hand S&P500 lost around half of their value during their trough which is less than MSFT. Lastly, MSFT recovery period is longer than S&P500.