Now to making pretty-looking graphs and charts for portfolio optimization! The first thing we will do is determine the frontier for our combination of securities. Remember, the variable returnsMatrix below is a matrix of returns for all the securities in your portfolio.
This gives us the frontier. If you type in ?frontierPlot and read through, you will find out all the interesting plots you can make.
We can plot this by:
The circles in dark mark the efficient frontier and the grid() function just makes it look nicer. We can now add to this plot by doing the following:
This added the minimum variance point, the capital market point and the tangency point. The tangency point is marked with an ‘x’ in yellow and lies in exactly the same location as the capital market point in blue. We can pile on even more stuff:
So we now have the tangency line in blue, the Sharpe ratio line in orange, some of the visible asset points in black and the efficient frontiers for all possible combinations of two assets in our portfolio. Looking at this we can kind of see how the assets contribute to the portfolio efficient frontier, and why some assets are highly weighted while others are weighted at 0. Another very interesting chart is obtained by:
This displays the weights on the different securities, the risk, and the return along the frontier. The black line through the chart indicates the minimum variance portfolio. Let’s create some graphs for the tangency portfolio:
This gives a pie-chart of the weights on the securities in the tangency portfolio.
This gives a pie-chart of the weighted returns of the tangency portfolio.