Why is my p-value matrix after using corrcoef filled with NaN?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Adam Danz
il 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 Commenti
Adam Danz
il 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".
Più risposte (1)
Voss
il 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 Commenti
Vedere anche
Categorie
Scopri di più su Hypothesis Tests in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!