So, I’ve been\u00a0feeling a\u00a0little bit\u00a0bogged down on this efficient frontier topic,\u00a0and I’m anxious to wrap things up with this post and move on to something more original!<\/p>\n
In the previous two posts, I have demonstrated how to calculate the efficient frontier for any number of\u00a0risky assets<\/a>, and I’ve shown how to calculate the portfolio weights for each point on the efficient frontier<\/a>.<\/p>\n In this post, I will conclude this series on the efficient frontier (finally!) by\u00a0demonstrating how the frontier changes with the addition of a risk-free asset.<\/p>\n An example Octave script is provided for calculating and plotting the efficient frontier, capital\u00a0allocation line, and tangency portfolio.<\/p>\n The tangency portfolio is the intercept point if we draw a tangent line from the risk-free rate of return (on the y-axis) to the efficient frontier for risky assets.\u00a0<\/p>\n The equations used to calculate the portfolio weights, expected return, and variance for the tangency portfolio are shown in this section.<\/p>\n The variables used in these equations are described in more detail in the previous posts.\u00a0\u00a0However, to review briefly, is the vector of expected returns for the risky assets, and is the covariance matrix for the returns of these assets.\u00a0 The values for A, B, C, and are\u00a0intermediate values calculated using the portfolio statistics and the equations for these values are shown in my initial post <\/a>on this topic.\u00a0 \u00a0The value R is the return on the risk-free asset.\u00a0 The value is a vector showing the weight of each asset (weights sum to 1) in the tangency portfolio, and and are the expected return and variance of the tangency portfolio.<\/p>\n <\/p>\n <\/p>\n <\/p>\n The Capital\u00a0Allocation Line or CAL is the tangent line from the risk-free rate of return (on the y-axis) to the efficient frontier for risky assets. The points on this line represent the highest expected return we can get at a given level of risk when we have access to a risk-free asset.\u00a0<\/p>\n All points on this line are a combination of the tangency portfolio and the risk-free asset.\u00a0 If the weight of the portfolio in the tangency portfolio is given as then the weight in the risk-free asset must be .\u00a0 The value of can be calculated for any\u00a0desired expected return, \u00a0on the CAL using this equation:<\/p>\n <\/p>\n Using this y-value we can calculate the standard deviation at this point on the CAL:<\/p>\n <\/p>\n By combining these equations, we get the general equation for the CAL:<\/p>\n <\/p>\n As an example, let’s consider the four risky assets used in the efficient frontier examples in the previous posts.\u00a0 The expected return vector and covariance matrix for these assets is given here:<\/p>\n <\/p>\n <\/p>\n The risk-free rate will be assumed to be 3%, and the target return will be set to 14%.<\/p>\n If we implement the equations\u00a0for the tangency portfolio and CAL\u00a0in Octave, we can calculate the portfolio weights for the tangency portfolio (), and the weight of the total portfolio which should be in the tangency portfolio ()\u00a0and the risk-free asset () to achieve the target expected return.<\/p>\n The portfolio\u00a0weights for the tangency portfolio are shown here:<\/p>\n <\/p>\n The weight in the tangency portfolio is:<\/p>\n <\/p>\n Since this value is greater than 1, that means we have a short position in the risk-free asset with a weight of or -0.804.<\/p>\n Note that this is a somewhat\u00a0unrealistic scenario\u00a0since we cannot\u00a0borrow at the true risk-free rate.\u00a0 In practice our borrowing rate would be higher, and the actual risk-free rate would be used only for portfolios where we had a positive weight in the risk-free asset.<\/p>\n The plot of the efficient frontier, tangency portfolio, and the CAL are shown here:<\/p>\n \u00a0<\/a><\/p>\n Octave Code:<\/strong><\/p>\n This Octave code\u00a0will calculate and plot\u00a0the efficient frontier, tangency portfolio and the CAL.\u00a0 The script can be modified for a different set of assets by updating the expected returns vector, the covariance matrix, the target return, and the risk free rate.\u00a0 \u00a0The script will also work in Matlab.<\/p>\n Calculating the Efficient Frontier with a Risk-Free Asset So, I’ve been\u00a0feeling a\u00a0little bit\u00a0bogged down on this efficient frontier topic,\u00a0and I’m anxious to wrap things up with this post and move on to something more original! In the previous two posts, I have demonstrated how to calculate the efficient frontier for any number of\u00a0risky assets, and […]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/posts\/3541"}],"collection":[{"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/comments?post=3541"}],"version-history":[{"count":93,"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/posts\/3541\/revisions"}],"predecessor-version":[{"id":3637,"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/posts\/3541\/revisions\/3637"}],"wp:attachment":[{"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/media?parent=3541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/categories?post=3541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/tags?post=3541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Tangency Portfolio with a Risk-Free Asset w\/return R<\/h5>\n
Calculating a Point on the Capital\u00a0Allocation Line<\/h5>\n
Example Calculation using Octave<\/h5>\n
\r\nclear all;\r\nclose all;\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n% Mean Variance Optimizer Inputs\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n% S is matrix of security covariances\r\nS = [185 86.5 80 20; 86.5 196 76 13.5; 80 76 411 -19; 20 13.5 -19 25]\r\n\r\n% Vector of security expected returns\r\nzbar = [14; 12; 15; 7]\r\n\r\n% Risk Free Asset Return\r\nR = 3\r\n\r\n% Target Return\r\nmu_tar = 14\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n% Calculating Variables\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n% Unity vector..must have same length as zbar\r\nunity = ones(length(zbar),1)\r\n\r\n% Vector of security standard deviations\r\nstdevs = sqrt(diag(S))\r\n\r\nA = unity'*S^-1*unity\r\nB = unity'*S^-1*zbar\r\nC = zbar'*S^-1*zbar\r\nD = A*C-B^2\r\n\r\n% Calculate Lambda and Gamma\r\nlambda_target = (C - mu_tar*B)\/D;\r\ngamma_target = (mu_tar*A-B)\/D;\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n% Efficient Frontier\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nmu = 1:200;\r\nmu = mu\/10;\r\n\r\nminvar = ((A*mu.^2)-2*B*mu+C)\/D;\r\nminstd = sqrt(minvar);\r\n\r\nplot(minstd,mu,stdevs,zbar,'*')\r\ntitle('Efficient Frontier with Individual Securities','fontsize',18)\r\nylabel('Expected Return (%)','fontsize',18)\r\nxlabel('Standard Deviation (%)','fontsize',18)\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n% Global Minimum Variance Portfolio\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n% Mean and Variance of Global Minimum Variance Portfolio\r\nmu_g = B\/A\r\nvar_g = 1\/A\r\nstd_g = sqrt(var_g)\r\n\r\n% Minimum Variance Portfolio Weights\r\nw_g = (S^-1*unity)\/A\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n% Tangency Portfolio with a Risk Free Asset\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n% Expected Return of Tangency Portfolio\r\nztan = (C-B*R)\/(B-A*R);\r\n\r\n% Variance and Standard Deviation of Tangency Portfolio\r\nvartan = (C-2*R*B + R^2*A)\/((B-A*R)^2);\r\nstdtan = sqrt(vartan);\r\n\r\n% Weights for Tangency Portfolio\r\nw_tan = (S^-1*(zbar - R*unity))\/(B-A*R)\r\n\r\n% Tangency Line\r\nmu_tan = mu(mu >= R);\r\nminvar_rf = (mu_tan-R).^2\/(C-2*R*B+A*R^2);\r\nminstd_rf = sqrt(minvar_rf);\r\n\r\n% Weights for w_d (tangency when R=0)\r\nw_d = (S^-1*zbar)\/B;\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n% Target Return Portfolio w\/and w\/o Risk Free Asset\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\n% Weights for portfolio with target return = 14%, w\/o risk-free asset\r\n\r\nw_s = (lambda_target*A)*w_g + (gamma_target*B)*w_d;\r\n\r\n% Expected Return of Target Portfolio (should match target)\r\nmu_s = w_s'*zbar;\r\n\r\n% Variance and Standard Deviation of target portfolio\r\nvar_s = w_s'*S*w_s;\r\nstd_s = sqrt(var_s);\r\n\r\n% Weights for portfolio with target return = 14%, w\/risk free asset\r\n\r\ny = (mu_tar - R)\/(ztan-R);\r\nstdtar = stdtan*y;\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n% Tangency Plot\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n\r\nfigure\r\nplot(minstd_rf,'linewidth',2,mu_tan,minstd,'linewidth',2,mu,stdtan,ztan,'*','linewidth',2,std_g,mu_g,'x','linewidth',2,std_s,mu_s,'x','linewidth',2,stdtar,mu_tar,'*','linewidth',2)\r\ntext(0.5,R,'RF','fontsize',12);\r\ntext(0.5+std_g,mu_g,'Global Minimum Variance Portfolio','fontsize',12);\r\ntext(0.5+stdtan,ztan,'Tangency Portfolio','fontsize',12);\r\ntext(0.5+std_s,mu_s,'Target Return of 14% w\/o Risk-Free Asset','fontsize',12);\r\ntext(stdtar-8,mu_tar+0.5,'Target Return of 14% w\/Risk-Free Asset','fontsize',12);\r\ntitle('Efficient Frontier with Tangency Portfolio','fontsize',18)\r\nylabel('Expected Return (%)','fontsize',18)\r\nxlabel('Standard Deviation (%)','fontsize',18)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"