correlation shows NaN values?

조회 수: 1 (최근 30일)
Lilya
Lilya 2017년 12월 20일
댓글: Jos (10584) 2017년 12월 21일
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

채택된 답변

Birdman
Birdman 2017년 12월 20일
Try corrcoef
corrcoef(A,B)
  댓글 수: 12
Lilya
Lilya 2017년 12월 21일
Thank you for your clarification Jos. Do you recommend one of them?
Jos (10584)
Jos (10584) 2017년 12월 21일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Preprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by