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
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,
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
3 matches
Mail list logo