Why is my p-value matrix after using corrcoef filled with NaN?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Milva Bon
el 22 de Abr. de 2022
Comentada: Milva Bon
el 23 de Abr. de 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 comentarios
Respuesta aceptada
Adam Danz
el 22 de Abr. de 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 comentarios
Adam Danz
el 23 de Abr. de 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".
Más respuestas (1)
Voss
el 22 de Abr. de 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 comentarios
Ver también
Categorías
Más información sobre Hypothesis Tests en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!