我用R来计算两个区间数据集(即波高和北大西洋涛动指数)之间的Spearman关联。
第一个问题:我说R把我的区间数据转换成排序数据,然后进行相关性,这是对的吗?
第二个问题:我收到以下警告:
在cor.test.default(hs,df$V1,method = "spearman")中:不能用领带计算精确的p-值
那么,我应该使用肯德尔关联而不是斯皮尔曼吗?或者在R中有一种可以处理关系的Spearman相关性选项?首先,我使用Spearman的原因是它不具有分布形状。
非常感谢!
发布于 2019-02-22 14:29:04
正如错误信息所解释的,问题在于您的数据中有关联。在这种情况下,应该使用Kendallτ-b来计算p值,因为它专门用于处理领带。
让我们考虑以下x和y:
x <- c(44.4, 41.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
y <- c( 2.6, 3.1, 3.1, 5.0, 3.6, 4.0, 5.2, 2.8, 3.8)假设使用Kendall和Spearman统计数据运行相关测试。
Kendall
> cor.test(x, y, method = "kendall", alternative = "greater")
Kendall's rank correlation tau
data: x and y
z = 1.1593, p-value = 0.1232
alternative hypothesis: true tau is greater than 0
sample estimates:
tau
0.3142857
Warning message:
In cor.test.default(x, y, method = "kendall", alternative = "greater") :
Cannot compute exact p-value with tiesSpearman
> cor.test(x, y, method = "spearman", alternative = "greater")
Spearman's rank correlation rho
data: x and y
S = 62.521, p-value = 0.09602
alternative hypothesis: true rho is greater than 0
sample estimates:
rho
0.4789916
Warning message:
In cor.test.default(x, y, method = "spearman", alternative = "greater") :
Cannot compute exact p-value with ties在这两种情况下,我们得到的错误信息“不能计算准确的p-值与领带”。
解决这个问题的一种方法是在R中使用Kendall包。
> library(Kendall)
>
> x <- c(44.4, 41.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
> y <- c( 2.6, 3.1, 3.1, 5.0, 3.6, 4.0, 5.2, 2.8, 3.8)
> summary(Kendall(x,y))
Score = 11 , Var(Score) = 90.02778
denominator = 35
tau = 0.314, 2-sided pvalue =0.29191我们看到,在这种情况下,Kendall统计数据解释了数据中存在联系的事实,并相应地计算p值。
发布于 2019-02-22 14:35:39
第一,Spearman秩相关系数是一种非参数方法,因为它对排序值进行排序并得到相关系数值。我认为因为你自己对它进行了排序,排名不再是唯一的,因此精确的p值无法计算。
第二,这只是警告。不是错误。根据我的社区,Kendall的τ几乎与Spearman秩相关系数相同。相关系数值可能略有不同,但p值几乎相同。
https://stackoverflow.com/questions/54828592
复制相似问题