How to generate a matrix of correlated data based on a matrix of observations
Afficher commentaires plus anciens
Hello,
I'm currently studying multicriteria decision aids and my problem is the following:
I have a matrix of n different opportunities (rows) evaluated by m different criteria (columns). Let's call it A (n x m). As I am using the Monte Carlo method, I would like to generate random data around the ones of the first column and then generate the others columns with the right correlation (based on A).
I've already tried the decomposition chol(A) but it didn't work because sometimes the covariance matrix is positive semi-definite. Then I tried the ldl(A) (LDL') but did not succeed.
I hope my problem is clear enough. If it is not, please ask me some more details.
Thank you for you answers!
1 commentaire
Dorian
le 16 Déc 2014
Réponse acceptée
Plus de réponses (1)
Dorian
le 16 Déc 2014
0 votes
1 commentaire
John D'Errico
le 16 Déc 2014
Please, if you have a comment, USE THE COMMENT facility, rather than adding an answer.
Sorry, but you are incorrect. The covariance matrix generated by cov in my example is slightly negative definite only due to numerical round-off error.
In my example, look at the difference between C and Chat. I showed that difference matrix for a valid reason. See that the differences were on the order of eps in double precision, thus the differences were essentially in the least significant bits.
As far as asking how to generate a matrix that has elements which have the same correlation structure as your data, I JUST SHOWED YOU THAT. Simply use mvnrnd with the corrected covariance matrix. A covariance matrix which is generated from your data, but has some tiny negative eigenvalue due to numerical slop is exactly what nearestSPD is designed to correct.
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!