From sgiannerini at gmail.com  Thu Oct 20 10:10:01 2005
From: sgiannerini at gmail.com (Simone Giannerini)
Date: Thu, 20 Oct 2005 10:10:01 +0200
Subject: [Rd] numerical issues in chisq.test(simulate=TRUE) (PR#8224)
In-Reply-To: <20051020060822.CA694DD04@slim.kubism.ku.dk>
References: <20051020060822.CA694DD04@slim.kubism.ku.dk>
Message-ID: <3c12769c0510200110oc99f32cn890340c7611544a3@mail.gmail.com>

Hi,

I obtain the same result under Win. XP SP2 on AMD 64 3700+

platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    2.0
year     2005
month    10
day      06
svn rev  35749
language R

> m <- matrix(c(1,0,7,15),2,2) ; chisq.test(m, sim=TRUE)$p.value
[1] 0.3598201

> m <- matrix(c(1,0,7,16),2,2) ; chisq.test(m, sim=TRUE)$p.value
[1] 0.0004997501

> m <- matrix(c(1,0,7,17),2,2) ; chisq.test(m, sim=TRUE)$p.value
[1] 0.3403298

Ciao
Simone

On 10/20/05, dgrove at fhcrc.org <dgrove at fhcrc.org> wrote:
> Hi,
>
> This report deals with p-values coming from chisq.test using
> the simulate.p=TRUE option.  The issue is numerical accuracy
> and was brought up in previous bug reports 3486 and 3896.
> The bug was considered fixed but apparently was only mostly
> fixed.  Just the typical problem of two values that are
> mathematically equal not ending up numerically equivalent.
>
> Consider this series of three 2x2 tables:
>
> [1,]    1    7
> [2,]    0   15
>
> [1,]    1    7
> [2,]    0   16
>
> [1,]    1    7
> [2,]    0   17
>
>
> The pvals returned from chisq.test(m, sim=TRUE)$p.value are
>  0.3543228, 0.0004997501 and 0.3273363 respectively.
>
> The 2nd seems a bit unlikely, huh?
>
> I checked into it and the value I'm getting for the statistic
> (calculated in R code) is 4*.Machine$double.eps less than the
> value (which should be equal) that is returned from the C-code
> that does the simulation.
>
>
> Code for creating/testing the three matrices shown above:
> m <- matrix(c(1,0,7,15),2,2) ; chisq.test(m, sim=TRUE)$p.value
> m <- matrix(c(1,0,7,16),2,2) ; chisq.test(m, sim=TRUE)$p.value
> m <- matrix(c(1,0,7,17),2,2) ; chisq.test(m, sim=TRUE)$p.value
>
>
> Running SuSE9.3 on a AMD Athlon4000+
>
>
> > version
> platform i686-pc-linux-gnu
> arch     i686
> os       linux-gnu
> system   i686, linux-gnu
> status   Patched
> major    2
> minor    1.1
> year     2005
> month    07
> day      29
> language R
>
>
> Thanks,
> Doug
>
>
> Douglas Grove
> Statistical Research Associate
> Fred Hutchinson Cancer Research Center
> Seattle WA 98109
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


--
______________________________________________________

Simone Giannerini
Dipartimento di Scienze Statistiche "Paolo Fortunati"
Universita' di Bologna
Via delle belle arti 41 - 40126  Bologna,  ITALY
Tel: +39 051 2098248  Fax: +39 051 232153
E-mail: giannerini at stat.unibo.it



[Rd] numerical issues in chisq.test(simulate=TRUE) (PR#8224)
Simone Giannerini