相关系数的p值 [英] p-values of correlation coefficients

查看:307
本文介绍了相关系数的p值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R,并且对相关性有疑问。

I am using R and have a question on correlations.

A<-data.frame(A1=c(1,2,3,4,5),B1=c(6,7,8,9,10),C1=c(11,12,13,14,15 ))
B<-data.frame(A2=c(6,7,7,10,11),B2=c(2,1,3,8,11),C2=c(1,5,16,7,8))
cor(A,B)
#           A2        B2       C2
# A1 0.9481224 0.9190183 0.459588
# B1 0.9481224 0.9190183 0.459588
# C1 0.9481224 0.9190183 0.459588

我想获得矩阵中每个相关系数的p值。

I wanted to obtain the p-value for each of the correlation coefficients in the matrix. Is this possible?

我尝试从Hmisc包中使用 rcorr 函数,但仅获得单个p值,而没有

I tried using rcorr function from Hmisc package but obtain only a single p-value and not for each correlation.

A <- as.vector(t(A))
B <- as.vector(t(B))
rcorr(A, B)
     x    y
x 1.00 0.13
y 0.13 1.00

n= 15 


P
  x      y     
x        0.6425
y 0.6425       

同样,我也尝试在R中使用心理软件包来执行此操作,但无法这样做。

Similarly, I also tried using "psych" package in R to do this but unable to.

推荐答案

您可以应用<$ c如果先将它们转换为矩阵,则直接在 A B 上的$ c> rcorr :

You can apply rcorr directly on A and B if you convert them to matrices first :

library(Hmisc)
rcorr(as.matrix(A),as.matrix(B))

哪个给定:

     A1   B1   C1   A2   B2   C2
A1 1.00 1.00 1.00 0.95 0.92 0.46
B1 1.00 1.00 1.00 0.95 0.92 0.46
C1 1.00 1.00 1.00 0.95 0.92 0.46
A2 0.95 0.95 0.95 1.00 0.97 0.16
B2 0.92 0.92 0.92 0.97 1.00 0.15
C2 0.46 0.46 0.46 0.16 0.15 1.00

n= 5 


P
   A1     B1     C1     A2     B2     C2    
A1        0.0000 0.0000 0.0141 0.0273 0.4361
B1 0.0000        0.0000 0.0141 0.0273 0.4361
C1 0.0000 0.0000        0.0141 0.0273 0.4361
A2 0.0141 0.0141 0.0141        0.0078 0.7981
B2 0.0273 0.0273 0.0273 0.0078        0.8125
C2 0.4361 0.4361 0.4361 0.7981 0.8125       

这篇关于相关系数的p值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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