correlation shows NaN values?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
2017년 12월 20일
Try corrcoef
corrcoef(A,B)
댓글 수: 12
Lilya
2017년 12월 20일
the obtained result is:
NaN NaN NaN 1
Birdman
2017년 12월 20일
Can you share your vectors in a mat file?
Lilya
2017년 12월 20일
Find the attachment, please. thank you
If we want to omit NaN values from your data, the two array becomes differently sized. Therefore, a solution could be replacing NaN values with the mean of the array. Only JulTotcurr include NaN values.
JulTotcurr(isnan(JulTotcurr))=mean(JulTotcurr,'omitnan');
corrcoef(JulTotcurr,JulTotwnd)
Great! it works But can we obtain it as a vector? to plot the data?
Birdman
2017년 12월 20일
What do you want to plot?
Lilya
2017년 12월 20일
the values of the correlation
res=corrcoef(JulTotcurr,JulTotwnd);
plot(res(:,1),res(:,2),'o')
Lilya
2017년 12월 20일
Totally appreciate it thank you
Jos (10584)
2017년 12월 20일
Statistically, it is not recommended to replace the missing values by the mean ("mean imputing"). There are other techniques that are (often) more reliable.
Statistical analyses with missing data is quite common, and there are many pitfalls to be aware of, in order to avoid drawing false conclusions!
Lilya
2017년 12월 21일
Thank you for your clarification Jos. Do you recommend one of them?
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개)
카테고리
도움말 센터 및 File Exchange에서 NaNs에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
