例題:
2変数 x, y について,10 組の測定値がある。x,y の間に相関はあるか。
| x | 9.7 | 10.3 | 9.6 | 7.7 | 10.2 | 10.6 | 10.4 | 11.4 | 7.8 | 8.6 |
|---|---|---|---|---|---|---|---|---|---|---|
| y | 9.9 | 10.9 | 9.4 | 11.4 | 10.1 | 8.4 | 10.4 | 11.4 | 9.0 | 9.6 |
R による解析:
> x <- c(9.7, 10.3, 9.6, 7.7, 10.2, 10.6, 10.4, 11.4, 7.8, 8.6)
> y <- c(9.9, 10.9, 9.4, 11.4, 10.1, 8.4, 10.4, 11.4, 9.0, 9.6)
> cor.test(x, y, method="spearman")
Spearman's rank correlation rho
data: x and y
S = 140, p-value = 0.6818
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.1458973
Warning message:
p-values may be incorrect due to ties in: cor.test.default(x, y, method = "spearman")