A matrix version of cor.test()

后端 未结 5 1110
有刺的猬
有刺的猬 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 04:11

    Probably the easiest way is to use the rcorr() from Hmisc. It will only take a matrix, so use rcorr(as.matrix(x)) if your data is in a data.frame. It will return you a list with: 1) matrix of r pairwise, 2) matrix of pairwise n, 3) matrix of p values for the r's. It automatically ignores missing data.

    Ideally, a function of this kind should take data.frames too and also output confidence intervals in line with the 'New Statistics'.

提交回复
热议问题