R cor和cor测试之间的差异
我不明白为什么函数cor和cor.test不能给出与pearson methode相同的结果R cor和cor测试之间的差异,r,R,我不明白为什么函数cor和cor.test不能给出与pearson methode相同的结果 > cor(varCor,method="pearson") Distributeurs Importateurs Producteurs Préparateurs Distributeurs 1.0000000 0.5480281 0.2357191 0.7115063 Importateurs 0.5480281 1.0000
> cor(varCor,method="pearson")
Distributeurs Importateurs Producteurs Préparateurs
Distributeurs 1.0000000 0.5480281 0.2357191 0.7115063
Importateurs 0.5480281 1.0000000 -0.2318366 0.1740853
Producteurs 0.2357191 -0.2318366 1.0000000 0.4414107
Préparateurs 0.7115063 0.1740853 0.4414107 1.0000000
> cor.test(annee2010$Distributeurs,annee2010$Préparateurs, method="pearson")
Pearson's product-moment correlation
data: annee2010$Distributeurs and annee2010$Préparateurs
t = 14.6233, df = 94, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.7599547 0.8859092
sample estimates:
cor
0.8334552
>cor(varCor,method=“pearson”)
进口经销商生产商代理
经销商1.0000000.5480281 0.2357191 0.7115063
进口国0.5480281 1.0000000-0.2318366 0.1740853
生产者0.2357191-0.2318366 1.0000000.4414107
参数0.7115063 0.1740853 0.4414107 1.0000000
>校正试验(2010年退火$distributors,2010年退火$Préparateers,method=“pearson”)
皮尔逊积差相关
数据:ANNE2010$经销商和ANNE2010$副经销商
t=14.6233,df=94,p值<2.2e-16
替代假设:真实相关性不等于0
95%置信区间:
0.7599547 0.8859092
样本估计:
cor
0.8334552
它来自于我的数据或我不理解的差异帮助?你说得对!它来自我的数据! varCor是一个na.omit(2010年版)。。。所以,当我处理相同的数据时,它会改变结果
cor.test(varCor$Distributeurs,varCor$Préparateurs, method="pearson")
Pearson's product-moment correlation
data: varCor$Distributeurs and varCor$Préparateurs
t = 4.5283, df = 20, p-value = 0.0002048
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.4141262 0.8716421
sample estimates:
cor
0.7115063
谢谢 cor()和cor.test()兼容。
我猜您的varCor
已经是一个方差协方差矩阵,您可以再次调用cor()
?
如果你有一个方差-协方差矩阵,并且想要从中得到相关性,
使用
cov2cor()
关于vcov矩阵
看到了吗,科沃
(请看cov2cor
的代码。我将此函数添加到R的原因之一是显示
如何以一种既高效又易于理解的方式计算。
..
如果您查看R的真实源代码,或者分别查看该函数,您会发现R代码中有注释。
在网上,这将是我们的底线
什么是
varCor
?这两个向量annee2010$distributors
和annee2010$Préparateers
?您能编辑您的问题,给我们提供dput(varCor)
和dput(annee2010)的输出吗
,可能是为了长度而编辑的?事实上,非varCor只是一个带有数字冒号和na.omit的数据帧,但要感谢它的精度