正负Spearman的r值为负斜率

时间:2014-08-18 23:49:55

标签: r

我正在查看我在本周末收集的一些数据,其中一项Spearman相关性测试给了我一个正值,但是当我在图上添加一个abline时,它正在下降。我很好奇这是如何做到的。

以下是研究的数据:

    Year Matches Total
1   1958    2   7
2   1959    2   14
3   1960    5   9
4   1961    2   20
5   1962    4   27
6   1963    5   20
7   1964    5   25
8   1965    5   20
9   1966    3   18
10  1967    5   28
11  1968    6   26
12  1969    4   24
13  1970    6   22
14  1971    7   32

以下是我使用的程序:

Results<- (Study$Matches/Study$Total)*100
Year<-Study$Year
plot(Year, Results, main = "MAIN")
fit1 <- lm (Results ~ Year, data = Study)
abline(fit1, lty = "dashed")
cor.test(Year, Results, method = "s")

1 个答案:

答案 0 :(得分:1)

拟合产生线性模型。 Pearson是线性相关,它是负的。 Spearman是非线性的,基于排名。

> cor.test(Year,Results,method="spearman")

Spearman's rank correlation rho

data:  Year and Results
S = 438.9647, p-value = 0.9048
alternative hypothesis: true rho is not equal to 0
sample estimates:
       rho 
0.03524238 

Warning message:
In cor.test.default(Year, Results, method = "spearman") :
  Cannot compute exact p-value with ties
> cor(Year,Results,method="spearman")
[1] 0.03524238
> cor(Year,Results,method="pearson")
[1] -0.17501

正确绘制负线性相关性。只是斯皮尔曼是积极的。当相关性较低时,可能会发生不直观的事情。高p值也是一个线索。

相关问题