Skip to content

anova error

5 messages · Jean Coursol, Peter Ehlers, Ben Bolker +2 more

#
Just for fun

This small program gives negative Sum of Sq in anova (with R versions  
2.9.2 and 2.10.0) (linux 32 kernel 2.6.29.6-smp slackware 13.0) :

y = c(3.6, 5.0, 5.0, 4.6, 4.5, 4.3, 4.5, 5.1, 4.5, 4.3)
trans = as.factor(c("NT","NT","NT","NT","NT","T","T","T","T","T"))
lc = lm(y ~ trans)
l1 = lm(y ~ 1)

anova(l1,lc)

# Analysis of Variance Table
#
# Model 1: y ~ 1
# Model 2: y ~ trans
#   Res.Df   RSS Df  Sum of Sq F Pr(>F)
# 1      9 1.744
# 2      8 1.744  1 -2.220e-16           # negative Sum of Sq ????

anova(lc)  # is OK

# 2.9.2 version
# Analysis of Variance Table
#
# Response: y
#           Df    Sum Sq   Mean Sq   F value Pr(>F)
# trans      1 8.214e-32 8.214e-32 3.768e-31      1
# Residuals  8     1.744     0.218

# 2.10.0 version
# Analysis of Variance Table
#
# Response: y
#           Df Sum Sq Mean Sq F value Pr(>F)
# trans      1  0.000   0.000       0      1
# Residuals  8  1.744   0.218
#
It might be a good idea not to use an outdated version of R.
I don't see your "problem" in R 2.12.0.

Peter Ehlers
On 2010-12-01 05:44, Jean.Coursol at math.u-psud.fr wrote:
#
Peter Ehlers <ehlers <at> ucalgary.ca> writes:
These are essentially just round-off error in a problem with zero
noise: there is absolutely no practical difference between 2e-16 and
2e16.  If you really need to do something with these values that will
break if they are negative, see ?zapsmall ...
#
On Dec 1, 2010, at 9:18 AM, Peter Ehlers wrote:

            
Furthermore isn't it a bit <something> to be asking why the sign on a  
number that is effectively  zero happens to be negative? I would think  
that FAQ 7.31 applied even back in the 2.9 and 2.10 era.

(I still get a negative number in R 2.12.0 that is effectively zero,  
-4.4409e-16,  and rounded is exactly the same as the difference  
between sqrt(2)^2 and 2 in the FAQ entry, so if it were supposed to be  
"fixed" (which I'm not saying it should be) then it didn't occur until  
very recently.)
#
On Wed, Dec 1, 2010 at 9:02 AM, Ben Bolker <bbolker at gmail.com> wrote:
Well, actually there is a big difference between 2e-16 and 2e16.  I
think you meant to write 2e-16 and -2e-16