Parts 1 and 2 left a trail of breadcrumbs to follow. Now I provide a full-color map, a GPS, and local guide. In other words the complete solution in the R statistical language.

Recall that the fast way to compute portfolio variance is:

The companion equation is **r**_{p} =** w**^{T}rtn, where **rtn** is a column vector of expected returns (or historic returns) for each asset. The first goal is to find find **w**_{0} and **w**_{n}. **w**_{0 }minimizes variance regardless of return, while **w**_{n }maximizes return regardless of variance. The goal is to then create the set of vectors {**w**_{0},**w**_{1},…**w**_{n}} that minimizes variance for a given level of expected return.

I just discovered that someone already wrote an excellent post that shows exactly how to write an MVO optimizer completely in R. Very convenient! Enjoy…

http://economistatlarge.com/portfolio-theory/r-optimized-portfolio

### Like this:

Like Loading...

*Related*