cor.test(X,Y,method="")
method可以為"spearman","pearson" and "kendall",分別對應三種相關係數的計算和檢驗。
1 perrson相關係數
> n
> x
> y
> cor(x,y)
[1] -0.4132864
> cor.test(x,y)
Pearson"s product-moment correlation
data: x and y
t = -1.2837, df = 8, p-value = 0.2352
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.8275666 0.2924366
sample estimates:
cor
-0.4132864
上面給出了相關係數的可信度區間和P-value
2 spearman相關係數和
kendall相關係數
同上,只要把method改成spearman和kendall
cor.test(X,Y,method="")
method可以為"spearman","pearson" and "kendall",分別對應三種相關係數的計算和檢驗。
1 perrson相關係數
> n
> x
> y
> cor(x,y)
[1] -0.4132864
> cor.test(x,y)
Pearson"s product-moment correlation
data: x and y
t = -1.2837, df = 8, p-value = 0.2352
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.8275666 0.2924366
sample estimates:
cor
-0.4132864
上面給出了相關係數的可信度區間和P-value
2 spearman相關係數和
kendall相關係數
同上,只要把method改成spearman和kendall