How to compute the global minimum-variance portfolio


Enrico Schumann


portfolio optimisation, R

Review Status



The global minimum-variance (MV) portfolio is the leftmost point of the mean-variance efficient frontier. It is found by solving the problem

\begin{split} \min_{w} w' \Sigma w\\ w'\iota = 1 \end{split}

where $w$ is the vector of portfolio weights, $\Sigma$ is the variance-covariance matrix of the assets, and $\iota$ is an appropriately-sized vector of ones. We do not put any further constraints on the problem, in particular, short sales are allowed here.

Using a QP solver


We use the quadprog package for R (see the references below).


# create artificial data with mean 0 and sd 5%
nO <- 100 # number of observations
nA <- 10  # number of assets
mData <- array(rnorm(nO * nA, mean = 0, sd = 0.05), dim = c(nO, nA))

# qp
aMat  <- array(1, dim = c(1,nA))
bVec  <- 1
zeros <- array(0, dim = c(nA,1))
solQP <- solve.QP(cov(mData), zeros, t(aMat), bVec, meq = 1)

The quadprod package will minimise an obvective function $\frac{1}{2} w' \Sigma w$, hence the returned minimum-value will be one-half of the portfolio's variance.

all.equal(as.numeric(var(mData %*% solQP$solution)), as.numeric(2 * solQP$value))

A regression representation

The problem can also be implemented as a regression, see Kempf and Memmel [1]. The authors show that regressing the negative excess returns of $\mathrm{n_A} - 1$ assets on the returns of the remaining asset results in coefficients that equal the $\mathrm{n_A} - 1$ respective portfolio weights; the remaining asset's weight is determined by the budget constraint. (Excess return here means with respect to the remaining asset.) Formally, we run the regression

\begin{align} r_{\mathrm{n_A}} = \alpha + w_1 (r_{\mathrm{n_A}} - r_1) + w_2 (r_{\mathrm{n_A}} - r_2) + \ldots + w_{\mathrm{n_A}-1}(r_{\mathrm{n_A}}-r_{\mathrm{n_A}-1}) + \epsilon \end{align}

where $r_i$ is the vector of returns of the $i$th asset, and $\epsilon$ is the vector of errors.

From this equation, we directly obtain the weights $w_1$ to $w_{\mathrm{n_A}-1}$. Since the weights need to sum to unity, we have

\begin{align} w_{\mathrm{n_A}} = 1 - \sum_{i=1}^{\mathrm{n_A}-1} w_i\,. \end{align}

Furthermore, the resulting portfolio's mean return will equal $\alpha$, and the portfolio's variance will equal the variance of the residuals.


# (...continued)

# regression
# choose 1st asset as regressand
y <- mData[,1]
X <- mData[,1] - mData[,2:nA]
solR <- lm(y~X)

The results should be the same as the results from quadprog.

# weights from qp

# weights from regression
as.vector(c(1-sum(coef(solR)[-1]), coef(solR)[-1]))

# variance of portfolio
all.equal(as.numeric(var(mData %*% solQP$solution)), var(solR$residuals))

Solving a system of linear equations

The weights can also be found by solving a system of linear equations.


# solve
x <- solve(cov(mData), numeric(nA) + 1)

# rescale
x <- x / sum(x)

The resulting vector x should give the same weights.

Internal Links

How to compute the tangency portfolio
Related Articles

External links

1. Kempf, A. and C. Memmel (2006). Estimating the Global Minimum Variance Portfolio. Schmalenbach Business Review 58, 332-348.
2. R Development Core Team (2008). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing.
3. Turlach, B.A. [S original] and A. Weingessel [R port] (2007). quadprog: Functions to solve Quadratic Programming Problems. R package version 1.4-11. available from CRAN.
Gilli, M., Maringer, D., Schumann, E. (2011) . Numerical Methods and Optimization in Finance. Elsevier.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License