Why is my p-value matrix after using corrcoef filled with NaN?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Milva Bon
am 22 Apr. 2022
Kommentiert: Milva Bon
am 23 Apr. 2022
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 Kommentare
Akzeptierte Antwort
Adam Danz
am 22 Apr. 2022
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 Kommentare
Adam Danz
am 23 Apr. 2022
@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".
Weitere Antworten (1)
Voss
am 22 Apr. 2022
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 Kommentare
Siehe auch
Kategorien
Mehr zu Hypothesis Tests finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!