필터 지우기
필터 지우기

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

조회 수: 30 (최근 30일)
Danny
Danny 2015년 1월 4일
댓글: John D'Errico 2015년 1월 4일
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?

채택된 답변

John D'Errico
John D'Errico 2015년 1월 4일
편집: John D'Errico 2015년 1월 4일
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
Danny
Danny 2015년 1월 4일
Thank you very much for both replies.
John D'Errico
John D'Errico 2015년 1월 4일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by