Minimum Variance Portfolio
Given an expectation vector for assets
\[ \mu = \begin{pmatrix}0.04 \\\\ 0.08 \\\\ 0.12 \\\\ 0.15 \end{pmatrix}\]
and an asset covariance matrix
\[ \Sigma = \begin{pmatrix}0.0049 & 0.00168 & 0.0063 & 0.00546 \\\\ 0.00168 & 0.0144 & 0.01512 & 0.01248 \\\\ 0.0063 & 0.01512 & 0.0324 & 0.03744 \\\\ 0.00546 & 0.01248 & 0.03744 & 0.0676\end{pmatrix} \]
What does the optimization below mean?
\[ min_{w}\frac{1}{2}w^{T}\Sigma w \]
Solve the optimization using the method of Lagrange.
Meaning of the Optimization:
Starting with the constraints.
\[ w^{T}\mathbf{1} = 1 \]
This constraint, called the weight constraint says that the sum of the weights of assets in the portfolio is 1 i.e. all the money in the portfolio has to be invested in the assets from the asset matrix in some proportion.
\[ w^{T}\mathbf{\mu} = 0.1 \]
This constraint, called the return constraint says that the expected return of the portfolio of assets should be 0.1 or 10%.
This constrained optimization
\[ min_{w} \frac{1}{2}w^{T}\Sigma w \]
means choosing the asset weights to minimize the portfolio risk/variance given that you invest all the money in the available assets with a return expectation of 10%. This portfolio is called the minimum variance portfolio in modern portfolio theory.
Solving the optimization:
We can use the Method of Lagrange to solve this constrained optimization problem.
Step 1: Forming the Lagrangian
\[ L(w, \lambda) = \frac{1}{2}w^{T}\Sigma w + \lambda_{1}(1 - w^{T}\mathbf{1}) + \lambda_{2}(0.1 - w^{T}\mathbf{\mu}) \]
\[ L(w, \lambda) = \frac{1}{2}w^{T}\Sigma w + \lambda_{1}(1 - \mathbf{1}^{T}w) + \lambda_{2}(0.1 - \mathbf{\mu}^{T}w) \]
\( L(w, \lambda) \) - Lagrangian function
\( \lambda_{1}, \lambda_{2} \) - Lagrangian multipliers
The second form makes it easier to calculate the gradient and the hessian as we need to differentiate w.r.t \( w \).
Step 2: Reformulate the optimization
\[ min_{w}\frac{1}{2}w^{T}\Sigma w = min_{w, \lambda} L(w, \lambda) \]
\[ \nabla L(w, \lambda) = \begin{pmatrix}L_{w} \\\\ L_{\lambda_{1}} \\\\ L_{\lambda_{2}}\end{pmatrix} = 0 \]
Looking at each of the terms separately
\[ L_{w} = 0 \implies \frac{\partial L(w, \lambda)}{\partial w} = 0 \]
\[ \implies \frac{\partial}{\partial w}(\frac{1}{2}w^{T}\Sigma w + \lambda_{1}(1 - \mathbf{1}^{T}w) + \lambda_{2}(0.1 - \mathbf{\mu}^{T}w)) = 0 \]
\[ \implies w^{T}\Sigma - \lambda_{1}\mathbf{1}^{T} - \lambda_{2}\mathbf{\mu}^{T} = 0 \]
Taking a transpose for the final equation, we have
\[ \Sigma w - \lambda_{1}\mathbf{1} - \lambda_{2}\mathbf{\mu} = 0 \implies w = \Sigma^{-1}(\lambda_{1}\mathbf{1} + \lambda_{2}\mathbf{\mu}) \]
The other two equations would be
\[ L_{\lambda_{1}} = 0 \implies 1 - \mathbf{1}^{T}w = 0 \]
\[ L_{\lambda_{2}} = 0 \implies 0.1 - \mathbf{\mu}^{T}w = 0 \]
\[ \frac{\partial^2L(w, \lambda)}{\partial w^2} = \frac{\partial^2}{\partial w}(\frac{1}{2}w^{T}\Sigma w + \lambda_{1}(1 - \mathbf{1}^{T}w) + \lambda_{2}(0.1 - \mathbf{\mu}^{T}w)) \]
\[ = \frac{\partial}{\partial w}(\Sigma w - \lambda_{1}\mathbf{1}^{T} - \lambda_{2}\mathbf{\mu}^{T}) = \Sigma \]
\[ L_{w\lambda_{1}} = L_{\lambda_{1}w} = -\mathbf{1}^{T} \& L_{w\lambda_{2}} = L_{\lambda_{2}w} = -\mathbf{\mu}^{T} \]
\[ L_{\lambda_{1}\lambda_{1}} = L_{\lambda_{2}\lambda_{2}} = L_{\lambda_{1}\lambda_{2}} = 0 \]
\[ \nabla^2L(w, \lambda) = \begin{pmatrix}\Sigma & -\mathbf{1} & -\mathbf{\mu} \\\\ -\mathbf{1}^{T} & 0 & 0 \\\\ -\mathbf{\mu}^{T} & 0 & 0 \end{pmatrix} \]
I will write about checking for the Hessian being positive definite in another post.
Step 5: Solving for \( w, \lambda \):
We have three equations and three variables from Gradient vector section
\[ w = \Sigma^{-1}(\lambda_{1}\mathbf{1} + \lambda_{2}\mathbf{\mu}) \]
\[ \mathbf{1}^{T}w = 1 \]
\[ \mathbf{\mu}^{T}w = 0.1 \]
Substituting for \( w \) from the first equation in the next two equations, we get
\[ \mathbf{1}^T\Sigma^{-1}\mathbf{1}\lambda_{1} + \mathbf{1}^{T}\Sigma^{-1}\mathbf{\mu}\lambda_{2} = 1 \]
\[ \mathbf{\mu}^{T}\Sigma^{-1}\mathbf{1}\lambda_{1} + \mathbf{\mu}^{T}\Sigma^{-1}\mathbf{\mu}\lambda_{2} = 0.1 \]
\[ A = \mathbf{1}^{T}\Sigma^{-1}\mathbf{1} \]
\[ B = \mathbf{1}^{T}\Sigma^{-1}\mathbf{\mu} = \mathbf{\mu}^{T}\Sigma^{-1}\mathbf{1} \]
\[ C = \mathbf{\mu}^{T}\Sigma^{-1}\mathbf{\mu} \]
The equations can be written as
\[ A\lambda_{1} + B\lambda_{2} = 1 \& B\lambda_{1} + C\lambda_{2} = 0.1 \]
We can solve these two equations for \( \lambda_{1} \& \lambda_{2} \) as
\[ \lambda_{1} = \frac{C - 0.1B}{AC - B^2} \& \lambda_{2} = \frac{0.1A - B}{AC - B^2} \]
Once we evaluate \( \lambda_{1} \& \lambda_{2} \), we can substitute for them in the first equation and get the weight vector \( w \).
I will add the code for evaluating these matrices in a different post. The values from the calculations for this problem are
\[ A = 1505.260875, B = 50.58862248, C = 1.961294709 \]
\[ \lambda_{1} = -0.007880819 \& \lambda_{2} = 0.254260507 \]
\[ w = \begin{pmatrix}0.058676968 \\\\ 0.75902696 \\\\ -0.319545123 \\\\ 0.501841195\end{pmatrix} \]
Here is a c++ implementation for evaluating the minimum variance portfolio.