Welcome to our next lesson on Mean-Variance Portfolio Theory. In our previous session, we visually identified the entire set of investment possibilities for two assets, culminating in the concept of the efficient frontier and the Global Minimum Variance Portfolio (GMVP) as its starting point. We found this portfolio by plotting thousands of weight combinations and picking the one with the lowest risk.
While visually intuitive, this 'brute force' method is impractical for portfolios with many assets. Today, we will transition from this graphical approach to a more powerful and precise analytical one. We will develop the mathematical machinery to directly calculate the weights of the GMVP for a portfolio containing N risky assets. This involves formulating the problem as a constrained optimization task and solving it using the language of matrix algebra, a toolset well-suited to your background in statistics.
1. The N-Asset Case in Matrix Notation
To handle a portfolio of N assets efficiently, we must first express its characteristics using vectors and matrices. Let's define the key components:
- Expected Returns Vector (): An column vector where the -th element is the expected return of asset , .
- Portfolio Weights Vector (): An column vector where the -th element, , is the proportion of wealth invested in asset .
- Covariance Matrix (): An matrix where the element in the -th row and -th column is the covariance between asset and asset , . The diagonal elements, , are the variances, .
With this notation, the portfolio's expected return and variance become elegantly simple expressions:
- Portfolio Expected Return:
- Portfolio Variance:
The following reading formalizes this setup. As a statistician, you will recognize the variance formula as a quadratic form, which is central to multivariate statistical analysis.
12 Portfolio Theory with Matrix Algebra
This excerpt from "Introduction to Computational Finance and Financial Econometrics with R" provides a clear introduction to representing portfolio characteristics using matrix algebra.
Please read the subsection Portfolio return and risk characteristics. Your focus should be on internalizing how the summation formulas for portfolio return and variance are translated into their compact matrix equivalents, \mathbf{w}^T\boldsymbol{\mu} and \mathbf{w}^T\boldsymbol{\Sigma}\mathbf{w}.
Our goal is to find the Global Minimum Variance Portfolio. This means we must find the weight vector that minimizes the portfolio variance . However, there is one crucial constraint: the weights must sum to 1, ensuring we are fully invested. In matrix notation, this constraint is written as , where is an vector of ones.
So, the problem is formally stated as:
Minimize
Subject to
2. Solving the Optimization Problem
This is a classic constrained optimization problem, which can be solved using the method of Lagrange multipliers. The goal is to find the minimum of a function subject to a constraint. We'll construct a new function, the Lagrangian , and find its unconstrained minimum, which will correspond to the constrained minimum of our original function.
The Lagrangian function for our problem is:
Here, is the Lagrange multiplier. To find the minimum, we take the partial derivatives of with respect to each weight (which is equivalent to differentiating with respect to the vector ) and with respect to , and set them to zero. This gives us a system of linear equations.
The following resource walks through this derivation, showing how it leads to a system of equations that can be solved in a single step using matrix inversion.
This PDF from the University of Maryland's math department provides a clear, step-by-step derivation for the Global Minimum Variance Portfolio.
Please read the subsection Global Minimum Variance Portfolio. Focus on how the optimization problem is translated into a Lagrangian function, and how taking derivatives leads to a system of linear equations that can be expressed as a single block matrix equation.
As shown in the reading, the first-order conditions lead to the following block matrix system:
Solving this system for the vector gives us the optimal weight vector for the GMVP.
3. The Explicit Formula and a Practical Example
While the block matrix approach works, algebraic manipulation of the first-order conditions yields a more direct and elegant formula for the GMVP weights:
Let's break this down:
- The numerator, , calculates a vector of weights that are not yet scaled. is the inverse of the covariance matrix, often called the precision matrix in statistics.
- The denominator, , is a scalar value (a single number). It is the sum of all the elements in the unscaled weight vector from the numerator.
- Dividing the vector by this scalar ensures that the final weights in sum to 1, thus satisfying our constraint.
This formula is the analytical solution to the problem that numerical tools like Excel's Solver tackle through iteration. The following video demonstrates how such a solver is used in practice. While it doesn't use our matrix formula directly, it perfectly illustrates the problem we are solving: minimizing risk subject to the full investment constraint.
Calculating the Global Minimum Variance Portfolio (GMVP) For 3 Stocks in Excel
This video from Darwinex shows how to find the GMVP in practice using a numerical solver, which is what happens "under the hood" when we solve our matrix equations.
Please watch from the full video. As you watch, notice how the problem is set up in Excel: The objective is to minimize the portfolio standard deviation. The variables that can be changed are the asset weights. The constraints are that the weights must sum to 1 (and, in this case, are non-negative, although our analytical solution allows for shorting). The matrix formula we've derived provides the exact same answer without needing to iterate. It is the mathematically precise solution.
Let's see what a final solution looks like for a 5-asset portfolio.

In this example, the optimal weights (0.15, 0.20, 0.12, 0.36, 0.17) were found by applying the formula we just discussed to the given covariance matrix. This resulted in a portfolio with a minimum possible variance of 0.40% (or a standard deviation of 6.29%).
Conclusion
Today, we have made a significant leap from a visual, two-asset framework to a powerful, analytical N-asset solution. You now have the mathematical tool to solve for the portfolio with the lowest possible risk from any number of assets, provided you have their covariance matrix.
The key takeaways from this lesson are:
- The GMVP problem is formulated as a constrained optimization: minimize subject to .
- This problem can be solved analytically using the method of Lagrange multipliers.
- The solution for the GMVP weights has a compact and elegant form in matrix notation: . This provides a direct, non-iterative method for finding the optimal weights.
We have now analytically located the "tip" of the Markowitz bullet. In our next lesson, we will expand this method to find any other optimal portfolio on the efficient frontier. We will do this by introducing a second constraint: a specific target for the portfolio's expected return. This will equip us to trace out the entire efficient frontier mathematically.