A matrix version of cor.test()

后端 未结 5 1112
有刺的猬
有刺的猬 2020-11-27 03:23

Cor.test() takes vectors x and y as arguments, but I have an entire matrix of data that I want to test, pairwise. Cor() t

5条回答
  •  一生所求
    2020-11-27 03:55

    corr.test in the psych package is designed to do this:

    library("psych")
    data(sat.act)
    corr.test(sat.act)
    

    As noted in the comments, to replicate the p-values from the base cor.test() function over the entire matrix, then you need to turn off adjustment of the p-values for multiple comparisons (the default is to use Holm's method of adjustment):

     corr.test(sat.act, adjust = "none")
    

    [But be careful when interpreting those results!]

提交回复
热议问题