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
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!