correlation shows NaN values?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
I would like to calculate the correlation between two vectors (1*744) for each. but the correlation output gives a matrix (744*744) contains NaNs with no number in the matrix.
Any help will be appreciated.
thanks
0 commentaires
Réponse acceptée
Birdman
le 20 Déc 2017
Try corrcoef
corrcoef(A,B)
12 commentaires
Jos (10584)
le 21 Déc 2017
My pleasure. You can use random sampling, for instance. Replace the NaNs by values sampled from the rest of the data vector. The advantage is that it, in the long run, preserves both the mean and the variance of the original data (whereas mean imputing only preserves the mean). You also might consider bootstrapping this procedure to get a better estimate of the correlation with another vector. If X is your original vector:
Xcopy = X ;
tf = isnan(X) ;
Xcopy(tf) = randsample(X(~tf), sum(tf), true)
You also should analyse whether your missing data is (completely) random or not, as this would influence the inferences you can make.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Preprocessing 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!