December 5, 2017

Intro

We have eight years of monthly price data for nine passively-managed funds we're considering for our retirement portfolio. How might we use the historical data to determine the optimal investment allocation in each fund?

ticker style
VLCAX large cap blend
VVIAX large cap value
VBR small cap value
VGSLX real estate
EFV intl large value
SCZ intl small cap blend
VEMAX emerging mkts lg blend
SHV short term treasury
BWZ intl short-term treasury

Overview

  • Data Pull
  • Graphical Analysis
  • Global Minimum Variance Portfolio
  • Maximize Return Given Risk Appetite
    • Monte Carlo with Bootstrapping
    • Normally Distributed Returns
    • Linear Programming
    • Quadratic Programming

Data Retrieval

  • Used the quantmod package to access Yahoo! Finance price data.
  • getSymbols() retrieves historical prices.
  • adjustOHLC() adjusts raw price data for dividends and splits.
  • monthlyReturn() converts price data to monthly, percentage returns.

Price History

Monthly Returns

Risk vs. Reward

Correlations

Global Minimum Variance Portfolio

This is a problem with a non-linear objective and one equality constraint. We can solve analytically using method of Lagrange multipliers.

Define:
\(\sigma_{x,P}^2=\) portfolio variance
\(\mathbf{x}=\) vector of portfolio weights
\(\Sigma=\) covariance matrix
\(\lambda=\) Lagrange multipler

Objective:

\[\min_{\mathbf{x}}\sigma_{x,p}^2=\mathbf{x^T}\Sigma\mathbf{x~~\textrm{s.t.}~~\mathbf{x^T1}=1}\]

Set up the Lagrangian function as follows:

\[L(\mathbf{x},\lambda) = \mathbf{x^T}\Sigma\mathbf{x} + \lambda(\mathbf{x^T1}-1)\]

GMVP/cont

Take the partial derivatives with respect to each asset, \(x_i\) and set equal to zero:
\[0=\frac{\partial L}{\partial x_i}=2x_i\sigma_i^2 + 2\sum_{i \neq j}\sigma_{ij} + \lambda\] Also take the partial derivative with respect to \(\lambda\) and set equal to zero:

\[0 = \frac{\partial L}{\partial \lambda}=\mathbf{x^T1}-1\]
Solve 10 equations with 10 unknowns:

 VLCAX  VVIAX   VBR VGSLX   EFV    SCZ  VEMAX     SHV    BWZ lambda
 0.90% -0.65% 0.14% 0.02% 0.11% -0.11% -0.22% 100.11% -0.30% -0.00%

Solution implies shorting several assets–not realistic for retirement account.

Monte Carlo with Bootstrapping

  • Simulation using sampling with replacement.
    • Can't simulate each asset's returns independently because of strong pairwise correlations.
    • Solution: randomly sample from historical sets of monthly returns for all assets.
  • Obective: maximize return given upper bound on standard deviaton.
  • Nonlinear objective and nonlinear constraints.
  • Good brute force technique that requires minimal theory.
  • Enumerate over universe of possible weights. Keep universe small using simplying constraints.
    • Assume no asset gets more than 40% allocation.
    • assume discrete asset allocations in 10% increments(i.e. 0%, 10%, etc.).

MC / cont

\(\mathbf{\mu=}\) mean vector
\(\sigma_{p,x}=\) portfolio standard deviation, scalar
\(x_i=\) portfolio weight for asset \(i\)
\(S=\) constant, max allowed standard deviation

Objective:
\[\max_{\mathbf{x}}\mathbf{x^T\mu}\]
subject to
\[\sum_{i=1}^Nx_i=1\] \[0\le x_i\le0.4~\textrm{for all }i\] \[100x_i\bmod10=0~\textrm{for all }i\] \[\sigma_{p,x} \le S \]

MC Example Solution

Maximize return assuming s.d. \(\le\) 1.5%

$max_ret
[1] 0.003847719

$sd
[1] 0.01473267

$weights
VLCAX VVIAX   VBR VGSLX   EFV   SCZ VEMAX   SHV   BWZ 
  0.2   0.0   0.1   0.0   0.0   0.0   0.0   0.4   0.3 

MC Efficient Frontier

Normally Distributed Returns

New terms:
\(R_i=\) return for asset \(i\)
\(\mathbf{R}=\) vector of returns, all assets
\(\mu_{p,x}=\) mean portfolio return

Assume:
\[R_i \sim iid~ N(\mu_i,\sigma_i^2)\] \[cov(R_i,R_j) = \sigma_{ij}\]
Then the return of the portfolio is

\[\mu_{p,x}=E[\mathbf{x'R}]=\mathbf{x^T}E[\mathbf{R}]=\mathbf{x^T \mu}\]
The variance of the portfolio is:

\[\sigma^2_{p,x}=\mathbf{x^T}\Sigma\mathbf{x}\]

Normally Distributed Returns / cont

  • Assume individual assets are normally distributed random variables. Use historical historical means, variances as and covariances as parameter inputs.
  • No need for simulation, just calculated portfolio mean and variance given a set of weights.
  • Objective: maximize return given upper bound on standard deviation.
  • Same constraints used in MC problem.
  • Enumerate over universe of possible weights, using simplifying constraints.

Normal Returns Example Solution

Maximize return assuming s.d. \(\le\) 1.5%

$max_ret
[1] 0.003339794

$sd
[1] 0.01497017

$weights
VLCAX VVIAX   VBR VGSLX   EFV   SCZ VEMAX   SHV   BWZ 
  0.2   0.0   0.0   0.1   0.0   0.0   0.0   0.4   0.3 

Normal Returns Efficient Frontier

Linear Programming

  • Cannot use variance or standard deviation as constraint because non-linear.
  • Compromise: start with mean absolute deviation as constraint:
    \[\frac{1}{T}\sum_{t=1}^T\Big|\sum_ix_i\big(R_i(t)-\mu_i\big)\Big| \le M\textrm{ where M constant}\]

  • Break out constraint above to satisfy linearity requirement:
    \[\sum_ix_i\big(R_i(t)- \mathbf{\mu_i}\big) \le y_t \textrm{ for all }t\]
    \[\sum_ix_i\big(R_i(t)- \mathbf{\mu_i}\big) \ge -y_t \textrm{ for all }t\]

\[\frac{1}{T}\sum_{t=1}^{T}y_t \le M\textrm{ }\]

Linear Programming / cont

\[\max \mu_{p,x}= \sum_i x_i \mu_i\]
subject to
\[-y_t \le \sum_ix_i\big(R_i(t)- \mathbf{\mu_i}\big) \le y_t \textrm{ for all }t\]
\[\frac{1}{T}\sum_{t=1}^{T}y_t \le M\textrm{ }\]
\[\sum_{i}x_i = 1\]
\[0 \le x_i \le 0.4,~\textrm{for all }i,~~y_t \ge0,~\textrm{for all }t\]

Linear Programming Example

  • Maximize return assuming mean absolute deviation \(\le\) 1.5%.
  • Use lp() from lpSolve package.
$max_ret
[1] 0.006768058

$mad
[1] 0.015

$weights
VLCAX VVIAX   VBR VGSLX   EFV   SCZ VEMAX   SHV   BWZ 
 0.40  0.11  0.00  0.06  0.00  0.00  0.00  0.40  0.03 

Linear Programming Efficient Frontier

Quadratic Programming

  • Objective Function is quadratic; constraints are linear.
  • Maximize a combination of reward and risk by varying risk aversion parameter, \(q\).
  • \(q\) can vary from (0, \(\infty\)).
  • Use solve.QP from quadprog package.

Quadratic Programming / cont

Define:
\(q\ge 0\), constant

Objective:

\[\min~ \mathbf{x^T}\Sigma \mathbf{x} - q \mathbf{\mu^Tx}\]
subject to
\[\sum_{i}x_i = 1\]
\[0 \le x_i \le 0.4,~\textrm{for all }i\]

Quadratic Programming Example

Optimize with \(q = 0.5\).

$max_ret
[1] 0.01198807

$sd
[1] 0.03607641

$weights
VLCAX VVIAX   VBR VGSLX   EFV   SCZ VEMAX   SHV   BWZ 
  0.4   0.2   0.2   0.2   0.0   0.0   0.0   0.0   0.0 

Quadratic Programming Efficient Frontier

Conclusion

  • Investment science is field that relies heavily on optimization theory to make rational decisions.

  • There are often multiple approaches to a given optimization problem.