Getting different p-values with corrcoef and regress functions

8 visualizaciones (últimos 30 días)
I'm having trouble understanding the differences between the p-values returned from corrcoef and regress. I have a large data set with variables in the columns and instances in the rows. I determine which variables have significant relationships using corrcoef like this:
[R,P,RLO,RUP] = corrcoef(binaryDataXlx,'rows','pairwise');
[sigx,sigy] = find(P < 0.05);
sig = [sigx sigy];
Then, for those that are significant, I remove the NaN entries and use regress to find the coefficients of linear regression:
[B,BINT,Rregress,RINT,STATS] = regress(tempPruned(:,2),Xregress,0.05);
My main problem is that the p-values from corrcoef do not agree with the p-values from STATS(3). Is this because corrcoef compares all relationships, not just linear ones? And if so, why are the p-values from regress sometimes smaller than those from corrcoef?
Thanks you so much!!
Matthew

Respuesta aceptada

the cyclist
the cyclist el 21 de Dic. de 2016
This is difficult to understand without the seeing the code and data.
Here is a simple example with one predictor, in which the P-value does agree:
rng default
x = (0:0.05:1)';
y = x + 8*rand(size(x,1),1);
figure
plot(x,y,'.')
[b,bint,r,rint,stats] = regress(y,[ones(size(x)) x])
stats(3)
[r,p] = corrcoef(y,x)
Maybe you could craft a simple example showing your problem? Specifically, if you have more than one predictor, I'm not sure how you are comparing the single P-value of the F-statistic of the regression with the many P-values of corrcoef.
  1 comentario
Matthew_User14
Matthew_User14 el 22 de Dic. de 2016
Thank you very much for the kind reply. In the process of setting up an example, I found the error in my code. Now the p-values agree exactly. I was thinking that p-values of corrcoef and regress were testing different hypotheses, but it seems like that's not the case. Anyway, thank you again and sorry for the trouble!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by