How to make covariance matrix positive semi-definite (PSD)

28 visualizaciones (últimos 30 días)
I am using the cov function to estimate the covariance matrix from an n-by-p return matrix with n rows of return data from p time series. Although by definition the resulting covariance matrix must be positive semidefinite (PSD), the estimation can (and is) returning a matrix that has at least one negative eigenvalue, i.e. it is not positive semi-definite.
There are many discussions out there about how to transform a non-PSD covariance matrix to a PSD matrix, but I am wondering if there is an efficient way to identify the columns (individual time series) that are causing the calculation to return a non-PSD matrix, eliminate the columns, and then have the cov function return a PSD matrix without needing any artificial transformations?

Respuesta aceptada

John D'Errico
John D'Errico el 4 de En. de 2015
Editada: John D'Errico el 4 de En. de 2015
No, there is not a way. At least there is no constructive, unambiguous, intelligent way.
For example, consider the covariance matrix that arises from
X = repmat(rand(10,1),1,2);
C = cov(X);
Which column causes it to be not positive definite? Column 1 or column 2? What about column 2 makes it more a factor in that zero eigenvalue? I could as easily argue for column 1.
Or, how about this one:
X = rand(10,2);
X = [X,-mean(X,2)];
C = cov(X);
Here, I can delete any of the three columns and end up with a positive definite result, and each column is as "important" in contributing to the zero eigenvalue.
If you wish, I can keep going. How about this one?
X = randn(10,11);
C = cov(X);
Again, each column is as equally random as any other. And since they were randomly generated, we can write any column as a linear combination of the remaining columns. With probability essentially 1, there will be no zero coefficients employed in that linear combination. So which column is the offender? And if you say the last column, then I'll just randomly permute the columns and get a different answer. So effectively, your answer would be to just choose a random column.
Just use a good tool that will yield a positive definite matrix, and do so efficiently. nearestSPD is such a tool.
  4 comentarios
Danny
Danny el 4 de En. de 2015
Thank you very much for both replies.
John D'Errico
John D'Errico el 4 de En. de 2015
Hmm. As I think about this, I could perhaps write a custom version of COV, that would also return a valid cholesky factor of the covariance matrix, without any need to perturb the covariance matrix as a singularity repair. It is quite simple to do as it turns out. Of course, the problem is the only people who want that cholesky factor are those who would then use a tool like MVNRND. And MVNRND uses CHOL.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by