Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 580

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 583

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 586

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 589

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 592

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673
{"id":3541,"date":"2011-06-21T21:52:10","date_gmt":"2011-06-22T02:52:10","guid":{"rendered":"http:\/\/www.calculatinginvestor.com\/?p=3541"},"modified":"2011-06-21T21:52:10","modified_gmt":"2011-06-22T02:52:10","slug":"efficient-frontier-3","status":"publish","type":"post","link":"https:\/\/www.calculatinginvestor.com\/2011\/06\/21\/efficient-frontier-3\/","title":{"rendered":"Calculating the Efficient Frontier: Part 3"},"content":{"rendered":"
Calculating the Efficient Frontier with a Risk-Free Asset<\/h5>\n

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

Tangency Portfolio with a Risk-Free Asset w\/return R<\/h5>\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, \"\mathbf{\bar{z}}\" is the vector of expected returns for the risky assets, and \"\mathbf{S}\" is the covariance matrix for the returns of these assets.\u00a0 The values for A, B, C, and \"\Delta\" 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 \"\mathbf{w_{t}}\" is a vector showing the weight of each asset (weights sum to 1) in the tangency portfolio, and \"\bar{Z_{t}}\" and \"\sigma_{t}^{2}\" are the expected return and variance of the tangency portfolio.<\/p>\n

\"\mathbf{w_{t}}=\frac{\mathbf{S^{-1}}\left ( \mathbf{\bar{z}}-R \mathbf{1}\right )}{B-AR}\"<\/p>\n

\"\bar{Z_{t}}=\mathbf{w_{t}^{'}\bar{z}}=\frac{C-BR}{B-AR}\"<\/p>\n

\"\sigma _{t}^{2}=\mathbf{w_{t}^{'}Sw_{t}}=\frac{C-2RB+R^{2}A}{\left ( B-AR \right )^{2}}\"<\/p>\n

Calculating a Point on the Capital\u00a0Allocation Line<\/h5>\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 \"y\" then the weight in the risk-free asset must be \"1-y\".\u00a0 The value of \"y\" can be calculated for any\u00a0desired expected return, \"\bar{Z_{c}}\"\u00a0on the CAL using this equation:<\/p>\n

\"y=\frac{\bar{Z_c}-R}{\bar{Z_t}-R}\"<\/p>\n

Using this y-value we can calculate the standard deviation at this point on the CAL:<\/p>\n

\"\sigma_{c}= y\sigma_t\"<\/p>\n

By combining these equations, we get the general equation for the CAL:<\/p>\n

\"\bar{Z_c}=R+\left [ \frac{\bar{Z_t}-R}{\sigma_t} \right ]\sigma_c\"<\/p>\n

Example Calculation using Octave<\/h5>\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

\"\mathbf{\bar{z}}=\begin{bmatrix}<\/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 (\"\mathbf{w_{t}}\"), and the weight of the total portfolio which should be in the tangency portfolio (\"y\")\u00a0and the risk-free asset (\"1-y\") to achieve the target expected return.<\/p>\n

The portfolio\u00a0weights for the tangency portfolio are shown here:<\/p>\n

\"\mathbf{w_{t}}=\begin{bmatrix}<\/p>\n

The weight in the tangency portfolio is:<\/p>\n

\"y=1.804\"<\/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 \"1-y\" 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

\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":"

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}]}}