2
$\begingroup$

Using the formula w*Cov*t(w) I can generate a negative portfolio variance. What are the implications of a negative variance? Should I just assume it's zero? A negative variance is troublesome because one cannot take the square root (to estimate standard deviation) of a negative number without resorting to imaginary numbers. It also doesn't seem consistent with the formula for variance which is the average of the squared deviations from the mean since squaring always produces a positive number.

The negative variance is the tip of the iceberg of my real problem. I have a covariance matrix representing (ex-ante) expectations. I do not have and do not wish to use historical returns. I have 23 asset classes. I've been playing around with some portfolio optimization (not mean variance). I come up with a set of weights (w) for an optimal portfolio. I also have a set of weights for my benchmark (b). I'm calculating a tracking error. The square of the tracking error should be (w-b) * cov * t(w-b). This is what is negative.

Further, my weights are sufficiently different from my benchmark that inspection and intuition tell me zero is the wrong answer. To further prove this I generated 1000 random returns (using my assumptions for return and the covariance matrix) for the asset classes and calculated 1000 returns for w and for b. Then I calculated the difference and then I took the variance. And since I have a computer I repeated this 1000 times. The lowest tracking error (square root of the variance of the differences) was 2.7%. So I'm confident that the variance should be positive.

FWIW, I have a 23x23 covariance matrix. Most of it comes from a public source (Research Affiliates). I add municipal bonds. I'm pretty happy with the covariance matrix in that other uses for it - e.g. the portfolio variance of w and of b seem to be great.

Any insight into either what I might be doing wrong either computationally or by interpretation would be appreciated. All my work is in R and I could share some data and code.

$\endgroup$
2
  • 7
    $\begingroup$ Your matrix is not semi-definite positive hence it is not a covariance matrix. That is one problem with “manually” designed “covariance” matrices. There are ways to create a legitimate covariance matrix that is “close” (in some distance sense) from your matrix. $\endgroup$
    – Ivan
    Commented Jun 2, 2018 at 17:51
  • 1
    $\begingroup$ Can you post the data of your var/cov matrix? As the comment above indicates it is highly likely that it is not positive semi definite. $\endgroup$
    – phdstudent
    Commented Jun 2, 2018 at 18:08

3 Answers 3

3
$\begingroup$

As pointed out by other users here your designed covariance matrix appearantly is not positive-definite and therefore you get this strange behaviour.

Please note that this is not just a mathematical problem but an economic one.

As a toy example look at this: If A and B are strongly negatively correlated (say -1) then they can not both be negatively correlated (again -1) to a third one C. You can design (=write down) such a matrix but this is something you can not encounter in correct maths or real life.

What you can do:

  1. Pick non-negative variances for each asset $V = diag(v_1,v_2,\ldots, v_n)$
  2. choose a positive-definite matrix for the correlations $C$
  3. Calculate $Cov = \sqrt{V} C \sqrt{V}$ where the square-root is componentwise.

The calculation in the third step is discussed on stack.overflow. The package corpcor offers ways to shrink covariances to chosen targets and offers checks for positive-definiteness.

The function make.positive.definite is available that finds the closest (in a chosen sense) positive-definite matrix to some given one.

$\endgroup$
1
$\begingroup$

As Ivan pointed out in his comment, your matrix is not a valid covariance matrix. Put differently, there exists no data set (with complete observations) from which you could have estimated such a covariance matrix.

The simplest way to repair such a matrix is to replace the negative eigenvalues of the matrix by zeros. This method is implemented in function repairMatrix in the R package NMOF, which I maintain.

$\endgroup$
0
$\begingroup$

Ivan's comment is a good answer. I'm adding something but mainly creating an answer instead of a comment to make sure search results show there is an answer. My covariance matrix should be positive semi definite. As I understand it, this roughly translates to it being like a non-negative number. When you multiply by it, you will get zero or something with the same sign. Here is a link to a brief explanation of positive semi definite and positive definite that I found useful. Thanks Ivan.

$\endgroup$
2
  • 5
    $\begingroup$ This is not correct. To check it your matrix is positive semi definite you have several options being the easiest to check that all eigenvalues are positive. Another good alternative is to check if its leading principal minors are all positive. Matlab can check that in a fraction of a second. $\endgroup$
    – phdstudent
    Commented Jun 2, 2018 at 18:13
  • 2
    $\begingroup$ A positive semi-definite matrix implies that $x'\Sigma x$ is non-negative, for any real $x$. For a positive definite matrix, $x'\Sigma x$ is strictly greater than zero. $\endgroup$ Commented Jun 3, 2018 at 6:08

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