Author
Keywords
portfolio optimisation, R
Review Status
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)
where
is the vector of portfolio weights,
is the variance-covariance matrix of the assets, and
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
, 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
assets on the returns of the remaining asset results in coefficients that equal the
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

where
is the vector of returns of the
th asset, and
is the vector of errors.
From this equation, we directly obtain the weights
to
. Since the weights need to sum to unity, we have

Furthermore, the resulting portfolio's mean return will equal
, 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.
Internal Links
| Concepts |
| … |
| Tutorials |
| How to compute the tangency portfolio |
| Tips |
| … |
| Related Articles |
| … |
External links
| References |
|
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. http://www.R-project.org.
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.
|
| Weblinks |
| … |