# Portfolio Optimization in R, Part 2

**Adventures in Statistical Computing**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In the previous post, we built the efficient frontier of a portfolio of bonds. The next logical step is to find the super efficient (or market) portfolio holdings. If you are unfamiliar with the concept, take a second and read the section section on Wikipedia.

If you decided not to read, I’ll paraphrase. If you have a rate of return that is guaranteed (a risk free rate), then that asset sits on the y axis of our graph. Draw a line through that point that is tangent to the frontier. That point of tangency is the super efficient portfolio. You can hold a weight of that portfolio and the risk free asset and achieve a better risk return profile than the frontier.

Got it? Good.

So we need to find the line and the tangent point. First let’s decided on the risk free rate. Some people would use the 3 month treasury rate. The rate needs to match your holding period and we are dealing with 1 year values. My bank gives me a 2% CD for 1 year. I will use 2%.

How do we find the point of tangency? When we had 2 assets, we knew that we had a 2nd order polynomial. With 3 assets we get kinks in the surface — in this case where we stop allocating to SHY and start allocating to TLT. We can fit a higher order polynomial, but we cannot ensure that we have a concave surface. Or I could say, we cannot guarantee our point of tangency is always above the frontier. Same thing. We can also have imaginary roots. Or tangent points that are negative…

As an example, here is fitting a 6th order polynomial that fits the kinks but our tangent points are not useful.

Only 1 root is real; the rest are imaginary. We need another methodology.

We could just fit a polynomial to the first part of the frontier; where only SHY and IEF are in the portfolio. This would work, but it would not be very general. I want to find a solution that gives an answer regardless of the shape of the frontier. That is the topic of the next post.

In theory, there is no difference between theory and practice. In practice, there is.— Yogi Berra

**leave a comment**for the author, please follow the link and comment on their blog:

**Adventures in Statistical Computing**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.