# Minimize the variance of a three-security portfolio

I have three securities whose variance covariance matrix looks like this:

        DE5   FR10   IT15
DE5  0.0376 0.0350 0.0243
FR10 0.0350 0.0658 0.0658
IT15 0.0243 0.0658 0.1335


How do I weight each of the three to minimize variance of the package, excluding the (0, 0, 0) solution. I don't mind "going short" IE, a mixture of positive and negative coefficients.

Can this be done with regression? I suspect not as weights will depend on which variable is chosen as dependent.

Is there a straightforward linear-algebra way of doing this without bringing in heavyweight quadratic programming package? I have many of these to do.

Ideally I'd like some code in R.

• Traditionally, one would use quadratic programming rather than regression. – John Jun 27 '18 at 13:27
• @John but will regression work? I have over 500k of these to do and I know the regression routines in R are highly optimized. The thing is if I use regression, which variable do I choose as the dependent variable? Does it matter? See I think I get a problem because depending on which variable I use as dependent, I'll get different solutions even after scaling. – Thomas Browne Jun 27 '18 at 13:35
• First, you need to clearly determine/state all the constraints on the weights. Do they need to sum to 1 (not just that at least one is non-zero)? You "don't mind" shorting, but is there a constraint on magnitude of shorting. e.g., is weight < -1 allowed? Etc. Then you can worry about solution methods. Do actual problems to be solved only involve 3 securities, or are they larger? – Mark L. Stone Jun 27 '18 at 13:51
• @ThomasBrowne Under some conditions, a quadratic optimization is equivalent to a regression, but as Mark L. Stone notes the types of constraints are important. I would refer you to "The Sampling Error in Estimates of Mean-Variance Efficient Portfolio Weights" by Mark Britten-Jones as a classic source. I'm sure there are others. Also, a good quadratic optimization library, even in R, should be calling C/Fortran code for the best performance. You can do them in parallel to increase speed. – John Jun 27 '18 at 15:11
• @MarkL.Stone There is only one single constraint: at least one of the series must have a non-zero weight, given upfront. Because otherwise the optimizer will just give me three zeros. There is no constraint on the sum of the coefficients. And yes, I may generalize to larger problems. – Thomas Browne Jun 27 '18 at 21:06

This is a well-known finance problem. If the constraints are in the form

$w_i \geq Const\ \ \ \rm{or}\ \ \ w_i \leq Const$

the closed-form solution (formula) does not exist. You have to use iterative optimization methods. However, your constraint

$w_i \neq Const$

has measure 0 and is likely to be nonbinding. You can solve the unconstrained problem using formula

$w = \frac{\Omega^{-1}\rm{1}}{\rm{1^{T}}\Omega^{-1}\rm{1}}$

where $\Omega$ is the covariance matrix and $\rm{1}$ is the vectors of 1's... Then you can see that all the weights are non-zero and happily conclude that the constrained solution is the same as the unconstrained one.

Please note: the formula above gives the absolutely minimum-variance portfolio assuming

$\ \ \$1) there is not riskless asset (cash account or treasury bond),

$\ \ \$2) you are fine with any expected return.

The formula for the minimum-variance portfolio assuming a specific expected return is somewhat different.