Constructing large covariance matrix from correlations and covariances gives non positive definite matrix.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Jeff Miller
le 23 Avr 2021
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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!