I want to determine the correlation and p-value between one variable and all of the others in an R data frame, so I created a correlation matrix with cor_mat
, and then cor_get_pval
. The relevant p-values were all p<.0001. To test the accuracy, I used cor.test
on my one variable and some of the others, individually. I got the same correlation coefficient, but very high p-values (p>.5).
I think the reason for this is that cor_mat
doesn't adjust p-values for multiple hypothesis testing, and cor.test
does, but then shouldn't the cor_mat
p-values generally be higher than the cor.test
values? In any event, to minimize the potential for Type I error (which is why p-values get adjusted), I increased the confidence level in cor_mat
to 0.9999, and got the same very low p-values. Here is my code:
cor_crime2022_test <- cor_mat(Crime2022_Gini , method = "pearson" ,
conf.level = 0.9999)
pval <- cor_get_pval(cor_crime2022_test)
cor.test(Crime2022_Gini$TotIncidents , Crime2022_Gini$Gini2022)
Is my thinking about this correct? Should I rely on the p-values in cor_mat
or cor.test
? Should I be doing something else?