# [R] anova error

David Winsemius dwinsemius at comcast.net
Wed Dec 1 16:51:15 CET 2010

```On Dec 1, 2010, at 9:18 AM, Peter Ehlers wrote:

> 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.

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.)

--
David.

>
> Peter Ehlers
>
> On 2010-12-01 05:44, Jean.Coursol at math.u-psud.fr wrote:
>> 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
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help