Full_Name: Ian Wilson
Version: R-1.8.0
OS: Windows (but own compilation)
Submission from: (NULL) (139.133.7.38)
the p-value is incorrect for cor.test using method "spearman" in R-1.8.0. This
was not the case in R-1.7.1.
Version R-1.8.0 on Windows
cor.test(rnorm(50),rnorm(50),method="spearman")
Spearman's rank correlation rho
data: rnorm(50) and rnorm(50)
S = 20486, p-value = < 2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.01627851
cor.test(rnorm(50),rnorm(50),method="spearman")
Spearman's rank correlation rho
data: rnorm(50) and rnorm(50)
S = 22006, p-value = 1
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
-0.05671068
Without knowing the seed used it is impossible for us to reproduce this,
but I am not seeing anything strange.
Could you please reply with a reproducible example (and list the data used
too, in case the random number generation is the issue).
On Wed, 22 Oct 2003 i.wilson@maths.abdn.ac.uk wrote:
Full_Name: Ian Wilson
Version: R-1.8.0
OS: Windows (but own compilation)
Submission from: (NULL) (139.133.7.38)
the p-value is incorrect for cor.test using method "spearman" in R-1.8.0. This
was not the case in R-1.7.1.
Version R-1.8.0 on Windows
cor.test(rnorm(50),rnorm(50),method="spearman")
Spearman's rank correlation rho
data: rnorm(50) and rnorm(50)
S = 20486, p-value = < 2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.01627851
cor.test(rnorm(50),rnorm(50),method="spearman")
Spearman's rank correlation rho
data: rnorm(50) and rnorm(50)
S = 22006, p-value = 1
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
-0.05671068
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
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
[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
I've now tried the code
set.seed(1)
x <- rnorm(50)
y <- rnorm(50)
cor.test(x,y,method="spearman")
x <- rnorm(50)
y <- rnorm(50)
cor.test(x,y,method="spearman")
in r-patched (which gives apparently correct results), and r-devel,
which gives the first result correct, the second incorrect; when
repeated, both are bad.
Duncan Murdoch