Skip to content
All library documents

Deriving Minimum Variance Portfolio Weights from a Factor Covariance Model

Article Quant Q&A · Author: user25064

Summary

The document works through a minimum variance portfolio under a linear factor model. It defines portfolio risk from factor covariance and stock-specific residual risk, then imposes a budget constraint requiring weights to sum to one. The discussion corrects an initial formulation that treated specific variances as a vector rather than a diagonal covariance matrix, and presents the standard closed-form solution using the inverse of the total covariance matrix and a normalization by the sum of its elements.

The thread also raises numerical conditioning as a possible reason computed weights might fail to satisfy the constraint, and suggests rearranging calculations to avoid repeated matrix inversions. The author reports unstable estimates and high leverage in practice, while suggesting that factor-level optimization may sometimes be preferable. These are algebraic and implementation observations; the exchange does not diagnose the reported instability or prescribe constraints, regularization, or a robust covariance estimator.

Key ideas

  • Minimum variance weights under a full investment constraint depend on the inverse total covariance matrix.
  • Residual specific risk should be represented as a diagonal covariance matrix in the factor model.
  • The resulting closed-form weights are normalized to sum to one.
  • Poor numerical conditioning in covariance matrix inversion can undermine implementation.
  • The discussion notes unstable, high-leverage outcomes but does not resolve their cause.

Tags

Full text
# Factor Model - Minimum Variance Portfolio [Complete Proof]


# Factor Model - Minimum Variance Portfolio [Complete Proof]












Can someone check my proof? I think there is something not quite right. I have found limited resources online for this as well so I think it might benefit others to get this on the internet.

Assume there are $K$ time-series factors with $T$ return observations each and $N$ stocks. Our model states that the return on each stock in the model is a linear combination of the return on the factors, e.g. in vector random variable form $R_i = \beta_i F + \epsilon_i$. The return variance of a portfolio with weights $w$ is given by $\text{Var}(w^\prime R) = w \beta \text{Var}(F) \beta^\prime w + w^\prime \text{Var}(\epsilon)$.

Definitions:

- $w$ ($N \times 1$) portfolio weights

- $\beta$ ($K \times N$) factor loading matrix

- $\Omega = \beta^\prime \text{Var}(F) \beta$ ($N\times N$) factor risk matrix

- $e = \text{Var}(\epsilon)$ ($N \times 1$) stock specific variance

- $\lambda$ ($1\times 1$) Lagrange multiplier

- $\vec 1$ ($N\times 1$)

The optimization problem after adding the Lagrange multiplier for the weights sum to one constraint is:

$$ w^* = \text{argmin}_w \left[ w^\prime \Omega w + w^\prime e - \lambda(w^\prime \vec 1 - 1)\right] $$

The first order conditions are

$$ 2w^\prime \Omega + e^\prime - \lambda \vec 1^\prime = 0 $$ $$ w^\prime \vec 1 = 1 $$

Solving the first equation for $w^\prime$ in terms of $\lambda$ yields

$$w^\prime = \frac{1}{2}\left( \lambda \vec 1^\prime - e^\prime \right) \Omega^{-1}$$

Substituting this into the second FOC the result is

$$ 1 = \left( \frac{1}{2}\left( \lambda \vec 1^\prime - e^\prime \right) \Omega^{-1} \right) \vec 1\\ \implies 2 = \lambda \vec 1^\prime \Omega^{-1} \vec 1 - e^\prime \Omega^{-1} \vec 1 \\ \implies \lambda = \frac{2 + e^\prime \Omega^{-1} \vec 1}{\vec 1^\prime \Omega^{-1} \vec 1 } $$

Substituting the Lagrangian back into the first FOC yields the result

$$ w^{*\prime} = \frac{1}{2}\left[ \left(\frac{2 + e^\prime \Omega^{-1} \vec 1}{\vec 1^\prime \Omega^{-1} \vec 1 }\right)\vec 1^\prime - e^\prime \right] \Omega^{-1} $$

I am not sure if it can be written any more simply than that but when I coded this into a PCA statistical factor model I was getting weights that do not sum to one as the constraint suggests.

Result

Ultimately, I do not think there was really an issue with any of the math that was done originally but a reformulation of the problem really did help thanks to @John. For completeness, the final proof is below.

Definitions:

- $w$ ($N \times 1$) portfolio weights

- $\beta$ ($K \times N$) factor loading matrix

- $\Omega = \beta^\prime \text{Var}(F) \beta$ ($N\times N$) factor risk matrix

- $e = \text{Var}(\epsilon)$ ($N \times N$) diagonal matrix of stock specific variance

- $\lambda$ ($1\times 1$) Lagrange multiplier

- $\vec 1$ ($N\times 1$)

- $\Sigma \equiv \Omega + e$

Under this formulation, portfolio variance is given by

$$\text{Var}(w^\prime R) = w^\prime \beta \text{Var}(F) \beta^\prime w + w^\prime \text{Var}(\epsilon) w\\ = w^\prime \Omega w + w^\prime e w\\ = w^\prime \Sigma w$$

The optimization problem after adding the Lagrange multiplier for the weights sum to one constraint is:

$$ w^* = \text{argmin}_w \left[ w^\prime \Sigma w - \lambda(w^\prime \vec 1 - 1)\right] $$

The first order conditions are

$$ 2w^\prime \Sigma - \lambda \vec 1^\prime = 0 $$ $$ w^\prime \vec 1 = 1 $$

Solving the first equation for $w^\prime$ in terms of $\lambda$ yields

$$w^\prime = \frac{1}{2}\lambda \vec 1^\prime \Sigma^{-1}$$

Substituting this into the second FOC the result is

$$ 1 = \frac{1}{2} \lambda \vec 1^\prime \Sigma^{-1} \vec 1^\prime \implies \lambda = \frac{2}{\vec 1^\prime \Sigma^{-1} \vec 1} $$

Substituting the Lagrangian back into the first FOC yields the result

$$ w^{*\prime} = \frac{1^\prime \Sigma^{-1}}{\vec 1^\prime \Sigma^{-1} \vec 1} $$

In practice, the results that I have gotten from direct closed form estimation of $w^*$ are somewhat unstable for even small values of $N$ and yield results including very high leverage. It may be a coding issue and I am re-re-re checking code but I am fairly confident that there are not and severe coding errors.

If each factor is represented by a portfolio, it seems that it may be best to estimate the $K$ weights of the minimum variance portfolio of the factors then multiply through to get final portfolio weights.

## Answer by John (score 4, accepted)

https://quant.stackexchange.com/a/15342

Following @silencer's comment, your formula for variance is wrong. I would suggest that instead of trying to re-invent the wheel, you just use the formula that everyone else uses. So I'd replace your first indented line with $$ w^{*}\equiv argmin\left\{ \frac{1}{2}w'\varSigma w-\lambda\left(w'\mathbf{1}-1\right)\right\} $$ which will give you $$ w^{*}=\frac{\Sigma^{-1}\mathbf{1}}{\mathbf{1}'\Sigma^{-1}\mathbf{1}} $$ and then you can replace the $\Sigma$ with whatever your PCA or factor model tells you it should be.

## Answer by pbr142 (score 3)

https://quant.stackexchange.com/a/15335

The derivation is correct and given the formula you should get $w^{*'} \vec{1} = 1$. My guess is that the inversion of the $\Omega$ matrix is numerically badly conditioned. Instead of implementing the formula as it is, have you tried to calculate $\vec{1}^{'} \Omega^{-1}$ and $e^{'} \Omega^{-1}$ only once and rewrite: $$ w^{*\prime} = \frac{1}{2}\left[ \frac{ \left(2 + e^\prime \Omega^{-1} \vec 1\right)\vec 1^\prime \Omega^{-1} - \left(\vec 1^\prime \Omega^{-1} \vec 1\right) e^\prime \Omega^{-1}}{\vec 1^\prime \Omega^{-1} \vec 1 } \right] $$ This formulation might be numerically more stable.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.