{"id":1988571,"date":"2014-04-24T20:50:40","date_gmt":"2014-04-24T15:20:40","guid":{"rendered":"http:\/\/stockviz.biz\/index.php\/?p=1988571"},"modified":"2014-09-09T12:06:36","modified_gmt":"2014-09-09T06:36:36","slug":"relationship-pair-stocks","status":"publish","type":"post","link":"https:\/\/stockviz.biz\/index.php\/2014\/04\/24\/relationship-pair-stocks\/","title":{"rendered":"Relationship between a pair of stocks"},"content":{"rendered":"<h3>Linear Regression<\/h3>\n<p>The easiest relationship to examine between a pair of stocks is linearity. You can try and fit a linear model through their daily log returns first and then decide further course of action.<\/p>\n<p>Here&#8217;s a scatter-plot that shows how <a href=\"http:\/\/stockviz.biz\/Equity?TICKER=BANKINDIA\" target=\"_blank\">Bank of India<\/a> and <a href=\"http:\/\/stockviz.biz\/Equity?TICKER=CANBK\" target=\"_blank\">Canara Bank<\/a> could be related to each other.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK.png\" alt=\"BANKINDIA-CANBK\" width=\"640\" height=\"480\" class=\"alignnone size-full wp-image-1991461\" srcset=\"https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK.png 640w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-300x225.png 300w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-400x300.png 400w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>Results of linear regression:<\/strong><\/p>\n<pre>Residuals:\r\n      Min        1Q    Median        3Q       Max \r\n-0.055050 -0.009995  0.000331  0.009440  0.063258 \r\n\r\nCoefficients:\r\n              Estimate Std. Error t value Pr(&gt;|t|)    \r\n(Intercept) -0.0002843  0.0006817  -0.417    0.677    \r\nBANKINDIA    0.7451950  0.0232860  32.002   &lt;2e-16 ***\r\n---\r\nResidual standard error: 0.01638 on 575 degrees of freedom\r\nMultiple R-squared:  0.6404,    Adjusted R-squared:  0.6398 \r\nF-statistic:  1024 on 1 and 575 DF,  p-value: &lt; 2.2e-16<\/pre>\n<p>After fitting a regression model it is important to determine whether all the necessary model assumptions are valid before performing inference. If there are any violations, subsequent inferential procedures may be invalid resulting in faulty conclusions. Therefore, it is crucial to perform appropriate model diagnostics.<\/p>\n<h4>Residuals vs. Fitted<\/h4>\n<p>Residuals are estimates of experimental error obtained by subtracting the observed responses from the predicted responses. The predicted response is calculated from the model after all the unknown model parameters have been estimated from the data. Ideally, we should not see any pattern here.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-1.png\" alt=\"BANKINDIA-CANBK-1\" width=\"640\" height=\"480\" class=\"alignnone size-full wp-image-1991481\" srcset=\"https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-1.png 640w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-1-300x225.png 300w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-1-400x300.png 400w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-3.png\" alt=\"BANKINDIA-CANBK-3\" width=\"640\" height=\"480\" class=\"alignnone size-full wp-image-1991491\" srcset=\"https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-3.png 640w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-3-300x225.png 300w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-3-400x300.png 400w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<h4>Q-Q Plot of Residuals<\/h4>\n<p>The QQ Plot shows fat tails.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-2.png\" alt=\"QQ plot BANKINDIA-CANBK-2\" width=\"640\" height=\"480\" class=\"alignnone size-full wp-image-1991501\" srcset=\"https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-2.png 640w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-2-300x225.png 300w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-2-400x300.png 400w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<h4>Residuals vs. Leverage<\/h4>\n<p>The leverage of an observation measures its ability to move the regression model all by itself by simply moving in the y-direction. The leverage measures the amount by which the predicted value would change if the observation was shifted one unit in the y-direction. The leverage always takes values between 0 and 1. A point with zero leverage has no effect on the regression model. If a point has leverage equal to 1 the line must follow the point perfectly.<\/p>\n<p>Labeled points on this plot represent cases we may want to investigate as possibly having undue influence on the regression relationship.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-4.png\" alt=\"BANKINDIA-CANBK-4\" width=\"640\" height=\"480\" class=\"alignnone size-full wp-image-1991511\" srcset=\"https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-4.png 640w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-4-300x225.png 300w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/04\/BANKINDIA-CANBK-4-400x300.png 400w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<h3>Conclusion<\/h3>\n<p>A linear model on daily log returns may not be the best way to understand the relationship between the two stocks. We can either change the model (linear) or change the attribute (daily log returns) that we are using.<\/p>\n<p><em>To be continued&#8230;<\/em><\/p>\n<p>Source: <a href=\"http:\/\/www.stat.columbia.edu\/~martin\/W2024\/R7.pdf\" target=\"_blank\">Model Diagnostics for Regression<\/a><\/p>\n<h6 class=\"zemanta-related-title\" style=\"font-size: 1em\">Related articles<\/h6>\n<ul class=\"zemanta-article-ul\">\n<li class=\"zemanta-article-ul-li\"><a href=\"https:\/\/www.udemy.com\/blog\/least-squares-regression-line\/\">Least Squares Regression Line and How to Calculate it from your Data.<\/a> (udemy.com)<\/li>\n<li class=\"zemanta-article-ul-li\"><a href=\"http:\/\/stockviz.biz\/2014\/04\/24\/nifty-statistical-study\/\">Nifty Statistical Study<\/a> (stockviz.biz)<\/li>\n<\/ul>\n<div class=\"zemanta-pixie\" style=\"margin-top: 10px;height: 15px\"><img decoding=\"async\" class=\"zemanta-pixie-img\" style=\"border: none;float: right\" alt=\"\" src=\"http:\/\/img.zemanta.com\/pixy.gif?x-id=da4be486-2445-4f9c-8e33-7530b1a48741\" \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Linear Regression The easiest relationship to examine between a pair of stocks is linearity. You can try and fit a linear model through their daily log returns first and then decide further course of action. Here&#8217;s a scatter-plot that shows how Bank of India and Canara Bank could be related to each other. Results of &hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3471,9],"tags":[3371,2761],"class_list":["post-1988571","post","type-post","status-publish","format-standard","hentry","category-investing-insight","category-your-money","tag-pair-trading","tag-quant","entry"],"_links":{"self":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/1988571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/comments?post=1988571"}],"version-history":[{"count":0,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/1988571\/revisions"}],"wp:attachment":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/media?parent=1988571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/categories?post=1988571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/tags?post=1988571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}