{"id":267,"date":"2011-10-03T17:25:41","date_gmt":"2011-10-03T17:25:41","guid":{"rendered":"https:\/\/eranraviv.com\/?p=267"},"modified":"2019-05-13T19:20:55","modified_gmt":"2019-05-13T18:20:55","slug":"ols-beta-robust-beta","status":"publish","type":"post","link":"https:\/\/eranraviv.com\/ols-beta-robust-beta\/","title":{"rendered":"OLS beta VS. Robust beta"},"content":{"rendered":"<p>In financial context, <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-f55ba2d604586d7eebbde815f8b5af49_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#98;&#101;&#116;&#97;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"11\" style=\"vertical-align: -4px;\"\/>  is suppose to reflect the relation between a stock and the general market. A broad based index such as the S&amp;P 500 is often taken as proxy for the general market. The <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-f55ba2d604586d7eebbde815f8b5af49_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#98;&#101;&#116;&#97;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"11\" style=\"vertical-align: -4px;\"\/>, without getting into too much detail, is estimated using the regression: <strong><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 17px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-b18e2ca00bbeb0ae9d3cab79d8003aab_l3.svg\" height=\"17\" width=\"225\" class=\"ql-img-displayed-equation \" alt=\"&#92;&#91;&#115;&#116;&#111;&#99;&#107;&#95;&#105;&#32;&#61;&#32;&#92;&#98;&#101;&#116;&#97;&#95;&#48;&#43;&#92;&#98;&#101;&#116;&#97;&#95;&#49;&#109;&#97;&#114;&#107;&#101;&#116;&#95;&#105;&#43;&#101;&#95;&#105;&#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p> <\/strong> A <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-d517ccb116799365c0e4f4c3d8f71cd2_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#119;&#105;&#100;&#101;&#104;&#97;&#116;&#123;&#92;&#98;&#101;&#116;&#97;&#95;&#49;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"23\" width=\"16\" style=\"vertical-align: -4px;\"\/> of say, 1.5 means that when the market goes up 1% the specific stock goes up 1.5%. (Ignoring all the biases at the moment!)<!--more--><\/p>\n<p>The way the <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-10ad806ee2afa906d2772f884cf051cc_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#98;&#101;&#116;&#97;&#95;&#49;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"16\" style=\"vertical-align: -4px;\"\/> is estimated is using the<em> least squares<\/em> method, which minimizes the squared distances between the observed value and the fitted value, i.e. <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-f24535f4e4716b4491fdb5f9ac011db3_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#115;&#117;&#109;&#95;&#49;&#94;&#84;&#101;&#95;&#105;&#94;&#50;\" title=\"Rendered by QuickLaTeX.com\" height=\"22\" width=\"47\" style=\"vertical-align: -5px;\"\/>. An alternative is to minimize, not the squared distance but the absolute distance, i.e.  <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-e22523bfd893deebf65408e45b6af96d_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#115;&#117;&#109;&#95;&#49;&#94;&#84;&#92;&#109;&#105;&#100;&#32;&#101;&#95;&#105;&#32;&#92;&#109;&#105;&#100;\" title=\"Rendered by QuickLaTeX.com\" height=\"22\" width=\"66\" style=\"vertical-align: -5px;\"\/>. Unlike the <em> least squares, <\/em>this technique has no closed form solution. Nevertheless, it is easy to find the solution using numerical methods. Most statistical software has already built in the procedure under the name <em>robust regression<\/em>, or <em>quintile regression<\/em>. The reason for the name <em>robust regression <\/em>is that an outlier do not weigh more as it moves further from the fitted line, same way the median of the sequence {1,2,3} is still the same as the median of the sequence {1,2,27}, unlike the mean. So the second procedure is <em>robust<\/em> to any such values that do not reflect the day to day relationship. The reason for the name <em>quintile regression<\/em> is that the solution just happens to fit, not the mean, given the explanatory, but the median, given the explanatory, the median is the 50% quint<em>ile, hence quintile regression.<\/em><\/span><\/p>\n<h2>Illustration:<\/h2>\n<p>I use returns of &#8220;Bank of America&#8221; (BAC) as the individual stock, the SPY ETF (Exchange Traded Fund) as a proxy for market returns. Time span is from&nbsp;1998-09-18 till 2011-09-18, so 13 years of daily data. Let us have a look at the two methods, the <em>least squares<\/em> and the <em>quintile regression<\/em>. The former take care of the squared residuals, the latter, the absolute residuals.<\/p>\n<div class=\"mceTemp mceIEcenter\" style=\"text-align: center;\">\n<dl id=\"attachment_294\" class=\"wp-caption aligncenter\" style=\"width: 660px;\">\n<dt class=\"wp-caption-dt\"><a href=\"https:\/\/eranraviv.com\/wp-content\/uploads\/2011\/10\/BACplot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-294\" title=\"BACplot\" src=\"https:\/\/eranraviv.com\/wp-content\/uploads\/2011\/10\/BACplot.png\" alt=\"Rubost Regression VS. OLS\" width=\"650\" height=\"650\"><\/a><\/dt>\n<dd class=\"wp-caption-dd\">Rubost Regression VS. OLS<\/dd>\n<\/dl>\n<\/div>\n<p>What you can see is that the blue line, that correspond with the OLS, or the mean regression, is tilted in the direction of the outliers. The red line on the other hand, is more robust, it does not care about the value of the observations, only about their relative location, and so its slope is more moderate. The robust <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-28c42c700e39cac30ba75f64efa5fe4d_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#119;&#105;&#100;&#101;&#104;&#97;&#116;&#123;&#32;&#92;&#98;&#101;&#116;&#97;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"23\" width=\"12\" style=\"vertical-align: -4px;\"\/> is 1.15 while the OLS <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-77f7f29f9e2828e4226594c04bbf428c_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#119;&#105;&#100;&#101;&#104;&#97;&#116;&#123;&#92;&#98;&#101;&#116;&#97;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"23\" width=\"12\" style=\"vertical-align: -4px;\"\/> is 1.54. You can see that the RMSE = Root Mean Squared Error for the blue line is smaller, for the red line the MAE = Mean Absolute Error is smaller.Each method cares about its own metric.<\/p>\n<p>So what is the <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-f55ba2d604586d7eebbde815f8b5af49_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#92;&#98;&#101;&#116;&#97;\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"11\" style=\"vertical-align: -4px;\"\/> of Bank of America? My tendency is towards the robust version, I understand that the tails are part of the distribution, but by definition, most days are not outliers. More often than not, truth might be found somewhere in the middle..<\/p>\n<pre lang=\"rsplus\">\r\nend= format(Sys.Date(),\"%Y-%m-%d\") \r\nstart= format(as.Date(\"1998-09-18\"),\"%Y-%m-%d\")\r\nlibrary(quantmod)\r\nlibrary(magrittr)\r\ndat0 = getSymbols(\"BAC\", src=\"yahoo\", from=start, to=end, auto.assign = FALSE) %>% as.matrix\r\ndat1 = getSymbols(\"SPY\", src=\"yahoo\", from=start, to=end, auto.assign = FALSE) %>% as.matrix\r\nNROW(dat0)== NROW(dat1) # check if both tickers contain all days\r\nn <- NROW(dat0)\r\nret = (dat0[2:n, 4]\/dat0[1:(n-1),4] - 1) # BAC returns\r\nret_spy = (dat1[2:n, 4]\/dat1[1:(n-1),4] - 1) # SPY retuns\r\nbet = lm(ret~ret_spy)<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-060c0a85828afa61f82a02ae22971a44_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#99;&#111;&#101;&#102;&#91;&#50;&#93;&#32;&#35;&#32;&#79;&#76;&#83;&#32;&#98;&#101;&#116;&#97; &#108;&#105;&#98;&#114;&#97;&#114;&#121;&#40;&#113;&#117;&#97;&#110;&#116;&#114;&#101;&#103;&#41; &#114;&#98;&#101;&#116;&#32;&#61;&#32;&#114;&#113;&#40;&#114;&#101;&#116;&#126;&#114;&#101;&#116;&#95;&#115;&#112;&#121;&#41;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"425\" style=\"vertical-align: -5px;\"\/>coef[2] # Robust beta\r\nplot(ret~ret_spy, main = \"BAC - Beta for Mean Vs Beta for Median\", xlab = \"Market Returns\",\tylab = \"BAC Returns\")\r\nabline(lm(ret~ret_spy)<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-0165246abd59f72cd8f820da60e3b49d_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#99;&#111;&#101;&#102;&#91;&#49;&#58;&#50;&#93;&#44;&#32;&#99;&#111;&#108;&#32;&#61;&#32;&#52;&#41; &#97;&#98;&#108;&#105;&#110;&#101;&#40;&#114;&#113;&#40;&#114;&#101;&#116;&#126;&#114;&#101;&#116;&#95;&#115;&#112;&#121;&#41;\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"309\" style=\"vertical-align: -5px;\"\/>coef[1:2], col = 2)\r\nlegend(\"topleft\", bty = \"n\", c(\"Mean forecast\", \"Median Forecast\"), col = c(4,2), lty = c(1,1))\r\ntext(.11,-.05, paste(\"RMSE: \",format(sqrt(mean((lm(ret~ret_spy,)<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-15dc8181b2a903c569c02c262a80ef8f_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#102;&#105;&#116;&#32;&#45;&#32;&#114;&#101;&#116;&#94;&#50;&#41;&#41;&#44;&#100;&#105;&#103;&#105;&#116;&#115;&#32;&#61;&#32;&#52;&#41;&#41;&#44;&#32;&#99;&#111;&#108;&#32;&#61;&#32;&#52;&#41; &#116;&#101;&#120;&#116;&#40;&#46;&#49;&#49;&#44;&#45;&#46;&#48;&#56;&#44;&#32;&#112;&#97;&#115;&#116;&#101;&#40;&#34;&#82;&#77;&#83;&#69;&#58;&#32;&#34;&#44;&#102;&#111;&#114;&#109;&#97;&#116;&#40;&#115;&#113;&#114;&#116;&#40;&#109;&#101;&#97;&#110;&#40;&#40;&#114;&#113;&#40;&#114;&#101;&#116;&#126;&#114;&#101;&#116;&#95;&#115;&#112;&#121;&#44;&#41;\" title=\"Rendered by QuickLaTeX.com\" height=\"42\" width=\"582\" style=\"vertical-align: -5px;\"\/>fit - ret)^2)), digits = 4)), col = 2)\r\ntext(.11,-.2, paste(\"MAE: \",format(mean(abs(lm(ret~ret_spy,)<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/eranraviv.com\/wp-content\/ql-cache\/quicklatex.com-4f65306c35cbeed43f8a832d758fd4b5_l3.svg\" class=\"ql-img-inline-formula \" alt=\"&#102;&#105;&#116;&#32;&#45;&#32;&#114;&#101;&#116;&#41;&#41;&#44;&#32;&#100;&#105;&#103;&#105;&#116;&#115;&#32;&#61;&#32;&#52;&#41;&#41;&#44;&#32;&#99;&#111;&#108;&#32;&#61;&#32;&#52;&#41; &#116;&#101;&#120;&#116;&#40;&#46;&#49;&#49;&#44;&#45;&#46;&#50;&#51;&#44;&#32;&#112;&#97;&#115;&#116;&#101;&#40;&#34;&#77;&#65;&#69;&#58;&#32;&#34;&#44;&#102;&#111;&#114;&#109;&#97;&#116;&#40;&#109;&#101;&#97;&#110;&#40;&#97;&#98;&#115;&#40;&#114;&#113;&#40;&#114;&#101;&#116;&#126;&#114;&#101;&#116;&#95;&#115;&#112;&#121;&#44;&#41;\" title=\"Rendered by QuickLaTeX.com\" height=\"41\" width=\"582\" style=\"vertical-align: -5px;\"\/>fit - ret)), digits = 4)), col = 2)<\/pre>\n<p>Reference:<br \/>\n<a href=\"http:\/\/www.amazon.com\/gp\/product\/0470010924\/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0470010924&amp;linkCode=as2&amp;tag=erarav-20&amp;linkId=D6PZLTTVOEGQFM4F\"><img decoding=\"async\" src=\"http:\/\/ws-na.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=0470010924&amp;Format=_SL110_&amp;ID=AsinImage&amp;MarketPlace=US&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=erarav-20\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/ir-na.amazon-adsystem.com\/e\/ir?t=erarav-20&amp;l=as2&amp;o=1&amp;a=0470010924\" alt=\"\" style=\"border:none !important; margin:0px !important;\" width=\"2\" height=\"2\" border=\"0\"> <a href=\"http:\/\/www.amazon.com\/gp\/product\/0470129905\/ref=as_li_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0470129905&amp;linkCode=as2&amp;tag=erarav-20&amp;linkId=5L2F4UXVPSQCV6YO\"><img decoding=\"async\" src=\"http:\/\/ws-na.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=0470129905&amp;Format=_SL110_&amp;ID=AsinImage&amp;MarketPlace=US&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=erarav-20\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/ir-na.amazon-adsystem.com\/e\/ir?t=erarav-20&amp;l=as2&amp;o=1&amp;a=0470129905\" alt=\"\" style=\"border:none !important; margin:0px !important;\" width=\"2\" height=\"2\" border=\"0\"><\/p>\n<div id=\"mc_embed_signup\"><form action=\"https:\/\/eranraviv.us9.list-manage.com\/subscribe\/post?u=3890dd9667df0f24c588c91a7&amp;id=2b83e921d9\" method=\"post\" id=\"mc-embedded-subscribe-form\" name=\"mc-embedded-subscribe-form\" class=\"validate\" target=\"_blank\" novalidate><div id=\"mc_embed_signup_scroll\"><div><label id=\"mc-embed-label\" for=\"mce-EMAIL\">Subscribe for future posts (no spam)<\/label><\/div><input type=\"email\" name=\"EMAIL\" class=\"email\" id=\"mceEMAIL\" onkeyup=\"manage(this)\" placeholder=\"email address\" required><div style=\"position:absolute;left:-5000px\" aria-hidden=\"true\"><input name=\"b_3890dd9667df0f24c588c91a7_2b83e921d9\" tabindex=\"-1\"><\/div><div class=\"clear\"><input type=\"submit\" value=\"Subscribe\" name=\"subscribe\" id=\"mc-embedded-subscribe\" class=\"button\" disabled><\/div><\/div><\/form><\/div>","protected":false},"excerpt":{"rendered":"<p>In financial context, $\\beta$ is suppose to reflect the relation between a stock and the general market. A broad based index such as the S&amp;P 500 is often taken as proxy for the general market. The $\\beta$, without getting into too much detail, is estimated using the regression: $$stock_i = \\beta_0+\\beta_1market_i+e_i$$ A $\\widehat{\\beta_1}$ of say,&#8230;<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[4,11,8,12],"tags":[22,55],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-blog","category-finance","category-r","category-statistics-and-econometrics-blog","tag-econometric","tag-robust-statistics"],"_links":{"self":[{"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/comments?post=267"}],"version-history":[{"count":0,"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/posts\/267\/revisions"}],"wp:attachment":[{"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/media?parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/categories?post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eranraviv.com\/wp-json\/wp\/v2\/tags?post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}