Making Smart Beta Portfolios in R


Here we explore smart beta and how to build portfolios which implement smart beta in R. Smart beta is what people call algorithms that construct portfolios that are intended to beat market cap weighted benchmarks without a human selecting stocks and bonds. So we will begin by explaining what market cap benchmarks do, what is meant by alpha and beta, then show how to easily build smart beta portfolios in R.

Using ETFs it is now possible to track whole stock markets, so if you buy the ETF called SPY you would be buying a portfolio containing the largest 500 stocks in the US. Alternatively you could try and earn a return that is higher than the market, or pay a fund manager to do so, and the margin by which they beat the market is called alpha. Another pair of words that describe these two approaches is active and passive investing: active means a team of humans is paid to beat an index like the S&P 500, and passive means you just buy and track the S&P 500.

Passively tracking a market is easy, you simply buy a portfolio of assets that match the weights of a stock market index. Consistently outperforming the market and generating alpha is extremely difficult. Few active fund managers outperform the index by more than their fees. For example see page 4 of this report by S&P that systematically tracks fund performance. They find underperfomance over the past 10 years in 98.9% of US equity funds, 97% of emerging market funds and 97.8% of global equity funds. Funds that track markets such as ETFs are beta strategies and earn small fees, usually less than 0.4% of your investment per year, whereas funds that pay humans to try to beat markets by generating alpha charge high fees, often 1% per year or higher.

The words alpha and beta come from the capital asset pricing model from which we get this simple equation relating expected asset return to a constant, \(\alpha\) plus \(\beta\) times market excess return above the risk-free rate which is usually taken to be government bond yield.

\(\mbox{expected asset return} = \alpha + \beta \times (\mbox{expected market return} – \mbox{risk free rate})\)
 
The aim of smart beta is to generate alpha cheaply. For example instead of buying an S&P 500 ETF you buy a low-volatility portfolio of stocks in the S&P 500. Instead of weighting the ownership of each stock by market capitalization (share price times the number of shares) this “smart beta” low volatility ETF would choose weights such that the daily combined return is diversified. There are several variants of smart beta and these might include:

  • Low volatility: weights chosen such that the overall volatility of the portfolio is as low as possible.
  • Momentum: trend-following strategy where weights favour assets where prices are rising assuming the trend will continue.
  • Value: weights are highest for cheap assets where cheapness is measured using fundamental valuation measures.
  • Risk parity: each asset contributes the same way to portfolio volatility.

The three flavours of smart beta that we touch on here are minimum variance, maximum Sharpe and risk parity. Minimum variance and maximum Sharpe are based on the idea of the efficient frontier and are the portfolios with the smallest possible risk and maximum possible risk-adjusted return. The idea behind risk parity is that portfolio weights are chosen such that each allocation contributes an equal amount of total risk to the portfolio (see here for a nice description).

For the ETF assets we are about to consider the risk and return since 2012 are plotted on the x-axis and y-axis of this plot. Equities tend to have higher risk and higher return (lie toward the upper-right part of the plot) while fixed income carries lower volatility and lower return (bottom left hand of the plot). The blue line is the efficient frontier which, for a given return y-value (think of a horizontal line of equal return on the plot) combines the asset weights to attain the minimum risk (minimum x-value). The black dots on the efficient frontier are the minimum variance portfolio, which is the portfolio with the lowest possible volatility, and the tangency portfolio (or maximum Sharpe ratio portfolio) which has the greatest risk-adjusted excess return.

EfficientFrontier

This code downloads the ETF price data.

Minimum variance portfolio

For the minimum variance portfolio the marginal risk contribution for each asset is equal. If the portfolio volatility is \(\sigma\), the weight assigned to asset \(i\) and \(j\) are \(w_i\) and \(w_j\) then

\(\frac{\partial \sigma}{\partial w_i}=\frac{\partial \sigma}{\partial w_j}\)

Using the PortfolioAnalytics library we build our portfolio constraints such that our portfolio is fully invested (if we have £100 to spend this is fully invested in assets) and long only (no short positions) and we use mean historic return to gauge future return and historic volatility to gauge future risk.

Maximum Sharpe ratio portfolio

One interpretation of the Sharpe ratio portfolio (alternatively called the tangency portfolio) is Sharpe parity. The weights are such that each asset’s ratio of marginal excess return \(\frac{\partial \mu}{\partial w_i} – r\) to marginal risk \(\frac{\partial \sigma}{\partial w_i}\) is equal to that of the portfolio. Here \(r\) is the risk free rate, and \(\sigma\) is the portfolio volatility.

\(\frac{\frac{\partial \mu}{\partial w_i} – r}{\frac{\partial \sigma}{\partial w_i}} = \frac{\mu – r}{\sigma}\)

In matrix notation the maximum Sharpe portfolio is calculated in terms of the asset covariance matrix \(\Sigma\), asset expected return \(\mu\) and risk-free rate \(r\) as follows. This will also have negative weights, so to ensure the portfolio is long-only you have to set the negative weights to zero and re-normalize the weights (so they add up to one).

\(\frac{\Sigma ^ {-1}(\mu – r)}{1^T \Sigma ^ {-1}(\mu – r)}\)

Risk parity portfolio

Risk parity refers to the equality (parity) of the total risk contribution of each asset. If the weight of asset i is \(w_i\) then the total risk contribution is the product of weight \(w_i\) and the marginal risk contribution \(\frac{\partial \sigma}{\partial w_i}\), where \(\sigma\) is portfolio volatility. In summary:

\(w_i \frac{\partial \sigma}{\partial w_i} = w_j \frac{\partial \sigma}{\partial w_j}\)

where the marginal risk contribution is the matrix product of the covariance matrix and portfolio weights scaled by portfolio volatility

\(\frac{\partial \sigma}{\partial w_i} = \frac{\Sigma w}{\sqrt{w^T \Sigma w}}\)

We can compare minimum variance, maximum Sharpe and risk parity weights. Notice that the minimum variance portfolio tends to assign high weights to low volatility assets i.e. fixed income, and in particular UK government bonds (IGLT.L) which make up almost 2/3 of the portfolio. UK corporate credit (SLXX.L) gets about a fifth of the portfolio. Amongst equities only the FTSE gets significant weight of 14%. The maximum Sharpe portfolio has a slightly higher risk appetite with a heavy 79% weighting in UK corporate bonds and 18% in the Eurostoxx 50 (CSX5.L).