[Rd] Something strange in cor.test in R-1.8.0 (PR#4718)
Duncan Murdoch
dmurdoch at pair.com
Wed Oct 22 14:12:02 MEST 2003
On Wed, 22 Oct 2003 11:51:46 +0100 (BST), you wrote:
>Without knowing the seed used it is impossible for us to reproduce this,
>but I am not seeing anything strange.
I'm getting strange results in 1.8.0 for Windows too.
> set.seed(1)
> x <- rnorm(50)
> y <- rnorm(50)
> cor.test(x,y,method="spearman")
Spearman's rank correlation rho
data: x and y
S = 23640, p-value = 1
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
-0.1351741
> x <- rnorm(50)
> y <- rnorm(50)
> cor.test(x,y,method="spearman")
Spearman's rank correlation rho
data: x and y
S = 17248, p-value = < 2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.1717647
> x
[1] -0.62036668 0.04211587 -0.91092165 0.15802877 -0.65458464
1.76728727
[7] 0.71670748 0.91017423 0.38418536 1.68217608 -0.63573645
-0.46164473
[13] 1.43228224 -0.65069635 -0.20738074 -0.39280793 -0.31999287
-0.27911330
[19] 0.49418833 -0.17733048 -0.50595746 1.34303883 -0.21457941
-0.17955653
[25] -0.10019074 0.71266631 -0.07356440 -0.03763417 -0.68166048
-0.32427027
[31] 0.06016044 -0.58889449 0.53149619 -1.51839408 0.30655786
-1.53644982
[37] -0.30097613 -0.52827990 -0.65209478 -0.05689678 -1.91435943
1.17658331
[43] -1.66497244 -0.46353040 -1.11592011 -0.75081900 2.08716655
0.01739562
[49] -1.28630053 -1.64060553
> y
[1] 0.45018710 -0.01855983 -0.31806837 -0.92936215 -1.48746031
-1.07519230
[7] 1.00002880 -0.62126669 -1.38442685 1.86929062 0.42510038
-0.23864710
[13] 1.05848305 0.88642265 -0.61924305 2.20610246 -0.25502703
-1.42449465
[19] -0.14439960 0.20753834 2.30797840 0.10580237 0.45699881
-0.07715294
[25] -0.33400084 -0.03472603 0.78763961 2.07524501 1.02739244
1.20790840
[31] -1.23132342 0.98389557 0.21992480 -1.46725003 0.52102274
-0.15875460
[37] 1.46458731 -0.76608200 -0.43021175 -0.92610950 -0.17710396
0.40201178
[43] -0.73174817 0.83037317 -1.20808279 -1.04798441 1.44115771
-1.01584747
[49] 0.41197471 -0.38107605
In 1.7.1, the same code gives the same x and y and rho values, but
more reasonable p-values:
> cor.test(x,y,method="spearman")
Spearman's rank correlation rho
data: x and y
S = 23640, p-value = 0.3482
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
-0.1351741
> x <- rnorm(50)
> y <- rnorm(50)
> cor.test(x,y,method="spearman")
Spearman's rank correlation rho
data: x and y
S = 17248, p-value = 0.2322
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.1717647
More information about the R-devel
mailing list