[Rd] But in add1, presumably in add1.lm (PR#7842)

berwin at maths.uwa.edu.au berwin at maths.uwa.edu.au
Fri May 6 10:37:15 CEST 2005


xDear all,

while investigating some data, I noticed a strange behaviour of add1
which is reproduced below using a data set from a recommended
package.

Essentially, it seems the inclusion of an interaction term by add1 is
only correctly handled if the order of the variables in the
interaction coincide with the order in the formula that is given as
the scope.  (I have a vague memory that such a bug was already once
posted some time ago, but could not find anything in the bug report
repository.)  

I noticed this problem on R 2.1.0, but it also exists in all other R
version installed on my machine (R 1.8.1, R 1.9.1, R 2.0.0 and R
2.0.1).

Cheers,

        Berwin

> library(MASS)
> fmb <- lm(Days ~ .^4, quine)

> fm0 <- lm(Days ~ Eth + Sex, quine)
> add1(fm0, formula(fmb), test="F")
Single term additions

Model:
Days ~ Eth + Sex
        Df Sum of Sq   RSS   AIC F value   Pr(F)
<none>               35045   806                
Age      3      2119 32926   803  3.0030 0.03263
Lrn      1       162 34882   808  0.6605 0.41773
Eth:Sex  1       141 34904   808  0.5724 0.45057

> fm0 <- lm(Days ~ Sex + Eth, quine)
> add1(fm0, formula(fmb), test="F")
Single term additions

Model:
Days ~ Sex + Eth
        Df Sum of Sq   RSS   AIC F value   Pr(F)
<none>               35045   806                
Age      3      2119 32926   803  3.0030 0.03263
Lrn      1       162 34882   808  0.6605 0.41773
Eth:Sex  0         0 35045   806                

> fm0 <- lm(Days ~ Age + Eth, quine)
> add1(fm0, formula(fmb), test="F")
Single term additions

Model:
Days ~ Age + Eth
        Df Sum of Sq   RSS   AIC F value  Pr(F)
<none>               33049   802               
Sex      1       123 32926   803  0.5226 0.4710
Lrn      1       598 32450   801  2.5815 0.1104
Eth:Age  0         0 33049   802               

> fm0 <- lm(Days ~Eth + Age , quine)
> add1(fm0, formula(fmb), test="F")
Single term additions

Model:
Days ~ Eth + Age
        Df Sum of Sq   RSS   AIC F value    Pr(F)
<none>               33049   802                 
Sex      1       123 32926   803  0.5226 0.470950
Lrn      1       598 32450   801  2.5815 0.110369
Eth:Age  3      2837 30212   795  4.3194 0.006047

--please do not edit the information below--

Version:
 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status = 
 major = 2
 minor = 1.0
 year = 2005
 month = 04
 day = 18
 language = R

Search Path:
 .GlobalEnv, package:methods, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, Autoloads, package:base



More information about the R-devel mailing list