{"id":7355,"date":"2012-05-28T09:37:26","date_gmt":"2012-05-28T08:37:26","guid":{"rendered":"https:\/\/www.portfolioprobe.com\/?p=7355"},"modified":"2012-05-28T09:37:26","modified_gmt":"2012-05-28T08:37:26","slug":"jackknifing-portfolio-decision-returns","status":"publish","type":"post","link":"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/","title":{"rendered":"Jackknifing portfolio decision returns"},"content":{"rendered":"<p>A look at return variability for portfolio changes.<\/p>\n<h2>The problem<\/h2>\n<p>Suppose we make some change to our portfolio.\u00a0 At a later date we can see if that change was good or bad for the portfolio return.\u00a0 Say, for instance, that it helped by 16 basis points.\u00a0 How do we properly account for variability in that 16 basis points?<\/p>\n<h2>Performance measurement<\/h2>\n<p>This is an exercise in performance measurement. We want to know: Was that a good decision?<\/p>\n<p>One <a href=\"https:\/\/www.portfolioprobe.com\/about\/applications-of-random-portfolios\/performance-measurement\/\">approach to performance measurement<\/a> is to take the returns over the investigation period as fact and look at other possible decisions that could have been made.<\/p>\n<p>Here we go the other way around.\u00a0 We take the decision as fact and think of the returns over the period as just one realization of a random process.<\/p>\n<h2>Supposings<\/h2>\n<p>Suppose we are holding a portfolio at the end of 2010, and it has the constraints:<\/p>\n<ul>\n<li>constituents from the S&amp;P 500<\/li>\n<li>long-only<\/li>\n<li>at most 50 names<\/li>\n<li>no asset may account for more than 4% of the portfolio variance<\/li>\n<\/ul>\n<p>Suppose further that the value of the portfolio is $10,000,000 and we are willing to trade $100,000 (buys plus sells).<\/p>\n<p>The trade we did resulted in the return being larger by 16.28351 basis points during 2011 (not counting trading costs).\u00a0 But of course that is only how it happened to have turned out &#8212; history could have been different.\u00a0 A gain of 16.28351 basis points was not an inevitable result of that decision.<\/p>\n<p>(It doesn&#8217;t really matter, but in the example presented here the initial portfolio is merely a <a href=\"https:\/\/www.portfolioprobe.com\/about\/random-portfolios-in-finance\/\">random portfolio obeying the constraints<\/a>, and the decision is to move towards smaller predicted variance.)<\/p>\n<h2>Bootstrapping<\/h2>\n<p>One way to assess variability is to use the <a href=\"http:\/\/www.burns-stat.com\/pages\/Tutor\/bootstrap_resampling.html\" target=\"_blank\">statistical bootstrap<\/a>.\u00a0 Figure 1 shows the bootstrap distribution of the return difference using daily data for the year.<\/p>\n<p>Figure 1: Distribution of the return difference for the decision from bootstrapping daily returns in 2011. <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/jackboot\/\" rel=\"attachment wp-att-7356\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7356\" title=\"jackboot\" src=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackboot.png\" alt=\"\" width=\"512\" height=\"480\" srcset=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackboot.png 512w, https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackboot-250x234.png 250w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a>26% of the distribution in Figure 1 is below zero.<\/p>\n<p>The bootstrap samples the days with replacement.\u00a0 It is (essentially) assuming that the returns are independent.\u00a0 That&#8217;s a quite strong assumption &#8212; it probably produces a distribution that is too variable.<\/p>\n<p>We should be able to consider 26% as an upper limit on the <a href=\"https:\/\/www.portfolioprobe.com\/2012\/02\/06\/the-us-market-will-absolutely-positively-definitely-go-up-in-2012\/\">p-value<\/a> for the hypothesis that the difference is less than or equal to zero.<\/p>\n<p>Figure 2 shows a typical case of the number of replicates for each value in a sample with 252 observations.\u00a0 Many observations (about a third) do not appear at all, and a few observations appear more than three times.<\/p>\n<p>Figure 2: Number of replications for each observation in a bootstrap sample for 252 observations. <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/bootcount\/\" rel=\"attachment wp-att-7359\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7359\" title=\"bootcount\" src=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/bootcount.png\" alt=\"\" width=\"512\" height=\"480\" srcset=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/bootcount.png 512w, https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/bootcount-250x234.png 250w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<h2>Jackknifing<\/h2>\n<p>The jackknife is generally considered to be a primitive version of the bootstrap.\u00a0 Another name for it is &#8220;leave-k-out&#8221;.\u00a0 The &#8220;k&#8221; is often 1.\u00a0 The equivalent of Figure 2 for the jackknife would be that all observations are at one replicate except for k at zero.<\/p>\n<p>The jackknife disturbs the distribution much less &#8212; we&#8217;ll get less variability.<\/p>\n<p>Figure 3 shows the return difference distribution from leaving out one daily return during the year.<\/p>\n<p>Figure 3: Distribution of the return difference in 2011 for the decision from leaving out 1 daily return. <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/jackrd1\/\" rel=\"attachment wp-att-7393\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7393\" title=\"jackrd1\" src=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd1.png\" alt=\"\" width=\"512\" height=\"480\" srcset=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd1.png 512w, https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd1-250x234.png 250w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<p>Figures 4 through 8 show the distributions from leaving out various fractions of the returns.<\/p>\n<p>Figure 4: Distribution of the return difference in 2011 for the decision from leaving out 1% (that is, 3) of the daily returns. <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/jackrd01f\/\" rel=\"attachment wp-att-7394\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7394\" title=\"jackrd01f\" src=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd01f.png\" alt=\"\" width=\"512\" height=\"480\" srcset=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd01f.png 512w, https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd01f-250x234.png 250w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<p>Figure 5: Distribution of the return difference in 2011 for the decision from leaving out 5% of the daily returns. <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/jackrd05f\/\" rel=\"attachment wp-att-7395\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7395\" title=\"jackrd05f\" src=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd05f.png\" alt=\"\" width=\"512\" height=\"480\" srcset=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd05f.png 512w, https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd05f-250x234.png 250w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<p>Figure 6: Distribution of the return difference in 2011 for the decision from leaving out 10% of the daily returns. <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/jackrd10f\/\" rel=\"attachment wp-att-7396\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7396\" title=\"jackrd10f\" src=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd10f.png\" alt=\"\" width=\"512\" height=\"480\" srcset=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd10f.png 512w, https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd10f-250x234.png 250w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<p>Figure 7: Distribution of the return difference in 2011 for the decision from leaving out 20% of the daily returns. <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/jackrd20f\/\" rel=\"attachment wp-att-7397\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7397\" title=\"jackrd20f\" src=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd20f.png\" alt=\"\" width=\"512\" height=\"480\" srcset=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd20f.png 512w, https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd20f-250x234.png 250w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<p>Figure 8: Distribution of the return difference in 2011 for the decision from leaving out 50% of the daily returns. <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/jackrd50f\/\" rel=\"attachment wp-att-7398\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7398\" title=\"jackrd50f\" src=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd50f.png\" alt=\"\" width=\"512\" height=\"480\" srcset=\"https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd50f.png 512w, https:\/\/www.portfolioprobe.com\/wp-content\/uploads\/2012\/05\/jackrd50f-250x234.png 250w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a>The fractions of the distributions below zero are: 0.5% for leave out 5%, 3% for leave out 10%, 9% for leave out 20%, and 26% for leave out 50%.<\/p>\n<h2>Questions<\/h2>\n<p>A quite interesting feature of Figure 1 is the long negative tail.\u00a0 Any ideas what is happening there?\u00a0 The trade closes MHS and opens WMT, but their return distributions for the year are both reasonably symmetric.\u00a0 The less symmetric MHS has a fairly trivial weight.<\/p>\n<p>How can we decide what fraction of observations is best to leave out?<\/p>\n<p>Have others done analyses similar to this?<\/p>\n<h2>Summary<\/h2>\n<p>If we could figure out how to determine the right amount of variability, this would be an interesting approach.<\/p>\n<h2>Epilogue<\/h2>\n<blockquote><p>You&#8217;re old enough to make a choice<br \/>\nIt&#8217;s just that in between all the words on the screen<br \/>\nI doubt you&#8217;ll ever hear a human voice<\/p><\/blockquote>\n<p>from &#8220;Walk Between the Raindrops&#8221; by James McMurtry<br \/>\n<object width=\"520\" height=\"390\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/Yd1G8zB6sYA?version=3&amp;hl=en_GB\" \/><param name=\"allowfullscreen\" value=\"true\" \/><embed width=\"520\" height=\"390\" type=\"application\/x-shockwave-flash\" src=\"http:\/\/www.youtube.com\/v\/Yd1G8zB6sYA?version=3&amp;hl=en_GB\" allowFullScreen=\"true\" allowscriptaccess=\"always\" allowfullscreen=\"true\" \/><\/object><\/p>\n<h2>Appendix R<\/h2>\n<p>The computations were done with <a href=\"https:\/\/www.portfolioprobe.com\/user-area\/some-hints-for-the-r-beginner\/\">R<\/a>.<\/p>\n<h4>replication plot<\/h4>\n<p>Figure 2 was produced like:<\/p>\n<pre>jjt &lt;- table(sample(252, 252, replace=TRUE))\r\nbootcount &lt;- rep(0, 252)\r\nnames(bootcount) &lt;- 1:252\r\nbootcount[names(jjt)] &lt;- jjt\r\nplot(bootcount, type='h')<\/pre>\n<p>The type of the plot is &#8216;h&#8217; for &#8220;high-density&#8221;.\u00a0 I&#8217;m not convinced I know why it is called that.<\/p>\n<h4>return difference<\/h4>\n<p>The function to compute the difference in returns between two portfolios is:<\/p>\n<pre>&gt; pp.retdiff\r\nfunction (wt1, wt2, logreturns)\r\n{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ret1 &lt;- sum(wt1 * (exp(colSums(logreturns[,\r\n                 names(wt1)])) - 1))\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ret2 &lt;- sum(wt2 * (exp(colSums(logreturns[,\r\n                 names(wt2)])) - 1))\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ret2 - ret1\r\n}<\/pre>\n<p>This takes a matrix of log returns, sums them over times, then coverts to simple returns in order to multiply by the weights &#8212; see <a href=\"https:\/\/www.portfolioprobe.com\/2010\/10\/04\/a-tale-of-two-returns\/\">&#8220;A tale of two returns&#8221;<\/a>.<\/p>\n<h4>jackknife<\/h4>\n<p>The function that was used to do the jackknifing was:<\/p>\n<pre>&gt; pp.jackknife.rows\r\nfunction (X, FUN, NOUT=1, FRACTION=NULL, TRIALS=1000, ...)\r\n{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 nobs &lt;- nrow(X)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if(length(FRACTION) == 1) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 NOUT &lt;- max(1, round(nobs * FRACTION))\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } else if(length(FRACTION) &gt; 1) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 stop(\"'FRACTION' must have length 1 or 0\")\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if(is.character(FUN)) FUN &lt;- get(FUN)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if(!is.function(FUN)) {\r\n                stop(\"'FUN' is not a function\")\r\n        }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if(NOUT == 1) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ans &lt;- numeric(nobs)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for(i in 1:nobs) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ans[i] &lt;- FUN(X[-i,,\r\n                             drop=FALSE], ...)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } else {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ans &lt;- numeric(TRIALS)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for(i in 1:TRIALS) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 out &lt;- sample(nobs, NOUT)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ans[i] &lt;- FUN(X[-out,,\r\n                             drop=FALSE], ...)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ans\r\n}<\/pre>\n<p>The arguments to this function will look really ugly to a lot of people.\u00a0 That&#8217;s sort of the point.\u00a0 It accepts a function as an argument and accepts additional arguments to that function via the three-dots construct.\u00a0 There is the possibility of a conflict of argument names.\u00a0 One convention for limiting that possibility is to use argument names in all capitals in functions with a function as an argument.<\/p>\n<p>There are various ways of using these functions to do our jackknifing.\u00a0 Here is one way:<\/p>\n<pre>pp.jackknife.rows(sp5.logret11, pp.retdiff,\r\n       wt1=jack.initwt, wt2=jack.optwt)<\/pre>\n<p>Here is another:<\/p>\n<pre>pp.jackknife.rows(sp5.logret11, function(x)\r\n       pp.retdiff(jack.initwt, jack.optwt, x))<\/pre>\n<p>These do the same thing in different ways.\u00a0 The first gives the first two arguments of <code>pp.retdiff<\/code> by name.\u00a0 These are then the inhabitants of the three-dots inside <code>pp.jackknife.rows<\/code>.\u00a0 When <code>pp.retdiff<\/code> is called, the only unmatched argument is the third one, which is what we want.<\/p>\n<p>The second method creates an anonymous function and passes it in as the <code>FUN<\/code> argument.<\/p>\n<p><a href=\"http:\/\/feedburner.google.com\/fb\/a\/mailverify?uri=PortfolioProbe&amp;loc=en_US\" target=\"_blank\">Subscribe to the Portfolio Probe blog by Email<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>A look at return variability for portfolio changes. The problem Suppose we make some change to our portfolio.\u00a0 At a later date we can see if that change was good or bad for the portfolio return.\u00a0 Say, for instance, that it helped by 16 basis points.\u00a0 How do we properly account for variability in that &hellip; <a href=\"https:\/\/www.portfolioprobe.com\/2012\/05\/28\/jackknifing-portfolio-decision-returns\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,11,6],"tags":[149,39],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/posts\/7355"}],"collection":[{"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/comments?post=7355"}],"version-history":[{"count":0,"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/posts\/7355\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/media?parent=7355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/categories?post=7355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.portfolioprobe.com\/wp-json\/wp\/v2\/tags?post=7355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}