I can only assume I'm betraying my ignorance here, but this is not what I would expect. I'm getting the following from a stepwise selection (with both step and stepAIC): > step(lm(sqrt(Grids)~ SE + Edge + NH), scope=~ (Edge + SE + NH)^2) Start: AIC= 593.56 sqrt(Grids) ~ SE + Edge + NH Df Sum of Sq RSS AIC <none> 2147.0 593.6 + Edge:NH 1 3.0 2143.9 595.1 + SE:NH 4 23.2 2123.8 598.4 - NH 1 75.8 2222.8 601.6 - Edge 1 448.7 2595.7 646.4 - SE 4 1033.7 3180.6 699.1 My problem is that the SE:Edge term is not added. Now, I know that I've specified the terms in a different order in the start model and the scope, but this shouldn't matter, should it? Aren't these model specifications commutative? Am I missing something important, or is this just an obscure feature? Bob -- Bob O'Hara Dept. of Mathematics and Statistics P.O. Box 4 (Yliopistonkatu 5) FIN-00014 University of Helsinki Finland Telephone: +358-9-191 23743 Mobile: +358 50 599 0540 Fax: +358-9-191 22 779 WWW: http://www.RNI.Helsinki.FI/~boh/ Journal of Negative Results - EEB: http://www.jnr-eeb.org
"Anon." <bob.ohara at helsinki.fi> writes:> I can only assume I'm betraying my ignorance here, but this is not > what I would expect. > > I'm getting the following from a stepwise selection (with both step > and stepAIC): > > > step(lm(sqrt(Grids)~ SE + Edge + NH), scope=~ (Edge + SE + NH)^2) > Start: AIC= 593.56 > sqrt(Grids) ~ SE + Edge + NH > > Df Sum of Sq RSS AIC > <none> 2147.0 593.6 > + Edge:NH 1 3.0 2143.9 595.1 > + SE:NH 4 23.2 2123.8 598.4 > - NH 1 75.8 2222.8 601.6 > - Edge 1 448.7 2595.7 646.4 > - SE 4 1033.7 3180.6 699.1 > > > My problem is that the SE:Edge term is not added. Now, I know that > I've specified the terms in a different order in the start model and > the scope, but this shouldn't matter, should it? Aren't these model > specifications commutative? > > Am I missing something important, or is this just an obscure feature?Looks a bit odd, but the first thing I would do is to check whether the model with that term added actually makes sense: m1 <- lm(sqrt(Grids)~ SE + Edge + NH) m2 <- update(m1,~.+SE:Edge) anova(m1,m2) My hunch is that you'l find zero DF between the two models, but try it and see. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
There seems to be some obscure features in step() when you have interaction terms: their interpretation is order sensitive. Term A:B is regarded to be something else than B:A. Sometimes this results in error Error in factor.scope(ffac, list(add = fadd, drop = fdrop)) : upper scope does not include model Just because R internally decides to order terms differently than in the scope (this may happen even when you have produced the scope by first fitting the maximal model, and then extracting that using scope=formula()). I once was diligent enough to trace this to a certain C function where this ordering was done, but I was not clever enough to instantly know how to change the behaviour. cheers, jari oksanen On 19 Mar 2004, at 17:25, Anon. wrote:> I can only assume I'm betraying my ignorance here, but this is not > what I would expect. > > I'm getting the following from a stepwise selection (with both step > and stepAIC): > > > step(lm(sqrt(Grids)~ SE + Edge + NH), scope=~ (Edge + SE + NH)^2) > Start: AIC= 593.56 > sqrt(Grids) ~ SE + Edge + NH > > Df Sum of Sq RSS AIC > <none> 2147.0 593.6 > + Edge:NH 1 3.0 2143.9 595.1 > + SE:NH 4 23.2 2123.8 598.4 > - NH 1 75.8 2222.8 601.6 > - Edge 1 448.7 2595.7 646.4 > - SE 4 1033.7 3180.6 699.1 > > > My problem is that the SE:Edge term is not added. Now, I know that > I've specified the terms in a different order in the start model and > the scope, but this shouldn't matter, should it? Aren't these model > specifications commutative? > > Am I missing something important, or is this just an obscure feature? > > Bob > > -- > Bob O'Hara > > Dept. of Mathematics and Statistics > P.O. Box 4 (Yliopistonkatu 5) > FIN-00014 University of Helsinki > Finland > Telephone: +358-9-191 23743 > Mobile: +358 50 599 0540 > Fax: +358-9-191 22 779 > WWW: http://www.RNI.Helsinki.FI/~boh/ > Journal of Negative Results - EEB: http://www.jnr-eeb.org > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html