| ... views |

14: Portfolio Optimization

Modern portfolio theory is linear algebra in disguise. Harry Markowitz’s Nobel Prize-winning insight: don’t just maximize returns—minimize variance for a given return. The math? Quadratic forms, covariance matrices, and constrained optimization.


The Setup

You have nn assets with:

  • Expected returns: μ=[μ1,,μn]T\boldsymbol{\mu} = [\mu_1, \ldots, \mu_n]^T
  • Covariance matrix: Σ\Sigma (an n×nn \times n symmetric positive semi-definite matrix)
  • Portfolio weights: w=[w1,,wn]T\mathbf{w} = [w_1, \ldots, w_n]^T where wi=1\sum w_i = 1

The portfolio return is rp=wTμr_p = \mathbf{w}^T \boldsymbol{\mu}.

The portfolio variance is σp2=wTΣw\sigma_p^2 = \mathbf{w}^T \Sigma \mathbf{w}.

This is a quadratic form—the variance depends on how weights interact through the covariance structure.


Why Covariance Matrices Matter

The covariance matrix Σ\Sigma encodes how assets move together:

Σij=Cov(ri,rj)=E[(riμi)(rjμj)]\Sigma_{ij} = \text{Cov}(r_i, r_j) = E[(r_i - \mu_i)(r_j - \mu_j)]
  • Diagonal entries Σii=σi2\Sigma_{ii} = \sigma_i^2 are individual variances
  • Off-diagonal entries capture correlations
  • Σ\Sigma is always symmetric and positive semi-definite

Key insight: Portfolio risk isn’t just the sum of individual risks. Correlations can cancel out—this is diversification.


The Minimum Variance Portfolio

The simplest problem: find weights that minimize variance with no return target.

Minimize: wTΣw\mathbf{w}^T \Sigma \mathbf{w}

Subject to: 1Tw=1\mathbf{1}^T \mathbf{w} = 1 (weights sum to 1)

Using Lagrange multipliers:

L=wTΣwλ(1Tw1)\mathcal{L} = \mathbf{w}^T \Sigma \mathbf{w} - \lambda(\mathbf{1}^T \mathbf{w} - 1)

Taking the gradient and setting to zero:

wL=2Σwλ1=0\nabla_\mathbf{w} \mathcal{L} = 2\Sigma \mathbf{w} - \lambda \mathbf{1} = 0 w=λ2Σ11\mathbf{w} = \frac{\lambda}{2} \Sigma^{-1} \mathbf{1}

Using the constraint 1Tw=1\mathbf{1}^T \mathbf{w} = 1:

wmin var=Σ111TΣ11\mathbf{w}_{\text{min var}} = \frac{\Sigma^{-1} \mathbf{1}}{\mathbf{1}^T \Sigma^{-1} \mathbf{1}}

The minimum variance portfolio is just the inverse covariance matrix applied to a vector of ones, normalized.


The Efficient Frontier

Now add a return target: minimize variance for a given expected return μp\mu_p.

Minimize: wTΣw\mathbf{w}^T \Sigma \mathbf{w}

Subject to:

  • 1Tw=1\mathbf{1}^T \mathbf{w} = 1
  • μTw=μp\boldsymbol{\mu}^T \mathbf{w} = \mu_p

The solution traces out the efficient frontier—the curve of optimal risk-return tradeoffs.

Using two Lagrange multipliers:

w=Σ1(λ11+λ2μ)\mathbf{w}^* = \Sigma^{-1}(\lambda_1 \mathbf{1} + \lambda_2 \boldsymbol{\mu})

where λ1\lambda_1 and λ2\lambda_2 are determined by the constraints. The efficient frontier is a parabola in variance-return space (or a hyperbola in standard deviation-return space).


The Role of Eigenvalues

Decompose Σ=VΛVT\Sigma = V \Lambda V^T (spectral decomposition). Then:

wTΣw=wTVΛVTw=zTΛz=iλizi2\mathbf{w}^T \Sigma \mathbf{w} = \mathbf{w}^T V \Lambda V^T \mathbf{w} = \mathbf{z}^T \Lambda \mathbf{z} = \sum_i \lambda_i z_i^2

where z=VTw\mathbf{z} = V^T \mathbf{w} are the weights in the eigenvector basis.

Interpretation:

  • Each eigenvalue λi\lambda_i is a principal variance direction
  • Large eigenvalues = high-risk directions in asset space
  • Eigenvectors are uncorrelated “principal portfolios”

Risk decomposition: Portfolio variance is a weighted sum of eigenvalues, with weights determined by exposure to each principal direction.


Numerical Example

Three assets with:

μ=[0.100.050.03],Σ=[0.040.0060.0020.0060.010.0040.0020.0040.0064]\boldsymbol{\mu} = \begin{bmatrix} 0.10 \\ 0.05 \\ 0.03 \end{bmatrix}, \quad \Sigma = \begin{bmatrix} 0.04 & 0.006 & 0.002 \\ 0.006 & 0.01 & 0.004 \\ 0.002 & 0.004 & 0.0064 \end{bmatrix}

The minimum variance portfolio:

  1. Compute Σ1\Sigma^{-1}
  2. Apply to 1\mathbf{1}: Σ11\Sigma^{-1} \mathbf{1}
  3. Normalize: divide by 1TΣ11\mathbf{1}^T \Sigma^{-1} \mathbf{1}

Result: The minimum variance portfolio underweights the high-variance asset and overweights low-variance, low-correlation assets.


Practical Considerations

Estimation Error

Σ\Sigma and μ\boldsymbol{\mu} are estimated from historical data. Small errors in Σ\Sigma can cause large errors in Σ1\Sigma^{-1}—especially if Σ\Sigma is near-singular.

Solutions:

  • Shrinkage estimators: Blend sample covariance with a structured target (e.g., diagonal)
  • Factor models: Assume Σ=BFBT+D\Sigma = B F B^T + D where FF is a small factor covariance matrix
  • Regularization: Add λI\lambda I to Σ\Sigma before inverting

Constraints

Real portfolios have constraints:

  • No short selling: wi0w_i \geq 0
  • Position limits: wiwmaxw_i \leq w_{\max}
  • Sector exposure limits

These turn the problem into quadratic programming—still tractable, but no longer closed-form.


Key Takeaways

  1. Portfolio variance is a quadratic form: wTΣw\mathbf{w}^T \Sigma \mathbf{w}
  2. Covariance matrix is everything: It encodes diversification potential
  3. Inverse covariance appears everywhere: Minimum variance, efficient frontier, risk parity
  4. Eigendecomposition reveals risk structure: Principal directions of portfolio risk
  5. Estimation matters: Σ1\Sigma^{-1} amplifies estimation errors

The Markowitz framework is 70 years old, but the linear algebra hasn’t changed. Covariance matrices, quadratic forms, eigendecomposition—these are the tools that turn “don’t put all your eggs in one basket” into a precise mathematical statement.

Comments

Loading comments...