[R] ANOVA and permutation tests : beware of traps

2014-09-23 Thread Stéphane Adamowicz
Recently, I came across a strange and potentially troublesome behaviour of the lm and aov functions that ask questions about calculation accuracy. Let us consider the 2 following datasets dat1 dat2 : (dat1 - data.frame(Y=c(1:3, 10+1:3), F=c(rep(A,3), rep(B,3 Y F 1 1 A 2 2 A 3 3 A 4

Re: [R] ANOVA and permutation tests : beware of traps

2014-09-23 Thread Joshua Wiley
Hi Stephane, This is the well known result of limitted floating point precision (e.g., http://www.validlab.com/goldberg/addendum.html). Using a test of approximate rather than exact equality shows R yields the correct answer: nperm - 1 Fperm - replicate(n=nperm, anova(lm(sample(Y) ~ F,

Re: [R] ANOVA and permutation tests : beware of traps

2014-09-23 Thread Prof Brian Ripley
Beware of the trap of listening to people with no knowledge of basic numerical methods! It really is basic that the results of floating-point computer calculations depends on the order in which they are done (and the compiler can change the order). Using == on such calculations is warned