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
Birdman
2017 年 12 月 20 日
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
Birdman
2017 年 12 月 20 日
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?
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 件)
カテゴリ
ヘルプ センター および File Exchange で NaNs についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
