The Efficient Frontier

Deriving Markowitz's equation

Posted by Terence Tam on June 7, 2015

We all have to deal with 401K allocation some point in our life right? Often times, we are very indecisive in choosing the best subset from a basket of securities that will give us the highest return in the long run, yet minimizing the risk. The efficient frontier by Markowitz can help us decide by showing us the minimum risk for each level of expected return and vice versa.

Let’s say you have three funds to choose from. Security $A$ tracks the S&P500, Security $B$ tracks the NASDAQ and prices of the technology sector, and Security $C$ is an indicator of the energy sector. Given we have historical records (daily stock price, daily % return) of these securities, we could find the variance and the covariance for these stocks. The variance of one stock would be the fluctuating price of that particular stock, where a higher variance would indicate the stock has a greater volatility, thus a higher risk because the %return is not guaranteed or fixed. Covariances, on the other hand, indicates how much two stocks follow similar movements. For instance, two stocks both from U.S. market would go down if the broader U.S. market is on a downward trend.

In our example, let’s say the four securities takes on four random variables. Then the expected % return for the securities are

where 14 stands for 14% average expected return for stock $A$, 12% for stock $B$, and so on.

Then, we can also define the sets of weights for the portfolio

such that $w_A+w_B+w_C+w_D=$ 1

The total average expected return of a portolio $P$ would be the weighted sum

The variance of the portfolio $P$ will be

where $\Sigma$ is the variance-covariance matrix of vector $\bar{Z}$.

The objective here is to minimize the porfolio variance given a porfolio mean $\bar{Z}$, and subject to the weights add up to 1. Our optimization problem could be defined as follows:

From here, we would use the Lagrangian method to solve the min (I can derive this in another post). Also, from the lagrangian equations we can derive the relationship between $\sigma_p$ and $\mu_p$, which turns out to be a hyperbola of the form

where

Let’s run a simple R program to generate the efficient frontier for our particular choices of securities.

Let’s calculate the coefficient, and find the min-variance