1. Learn
  2. /
  3. Courses
  4. /
  5. Intro to Computational Finance with R

Exercise

The global minimum variance portfolio - Part Two

Now you want to construct the global minimum variance portfolio under the condition that short sales are not allowed. The Markowitz portfolio optimization problem for the minimum variance portfolio with no short sales restrictions can be described as follows:

$$\underset{x}{\text{min}} \ \sigma^2_{p,x} = x'\sum x \text {, subject to}$$ $$x'\mathbf{1} = 1$$ $$x_i \geq 0,$$

with \(x\) the vector of portfolio weights, \(\sigma^2_{p,x}\) and \(\mu_{p,x}\) the portfolio variance and expected return respectively, \(\mu\) the vector of expected returns and \(\Sigma\) the covariance matrix of the returns.

As seen in the lectures, the portfolio optimization problem with inequality constraints can be set up as a quadratic programming problem. Quadratic programming problems are of the form: $$\underset{x}{\text{min}} \ \frac{1}{2}x'Dx - d'x \text{, subject to}$$ $$A'_{neq} x \geq b_{neq} \text{, for } m \text{ inequality constraints, and }$$ $$A'_{eq} x = b_{neq} \text{, for } l \text{ equality constraints,}$$ where \(D\) is a \(n \times n\) matrix, \(x\) and \(d\) are \(n \times 1\) vectors, \(A'_{neq}\) is an \(m \times n\) matrix, \(b_{neq}\) is an \(m \times 1\) vector, \(A'_{eq}\) is an \(l \times n\) matrix, and \(b_{eq}\) is an \(l \times 1\) vector.

Quadratic programming problems can be solved with the R package quadprog and the solve.QP() function. In the next exercise you will discover a more easy way to do this with the help of globalMin.portfolio().

Instructions

100 XP
  • The restriction matrices are already set up. Make sure to study their output.
  • Use these restriction matrices and the global minimum variance portfolio equality constraint to minimize the portfolio variance via solve.QP(). Assign the result to quad_prog.