<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/parametric-portfolio-policies/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://insightr.wordpress.com/2018/02/12/parametric-portfolio-policies/"> R – insightR</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p><strong>By Gabriel Vasconcelos</strong></p>
</div>
<h2>Overview</h2>
<p>There are several ways to do portfolio optimization out there, each with its advantages and disadvantages. We already discussed some techniques <a rel="nofollow" href="https://insightr.wordpress.com/2017/06/22/online-portfolio-allocation-with-a-very-simple-algorithm/" target="_blank">here</a>. Today I am going to show another method to perform portfolio optimization that works very well in large datasets because it produces very robust weights, which results in a good out-of-sample performance. This technique is called Parametric Portfolio Policies (PPP) and it was proposed by Brandt, Santa-Clara and Valkanov in 2009 (click <a rel="nofollow" href="https://academic.oup.com/rfs/article-abstract/22/9/3411/1572695" target="_blank">here</a> to read the full article).</p>
<p><span></span></p>
<p>A portfolio is a set of weights <img alt="w_{i,t}" title="w_{i,t}" src="https://s0.wp.com/latex.php?latex=w_%7Bi%2Ct%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> that states the proportion of wealth in asset <img alt="i" title="i" src="https://s0.wp.com/latex.php?latex=i&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> as time <img alt="t" title="t" src="https://s0.wp.com/latex.php?latex=t&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">. For example, in a Markowitz portfolio we get <img alt="w_{i,t}" title="w_{i,t}" src="https://s0.wp.com/latex.php?latex=w_%7Bi%2Ct%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> by minimizing the portfolio variance subject to some target return. This is like estimating one weight for each asset if you think of weights as parameters of a model. If you have 1000 assets you will have to estimate 1000 parameters. Naturally, you can’t expect a good out-of-sample performance from a simple Markowitz portfolio with 1000 assets just as you can’t expect a good performance from a simple regression with 1000 variables. The Parametric Portfolio Policy (PPP) is made exactly to this high-dimensional case. It parametrizes the weights on some asset characteristics in a way that we have to estimate only one parameter for each characteristic. Consider the following portfolio policy:</p>
<p><img alt="displaystyle w_{i,t} = bar{w}_{i,t} + frac{1}{N_t}theta'hat{x}_{i,t}" title="displaystyle w_{i,t} = bar{w}_{i,t} + frac{1}{N_t}theta'hat{x}_{i,t}" src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+w_%7Bi%2Ct%7D+%3D+%5Cbar%7Bw%7D_%7Bi%2Ct%7D+%2B+%5Cfrac%7B1%7D%7BN_t%7D%5Ctheta%27%5Chat%7Bx%7D_%7Bi%2Ct%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p>Here, the portfolio <img alt="w_{i,t}" title="w_{i,t}" src="https://s0.wp.com/latex.php?latex=w_%7Bi%2Ct%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is a function of a base portfolio <img alt="bar{w}_{i,t}" title="bar{w}_{i,t}" src="https://s0.wp.com/latex.php?latex=%5Cbar%7Bw%7D_%7Bi%2Ct%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, which will be a simple equal weighted portfolio in my example. <img alt="hat{x}_{i,t}" title="hat{x}_{i,t}" src="https://s0.wp.com/latex.php?latex=%5Chat%7Bx%7D_%7Bi%2Ct%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is a vector of characteristics for asset <img alt="i" title="i" src="https://s0.wp.com/latex.php?latex=i&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> at time <img alt="t" title="t" src="https://s0.wp.com/latex.php?latex=t&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, <img alt="theta" title="theta" src="https://s0.wp.com/latex.php?latex=%5Ctheta&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is the vector of parameters and <img alt="N_t" title="N_t" src="https://s0.wp.com/latex.php?latex=N_t&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is the number of available assets. Note that <img alt="hat{x}_{i,t}" title="hat{x}_{i,t}" src="https://s0.wp.com/latex.php?latex=%5Chat%7Bx%7D_%7Bi%2Ct%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"> is standardized cross-sectionally to make sure the sum of the weights in each period is one. If we have two characteristics we only need to estimate two parameters and use the policy equation to recover all weights in the portfolio. Unfortunately using a policy like this makes the portfolio much more restricted than the Markowitz case. In a Markowitz portfolio weights can be anything as long as the sum 1 but in the PPP the portfolio must satisfy the policy equation.</p>
<p>Now that we have the policy we need a way to obtain <img alt="theta" title="theta" src="https://s0.wp.com/latex.php?latex=%5Ctheta&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">. We can use utility functions and try to maximize the portfolio utility. In the equation below we have the populational case in the left and the sample case in the right.</p>
<p><img alt="displaystyle max_{theta}E[u(r_{p,t+1})] sim max_{theta} frac{1}{T}sum_{t=0}^{T-1}u(r_{p,t+1}) " title="displaystyle max_{theta}E[u(r_{p,t+1})] sim max_{theta} frac{1}{T}sum_{t=0}^{T-1}u(r_{p,t+1}) " src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5Cmax_%7B%5Ctheta%7DE%5Bu%28r_%7Bp%2Ct%2B1%7D%29%5D+%5Csim+%5Cmax_%7B%5Ctheta%7D+%5Cfrac%7B1%7D%7BT%7D%5Csum_%7Bt%3D0%7D%5E%7BT-1%7Du%28r_%7Bp%2Ct%2B1%7D%29+&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p>where:</p>
<p><img alt="displaystyle r_{p,t+1} = sum_{i=1}^{N_t} w_{i,t}r_{i,t+1}" title="displaystyle r_{p,t+1} = sum_{i=1}^{N_t} w_{i,t}r_{i,t+1}" src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+r_%7Bp%2Ct%2B1%7D+%3D+%5Csum_%7Bi%3D1%7D%5E%7BN_t%7D+w_%7Bi%2Ct%7Dr_%7Bi%2Ct%2B1%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p>Putting all together we have:</p>
<p><img alt="displaystyle max_{theta} frac{1}{T}sum_{t=0}^{T-1}uleft(left( bar{w}_{i,t} + frac{1}{N_t}theta'hat{x}_{i,t}right)r_{i,t+1}right)" title="displaystyle max_{theta} frac{1}{T}sum_{t=0}^{T-1}uleft(left( bar{w}_{i,t} + frac{1}{N_t}theta'hat{x}_{i,t}right)r_{i,t+1}right)" src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+%5Cmax_%7B%5Ctheta%7D+%5Cfrac%7B1%7D%7BT%7D%5Csum_%7Bt%3D0%7D%5E%7BT-1%7Du%5Cleft%28%5Cleft%28+%5Cbar%7Bw%7D_%7Bi%2Ct%7D+%2B+%5Cfrac%7B1%7D%7BN_t%7D%5Ctheta%27%5Chat%7Bx%7D_%7Bi%2Ct%7D%5Cright%29r_%7Bi%2Ct%2B1%7D%5Cright%29&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<p>where the utility function will be the Constant Relative Risk Aversion (CRRA) with relative risk aversion <img alt="gamma" title="gamma" src="https://s0.wp.com/latex.php?latex=%5Cgamma&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex">, define as:</p>
<p><img alt="displaystyle u(x)=frac{x^{1-gamma}-1}{1-gamma}" title="displaystyle u(x)=frac{x^{1-gamma}-1}{1-gamma}" src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+u%28x%29%3D%5Cfrac%7Bx%5E%7B1-%5Cgamma%7D-1%7D%7B1-%5Cgamma%7D&bg=ffffff&%23038;fg=333333&%23038;s=0" class="latex"></p>
<h2>The data</h2>
<p>The PPP parametrizes the weights on characteristics of the stocks, and although we can get a lot of characteristics from returns such as momentum and variance, we are likely to need something else to have good results. In the original paper Brandt Santa-Clara and Valkanov used momentum, book-to-market ratio and market capitalization (mktcap) . I will use only a momentum measure and the mktcap because they are easier to get and need no complex treatment.</p>
<p>The code below uses the package tidyquant to download data from all S&amp;P500 stocks from Yahoo Finance. The code takes some time to download all data. If you want to replicate the exact example I will show you can also download the data from <a rel="nofollow" href="https://github.com/gabrielrvsc/datasets/blob/master/prices.rda" target="_blank">here</a>. My data starts at 2008-01-02 and ends at 2018-02-06. If you use a different time you will obviously find different results.</p>
<pre>library(tidyverse)
library(reshape2)
library(lubridate)
library(tidyquant)

prices=tq_index(&quot;sp500&quot;) %>%
  tq_get(get = &quot;stock.prices&quot;, complete_cases = TRUE)
</pre>
<pre>## # A tibble: 6 x 12
##   symbol company  weight sector  share… date        open  high   low close
##   </pre>