Why is my p-value matrix after using corrcoef filled with NaN?
5 ビュー (過去 30 日間)
古いコメントを表示
Hi I have a code where I want to calculate the correlation coefficient and p-value of the columns of two matrices, instead of the matrices as w whole. I use the following code for that:
for jj = 1:size(locname,1)
[errormatrix, pvaluematrix] = corrcoef(Hxb(:,jj),Hmeas(:,jj), 'rows','complete');
error.R(1,jj) = errormatrix(1,2);
error.P(1,jj) = pvaluematrix(1,2);
end
This works for the correlation coefficient, however, my pvaluematrix is only NaN. How do I solve this?
0 件のコメント
採用された回答
Adam Danz
2022 年 4 月 22 日
First check whether you have NaNs in your inputs. If so, that explains why there are NaNs in your outputs.
If you do not have NaNs in your inputs, chec, that your inputs do not have identical values.
5 件のコメント
Adam Danz
2022 年 4 月 23 日
@Milva Bon, I was about to dig in but I see that another user has showed you why there are nans in the results. If you want more background information on this, see the link I provided in my answer and go to section "NaN values in the inputs spreading to the outputs".
その他の回答 (1 件)
Voss
2022 年 4 月 22 日
Columns 5, 6 and 7 of Hmeas are all NaN, so even with 'rows','complete', there is nothing you can get but a NaN result.
load('hmeas.mat')
load('hxb.mat')
nanxb = sum(~isnan(Hxb),1);
nanmeas = sum(~isnan(Hmeas),1);
for jj = 1:size(Hxb,2)
fprintf(1,'number of non-NaNs in column %d of Hxb: %d\n',jj,nanxb(jj));
fprintf(1,'number of non-NaNs in column %d of Hmeas: %d\n',jj,nanmeas(jj));
[errormatrix, pvaluematrix] = corrcoef(Hxb(:,jj),Hmeas(:,jj), 'rows','complete')
% error.R(1,jj) = errormatrix(1,2);
% error.P(1,jj) = pvaluematrix(1,2);
fprintf(1,' \n');
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Hypothesis Tests についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!