Constructing large covariance matrix from correlations and covariances gives non positive definite matrix.

3 次查看(过去 30 天)
Let's create a large correlation matrix (simply a symmetric matrix with ones on the diagonal and values between -1 and 1 on the off-diagonals), and a vector of standard deviations (positive reals).
dim = 400;
corr_ = eye(dim);
for ii = 1:dim
stdev_ = rand;
for jj = ii+1:dim
corr_(ii,jj) = rand*2-1;
corr_(jj,ii) = corr_(ii,jj);
end
end
Now lets create the covariance matrix in two different ways.
covmat1 = (stdev_*stdev_)'.*corr_;
covmat2 = diag(stdev_)*corr_*diag(stdev_);
Why are both of them not positive definite?
chol(covmat1)
chol(covmat2)
  2 个评论
Jeff Miller
Jeff Miller 2021-4-23
Not sure of the answer to your final question, but it may be relevant that your method of generating a correlation matrix is not valid (i.e., it generates a lot of matrices that could not possibly be correlation matrices). The different correlation values within a matrix are highly constrained--for example, if corr(1,2) = 0.99 and corr(1,3)=0.99 then corr(2,3) has to be quite large as well. So, you can't just generate correlation values independently.
Michael Stollenwerk
Yes, thank you very much! That makes sense. I guess in the data I am provided (a 400 by 400 correlation matrix) some entries must be slightly off s.th. it isn't a correlation matrix.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by