cor.test()的矩阵版本 [英] A matrix version of cor.test()

查看:80
本文介绍了cor.test()的矩阵版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Cor.test()接受向量 x y 作为参数,但是我有一个要成对测试的完整数据矩阵。 Cor()将此矩阵作为参数很好,我希望找到一种方法来对 cor.test()做同样的事情

Cor.test() takes vectors x and y as arguments, but I have an entire matrix of data that I want to test, pairwise. Cor() takes this matrix as an argument just fine, and I'm hoping to find a way to do the same for cor.test().

其他人的常见建议似乎是使用 cor.prob()

The common advice from other folks seems to be to use cor.prob():


https://stat.ethz.ch/pipermail/r-help/2001-November/016201.html

但是这些p值与 cor.test()生成的p值不同!!!与 cor.prob相比, Cor.test()似乎还能够更好地处理成对删除(我的数据集中有很多丢失的数据)。 ()

But these p-values are not the same as those generated by cor.test()!!! Cor.test() also seems better equipped to handle pairwise deletion (I have quite a bit of missing data in my data set) than cor.prob().

有人对 cor.prob()有什么选择吗?如果解决方案涉及嵌套的for循环,就这样吧(我对 R 足够陌生,即使这对我来说也是个问题)。

Does anybody have any alternatives to cor.prob()? If the solution involves nested for loops, so be it (I'm new enough to R for even this to be problematic for me).

推荐答案

corr.test psych 包中旨在做到这一点:

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

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

如注释中所述,复制 p来自整个矩阵的 cor.test()函数中的值,那么您需要关闭 p 的调整-多个比较的值(默认为使用Holm的调整方法):

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!]

这篇关于cor.test()的矩阵版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆