How to compute the global minimum-variance portfolio

An updated version of this tutorial is available.

Enrico Schumann

## Keywords

portfolio optimisation, R

draft

# Introduction

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

(1)
\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

## R

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

require(quadprog)

# 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

(2)
\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

(3)
\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.

## R

# (...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
as.vector(solQP$solution) # 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.

## R

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

# rescale
x <- x / sum(x)


The resulting vector x should give the same weights.