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.