i.wilson@maths.abdn.ac.uk
2003-Oct-22 12:11 UTC
[Rd] Something strange in cor.test in R-1.8.0 (PR#4718)
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
Prof Brian Ripley
2003-Oct-22 12:50 UTC
[Rd] Something strange in cor.test in R-1.8.0 (PR#4718)
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 > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel > >-- 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
i.wilson@maths.abdn.ac.uk
2003-Oct-22 14:34 UTC
[Rd] Something strange in cor.test in R-1.8.0 (PR#4718)
reproducible example> b1 <- c(42.5565911271682, 27.5164947336246, 39.483642950093,103.942262842055, 36.0059074090041, 38.5628716462492, 30.4961003157125, 41.4309 .... [TRUNCATED]> b2 <- c(32.38938053, 22.44444444, 33.05454545, 42.21176471,40.10869565, 29.80952381, 24.79452055, 25.18518519, 37.09677419, 31.32727273)> cor.test(b1, b2, method = "spearman")Spearman's rank correlation rho data: b1 and b2 S = 66, p-value = < 2.2e-16 alternative hypothesis: true rho is not equal to 0 sample estimates: rho 0.6> R.version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 8.0 year 2003 month 10 day 08 language R>-----Original Message----- From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk] Sent: 22 October 2003 11:52 To: i.wilson@maths.abdn.ac.uk Cc: r-devel@stat.math.ethz.ch; R-bugs@biostat.ku.dk Subject: Re: [Rd] Something strange in cor.test in R-1.8.0 (PR#4718) 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 > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel > >-- 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
maechler@stat.math.ethz.ch
2003-Oct-22 16:08 UTC
[Rd] Something strange in cor.test in R-1.8.0 (PR#4718)
>>>>> "Duncan" == Duncan Murdoch <dmurdoch@pair.com> >>>>> on Wed, 22 Oct 2003 08:17:32 -0400 writes:Duncan> 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") Duncan> in r-patched (which gives apparently correct results), and r-devel, Duncan> which gives the first result correct, the second incorrect; when Duncan> repeated, both are bad. Hmm, funny. I get repeatable results in in R 1.7.1 , 1.8.0, R-patched and R-devel (all on Linux), with an (ugly but convenient) 1-liner :> set.seed(1); for(k in 1:2){x <- rnorm(50);y <- rnorm(50);print(unlist(cor.test(x,y,method="spearman")[1:4]))}statistic.S p.value estimate.rho 23640.0000000 0.3482088 -0.1351741 statistic.S p.value estimate.rho 1.724800e+04 2.322263e-01 1.717647e-01 --- Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <><
p.dalgaard@biostat.ku.dk
2003-Oct-23 13:40 UTC
[Rd] Something strange in cor.test in R-1.8.0 (PR#4718)
Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> writes:> >>>>> maechler writes: > > >>>>> "Duncan" == Duncan Murdoch <dmurdoch@pair.com> > >>>>> on Wed, 22 Oct 2003 08:17:32 -0400 writes: > > Duncan> 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") > > Duncan> in r-patched (which gives apparently correct results), and r-devel, > Duncan> which gives the first result correct, the second incorrect; when > Duncan> repeated, both are bad. > > Hmm, > > funny. > > > I get repeatable results in in R 1.7.1 , 1.8.0, R-patched and > > R-devel (all on Linux), > > > with an (ugly but convenient) 1-liner : > > >> set.seed(1); for(k in 1:2){x <- rnorm(50);y <- rnorm(50);print(unlist(cor.test(x,y,method="spearman")[1:4]))} > > statistic.S p.value estimate.rho > > 23640.0000000 0.3482088 -0.1351741 > > statistic.S p.value estimate.rho > > 1.724800e+04 2.322263e-01 1.717647e-01 > > I get the same on Debian GNU/Linux. > > Where do we stand on this? Windows-specific?Probably, but of a nasty kind which I think we need to get to the bottom of. As I see it there are two possible causes 1. A bug in a Windows library or compiler. Potentially that could affect everything else. 2. A bug in ctest that just happens only to cause visible damage on Windows, but perhaps invisible damage elsewhere. Either way, I think we need to investigate. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
Kurt.Hornik@wu-wien.ac.at
2003-Oct-23 13:44 UTC
[Rd] Something strange in cor.test in R-1.8.0 (PR#4718)
>>>>> Peter Dalgaard writes:> Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> writes: >> >>>>> maechler writes: >> >> >>>>> "Duncan" == Duncan Murdoch <dmurdoch@pair.com> >> >>>>> on Wed, 22 Oct 2003 08:17:32 -0400 writes: >>Duncan> 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") >>Duncan> in r-patched (which gives apparently correct results), and r-devel, Duncan> which gives the first result correct, the second incorrect; when Duncan> repeated, both are bad.>> > Hmm, >> > funny. >> >> > I get repeatable results in in R 1.7.1 , 1.8.0, R-patched and >> > R-devel (all on Linux), >> >> > with an (ugly but convenient) 1-liner : >> >> >> set.seed(1); for(k in 1:2){x <- rnorm(50);y <- rnorm(50);print(unlist(cor.test(x,y,method="spearman")[1:4]))} >> > statistic.S p.value estimate.rho >> > 23640.0000000 0.3482088 -0.1351741 >> > statistic.S p.value estimate.rho >> > 1.724800e+04 2.322263e-01 1.717647e-01 >> >> I get the same on Debian GNU/Linux. >> >> Where do we stand on this? Windows-specific?> Probably, but of a nasty kind which I think we need to get to the > bottom of. As I see it there are two possible causes> 1. A bug in a Windows library or compiler. Potentially that could > affect everything else. > 2. A bug in ctest that just happens only to cause visible damage on > Windows, but perhaps invisible damage elsewhere.> Either way, I think we need to investigate.As Brian had written earlier in this thread, we need a reproducible example. If Duncan's example can be reproduced on Windows but not on Linux (and I cannot), odds are in favor of the problem being Windows specific. -k
ripley@stats.ox.ac.uk
2003-Oct-23 14:05 UTC
[Rd] Something strange in cor.test in R-1.8.0 (PR#4718)
On 23 Oct 2003, Peter Dalgaard wrote:> Kurt.Hornik@wu-wien.ac.at writes: > > > > Probably, but of a nasty kind which I think we need to get to the > > > bottom of. As I see it there are two possible causes > > > > > 1. A bug in a Windows library or compiler. Potentially that could > > > affect everything else. > > > 2. A bug in ctest that just happens only to cause visible damage on > > > Windows, but perhaps invisible damage elsewhere. > > > > > Either way, I think we need to investigate. > > > > As Brian had written earlier in this thread, we need a reproducible > > example. If Duncan's example can be reproduced on Windows but not on > > Linux (and I cannot), odds are in favor of the problem being Windows > > specific. > > No, odds are in favor of the *symptom* being Windows-specific. See > above... Problem is, we need a Windows guru to debug in that case.cor.test.default calls the second arg of prho as as.integer(q + 1), but someone altered the C code (at the last minute before 1.8.0 was frozen) to *double. So I think Peter is probably right. -- 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