Re: [Rd] Numerical stability in chisq.test

2017-12-29 Thread Jan Motl
Hi, there is also PR#8224, which seems to be relevant. I executed the following code: ## Modify the function chisq.test2 <- edit(chisq.test) # Modify to use increasing order of sorting at line 57 ## PR#8224 (patological contingency table) m <- matrix(c(1,0,7,16),2,2); # Original original <-

Re: [Rd] Numerical stability in chisq.test

2017-12-28 Thread peter dalgaard
> On 28 Dec 2017, at 13:08 , Kurt Hornik wrote: > >> Jan Motl writes: > >> The chisq.test on line 57 contains following code: >> STATISTIC <- sum(sort((x - E)^2/E, decreasing = TRUE)) > > The preceding 2 lines seem relevant: > >## Sorting before summing may look strange,

Re: [Rd] Numerical stability in chisq.test

2017-12-28 Thread Kurt Hornik
> Jan Motl writes: > The chisq.test on line 57 contains following code: > STATISTIC <- sum(sort((x - E)^2/E, decreasing = TRUE)) The preceding 2 lines seem relevant: ## Sorting before summing may look strange, but seems to be ## a sensible way to deal with round

[Rd] Numerical stability in chisq.test

2017-12-27 Thread Jan Motl
The chisq.test on line 57 contains following code: STATISTIC <- sum(sort((x - E)^2/E, decreasing = TRUE)) However, based on book "Accuracy and stability of numerical algorithms" available from: http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%