Modern Portfolio Theory Using Matrix Algebra

Nidhi Raniyer
11 min readMay 5, 2021


— The following article reviews Markowitz’s portfolio selection model, focusing on Modern Portfolio Theory to enhance methods of portfolio selection. It also introduces matrices and linear algebra to simplify the complex computation behind Modern Portfolio Theory for faster and more accurate estimation of risk, return and optimization of a given investment portfolio.


Modern portfolio theory (MPT) is a theory on how risk-avoiding investors can construct portfolios to make the most of the expected return based on a given level of market risk, emphasizing that risk is an inherent part of higher reward. Harry Markowitz formulated the first mathematical model for portfolio selection in 1952–59, which evaluates investment in terms of their mean and variance which is popularly known as Modern Portfolio Theory. The theory uses basic statistics and mathematical formulas to find out risk, return and optimization option in an investment portfolio comprising of a number of different assets. While working with larger portfolios or portfolio with a bulky number of assets and wealth, the use of algebra to represent the portfolio’s expected return, variance and other aspects can be extremely cumbersome. In this journal, we will not only review Markowitz’s theory but we will also introduce the use of matrix or linear algebra which can greatly simplify many of the computations behind MPT.

Portfolio Optimization Theory deals with the issues related to allocation of the total wealth among different assets. This theory was pioneered by Harry Markowitz in his paper “Portfolio Selection[4]” published in 1952 by the Journal of Finance. He was later awarded a Nobel prize for developing the MPT. Based on statistical measures such as variance and correlation, MPT infers an individual investment’s return is less important than how the investment behaves in the context of the entire portfolio. Matrix algebra formulation can prove to be constructive when it comes to performing computation. The linear algebra formulas can easily be converted to matrix programming languages like R and Octave. Popular spreadsheet programs like Google sheets and Microsoft Excel, which are used vitally in many financial enterprises, can also handle basic matrix calculations to reach to an efficient portfolio optimization. All of this makes familiarity with matrix techniques for portfolio calculations a feasible option.’

Literature Review

Harry Markowitz, famously known as Markowitz, is considered a pioneer for his theoretical contributions to financial economics and corporate finance. Markowitz shared a Nobel Prize in 1990 for his contributions to the field of finance, espoused in his “Portfolio Selection” (1952) essay first published in The Journal of Finance, and more extensively in his book, “Portfolio Selection: Efficient Diversification (1959). His groundbreaking work formed the foundation of what is now popularly known as ‘Modern Portfolio Theory’ (MPT). The foundation for this theory was substantially later expanded upon by Markowitz’ fellow Nobel Prize co-winner, William Sharpe, who is widely known for his 1964 Capital Asset Pricing Model work on the theory of financial asset price formation.


Modern portfolio theory argues that an investment’s risk and return characteristics should not be viewed alone, but should always be evaluated by how the investment affects the overall portfolio’s risk and return. MPT shows that an investor can construct a portfolio of multiple assets that will maximize returns for a given level of risk. Likewise, given a desired level of expected return, an investor can construct a portfolio with the lowest possible risk. Based on statistical measures such as variance and correlation, an individual investment’s return is less important than how the investment behaves in the context of the entire portfolio.


In order to predict future returns (expected return) for a security or portfolio, the historical performance of returns are often examined. Expected return can be defined as “the average of a probability distribution of possible returns”. Calculation of the expected return is the first step in Markowitz’ portfolio selection model. Expected return can simply be viewed as the historic average of a stock’s return over a given period of time. Calculations for a portfolio of securities (two or more) simply involve calculating the weighted average of the expected individual returns.

The portfolio’s risk is a complicated function of the variances of each asset and the correlations of each pair of assets. To calculate the risk of a four-asset portfolio, an investor needs each of the four assets’ variances and six correlation values, since there are six possible two-asset combinations with four assets. Because of the asset correlations, the total portfolio risk, or standard deviation, is lower than what would be calculated by a weighted sum.


As previously discussed, there are various ways to determine the volatility (risk) of multiple investment. The two most common measures are variance and standard deviation. Variance is a “measure of the squared deviations of a stock’s return from its expected return” the average squared difference between the actual returns and the average return. In context of a portfolio, variance measures the volatility of an asset or group of assets.

Larger variance values indicate greater risk. When many assets are held together in a portfolio, assets decreasing in value are often compensated by assets increasing in value present in the portfolio, thereby minimizing risk. Hence, the total variance of a portfolio of assets is always lower than a simple weighted average of the individual asset variances. Analysts’ observations indicate that the variance of a portfolio decreases as the number of portfolio assets increases. According to Frantz & Payne (2009), increasing the number of portfolio assets significantly improves its Efficient Frontier which is an efficient allocation of diversified assets for variable risks. To a degree, the returns on these types of assets tend to cancel each other out, suggesting that the portfolio variance return of these assets will be smaller than the corresponding weighted average of the individual asset variances. Accordingly, maintaining portfolios comprised of a greater number of assets allows investors to more effectively reduce their risk. In actuality, once the number of assets in a portfolio becomes large enough, the total variance is actually derived more from the covariance than from the variance of the assets (Schneeweis, Crowder, & Kazemi, 2010). The significance of this is that this method reinforces the notion that says how assets tend to move within a portfolio has a greater significance rather than how much each individual asset fluctuates in value.


Another common measure of volatility (risk) is the standard deviation of a security. Markowitz’ portfolio selection model makes the general assumption that investors make their investment decisions based on returns and the risk spread. For most investors, the risk undertaken when purchasing a security is that they will receive returns that are lower than what was expected. As a result, it is a deviation from the expected (average) return. Put another way, each security presents its own standard deviation from the average (McClure, 2010). A higher standard deviation translates into a greater risk and a required higher potential return. The standard deviation of a return is the square root of the variance (Bradford, J. & Miller, T., 2009).

The standard deviation of expected returns requires the statistical calculation of several factors which will help to measure the return’s volatility or risk.


Variance and standard deviation measure stock variability. However, if a measurement of the relationship between returns for one stock and returns on another is required, it is necessary to measure their covariance or correlation. Covariance and correlation measures how two random variables are related (Ross, Westerfield & Jaffe, 2002). Covariance is a statistical measure which addresses the interrelationship between the returns of two securities.

If the returns are positively related to each other, their covariance will be positive; if negatively related, the covariance will be negative; and if they are unrelated, the covariance should be zero (Ross, Westerfield & Jaffe, 2002). Markowitz argues that, “It is necessary to avoid investing in securities with high covariance among themselves” (Markowitz, 1952, p. 89).


Correlation coefficient (also referred to as correlation) is the final measure of risk/volatility examined here. It determines the degree to which two variables are related. Correlation coefficient addresses some of the difficulties of analyzing the squared deviation units presented by the covariance of return measure (Ross, Westerfield & Jaffe, 2002). The correlation coefficient simply divides the covariance by the standard deviations of a pair of securities. If cov(x,y) is the covariance between x and y:

If the correlation between the securities is positive, then the variables are positively correlated; if it is negative, then they are negatively correlated; and if the correlation is zero, then the variables are determined to be uncorrelated (Ross, Westerfield & Jaffe, 2002). The degree of risk reduction is dependent upon the variance of the different assets, particularly from the correlation between the investment asset and its weight in the portfolio. The greater is the proportion of uncorrelated assets in a portfolio, the greater will be the risk reduction. The ‘imperfect’ correlations (between +1.00 and — 1.00) generally indicate a reduction in portfolio risks. Portfolio pairs with smaller correlation coefficient values suggest less risk than pairs with larger values. In any event, these risk factors should be carefully selected because the correlation between assets and risk factors is not always obvious. Moreover, correlation may exist even if the factor and asset are not in the business or industry.


Efficient Frontier is a key concept of MPT. It represents the best combination of securities or assets within an investment portfolio. It describes the relationship between expected portfolio returns and the volatility of the portfolio. It is usually depicted in graphic form as a curve on a graph comparing risk against the expected return of a portfolio. The optimal portfolios plotted along this curve represent the highest expected return on investment possible (McClure, 2010).

One of the major implications of Markowitz’ Efficient Frontier theory is its inferences of the benefits of diversification (Efficient frontier). Diversification, as discussed above, can increase expected portfolio returns without increasing risk. Markowitz’ theory implies that rational investors seek out portfolios that generate the largest possible returns with the least amount of risk.


The Markowitz model does complex calculations to figure risk returns and other aspects which can be cumbersome when subjected to a large number of assets in the portfolio. Computation can also be difficult and monotonous while dealing with a large portfolio. Another shortcoming for the Markowitz model assumes that the investor knows the true expected return. However, in practice, investors can only estimate the expected return as investment return changes over time. Practically, due to lack of historical data about security return, it is difficult to predict the investment return accurately. The classical portfolio formulation ignores the estimation error and thereby performs poorly in uncertain conditions. Therefore, it is needed to develop a portfolio optimization methodology that considers data uncertainty by integrating statistical methods and experts’ experience to estimate the future return on investment.


Consider a three asset portfolio problem with assets denoted A, B and C. Let Ri = (i= A, B, C) denote the return on asset i and assume that the constant expected return (CER) model holds:

Let 1 represent the total wealth available for investment while xi denote portion of wealth invested in asset i (i =A, B, C where xA + xB + xC = 1). We see that the return Rp,x is a random variable calculated as:

Now calculating this return value when the number of assets is large becomes a tedious task. If we can convert this linear calculation into matrix form, computation will be much easier.


Define the following n×1 column vectors containing the asset returns and portfolio weights:

To find the portfolio return, we can simply multiply first matrix with the transpose of the other.

Now if we define E[R] to be the mean of all the historic data about the returns on R, We can define another 3x1 column matrix in the following manner:

Therefore, the expected return on the portfolio is:

To simplify further we will define a 3×3 covariance matrix of returns:

The variance of the portfolio can be computed by:

In the beginning we had also specified that xi sums up to 1, i.e. the total wealth available for investment. We can express the condition in the following manner:

Here 1 is a 3x1 vector which each element equal to 1.

We can also compute the covariance between the return on portfolio x and return on portfolio y,


When working with large portfolios, the algebra of representing portfolio expected returns and variances becomes cumbersome. The use of matrix (linear) algebra can greatly simplify many of the computations. Matrix algebra formulations are also very useful when it comes time to do actual computations on the computer. The matrix algebra formulas are easy to translate into matrix programming languages like R. Popular spreadsheet programs like Microsoft Excel, which are the workhorse programs of many financial houses, can also handle basic matrix calculations. All of this makes it worth-while to become familiar with matrix techniques for portfolio calculations.


[1] urn.asp [2] .asp [3] owitz.asp
[4] 6261.1952.tb01525.x [5] f[6] rtfoliotheory.asp [7] d=2147880 [8] 018–0292–4 [9]