# 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.

• In your first formula for portfolio variance, you are missing a w. it should be w'var(e)w – silencer Nov 6 '14 at 0:29
• $e$ is in vector form not matrix because they are orthogonal (just by definition) – user25064 Nov 6 '14 at 20:06
• It's not a coding issue so much as it's the result of using long short portfolios. If you do the optimization imposing the long-only constraint on weights, then the results will be more stable. I'm sort of loathe to do things in terms of factor weights because it might force me to go short a lot of positions I wouldn't want. You might alternately just allow yourself to be long and short liquid instruments (like long SPY short IWM to account for a size effect). – John Nov 6 '14 at 22:36

## 2 Answers

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.

• This would provide weights over the factors, which is actually a decent option. The problem that I was considering was how to get the weights over the assets directly during the optimization process. In your case the weight vector would be $K\times 1$ and what I was thinking was $N\times 1$ – user25064 Nov 6 '14 at 17:56
• Perhaps I wasn't particularly clear. The $\Sigma$ could be any invertible covariance matrix. I meant that you can plug in the formula for $\Sigma$ being whatever it is. Obviously, if you're only using the factor covariance matrix, then your weights would be $K \times 1$ (which seems silly to me), but you can easily transform that into the security covariance matrix and have it be $N \times 1$. So you could replace $\Sigma$ with whatever formula you need and then express the weights analytically in terms of each part. – John Nov 6 '14 at 19:49
• I see now what you mean, if I formulate it (as i should have in the first place) so that $\text{Var}(\epsilon)$ is an $N\times N$ diagonal matrix then I can write that your $\Sigma$ is $\Omega + \text{Var}(\epsilon)$ I am going to try this out in application.. – user25064 Nov 6 '14 at 20:33

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.