2
$\begingroup$

I have the following expression for which I wish to find the $\vec{w}$ which minimizes it:

$$ L = \frac{\vec{w}^TA\vec{w}}{\vec{w}^TB\vec{w}} - \lambda(\vec{w}^T\vec{1} - 1) $$

The partial derivates with respect to $\vec{w}$ and $\lambda$ are as follows

\begin{align*} \frac{\partial L}{\partial \vec{w}} &= \frac{2(\vec{w}^TB\vec{w})A\vec{w}-2(\vec{w}^TA\vec{w})B\vec{w}}{(\vec{w}^TB\vec{w})^2} - \lambda \\ \frac{\partial L}{\partial \lambda} &= -\vec{w}^T\vec{1} + 1 \end{align*}

But I'm having a hard time simplifying these to get the minimizing value of $\vec{w}$. Any insights?

$\endgroup$
3
  • $\begingroup$ Would you mind explaining what A and B stands for? Thanks $\endgroup$
    – T123
    May 13 at 16:23
  • $\begingroup$ They are both nxn matrices, and $\vec{w}$ is an nx1 vector $\endgroup$
    – Ringleader
    May 13 at 16:40
  • $\begingroup$ If you want more detail than that: $$A = \Sigma - \sigma_D^2; B = \sigma_D1\sigma_D - \sigma_D^2$$ where $\Sigma = $ Covariance matrix of assets, $\sigma_D = $ diagonal matrix showing each asset's standard deviations (so $\sigma_D^2$ is the same but with variances), and the $1$ matrix is simply an nxn matrix filled with ones. $A$ is therefore essentially a matrix filled with the covariances between each asset but with zeros along the diagonal. $\endgroup$
    – Ringleader
    May 13 at 16:53

1 Answer 1

1
$\begingroup$

Due to the $\vec w^TB\vec w$ in the denominator, you have to solve this problem numerically, either as a direct minimization with a constraint, or by finding the roots of the two Lagrangian equations after taking partial derivatives.

  • Direct minimization with linear equality constraint

$$ min_\vec{w} \left(\frac{\vec{w}^TA\vec{w}}{\vec{w}^TB\vec{w}}\right) \quad s.t. \quad\vec{w}^T \vec{1}-1 = 0. $$ In Python this can be done e.g. using scipy.optimize.minimize with equality constraint argument specified.

  • Alternatively, solve the lagrangian system of equations

$$ \frac{\partial L}{\partial \vec{w}} = 0 \\ \frac{\partial L}{\partial \lambda} = 0, $$ by finding the vector $\vec{w}$ and the value of $\lambda$ that solves the two equations (root finding). In Python this can be done using scipy.optimize.root.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.