Dear community, can anyone provide a snippet of code to force the lm() to fit a model with terms in the formula in an arbitrary order? I am interested in something like: lm(y ~ A * B + C, data=data) where the interaction of A and B should be in the formula before C. My goal is to simplify my presentation of models using the anova() statement. I have found that this should be possible using the terms.formula() function, but if anyone has an example that would be much appreciated. Cheers Andrew Andrew Robinson Senior Lecturer in Statistics Tel: +61-3-8344-9763 Department of Mathematics and Statistics Fax: +61-3-8344 4599 University of Melbourne, VIC 3010 Australia Email: a.robinson at ms.unimelb.edu.au Website: http://www.ms.unimelb.edu.au
RSiteSearch("keep.order") gave me http://finzi.psych.upenn.edu/R/Rhelp02a/archive/14240.html which has such an example, and points out another example is in demo(glm.vr). On Sun, 19 Feb 2006, Andrew Robinson wrote:> Dear community, > > can anyone provide a snippet of code to force the lm() to fit a model with > terms in the formula in an arbitrary order? I am interested in something > like: > > lm(y ~ A * B + C, data=data) > > where the interaction of A and B should be in the formula before C. My > goal is to simplify my presentation of models using the anova() statement. > I have found that this should be possible using the terms.formula() > function, but if anyone has an example that would be much appreciated. > > Cheers > > Andrew > > > Andrew Robinson > Senior Lecturer in Statistics Tel: +61-3-8344-9763 > Department of Mathematics and Statistics Fax: +61-3-8344 4599 > University of Melbourne, VIC 3010 Australia > Email: a.robinson at ms.unimelb.edu.au Website: http://www.ms.unimelb.edu.au > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Thanks to Brian Ripley and Ernst Hansen for their kindly replies to my question. Cheers Andrew On Sun, February 19, 2006 11:43 pm, Prof Brian Ripley said:> RSiteSearch("keep.order") gave me > > http://finzi.psych.upenn.edu/R/Rhelp02a/archive/14240.html > > which has such an example, and points out another example is in > demo(glm.vr). > > On Sun, 19 Feb 2006, Andrew Robinson wrote: > >> Dear community, >> >> can anyone provide a snippet of code to force the lm() to fit a model >> with >> terms in the formula in an arbitrary order? I am interested in >> something >> like: >> >> lm(y ~ A * B + C, data=data) >> >> where the interaction of A and B should be in the formula before C. My >> goal is to simplify my presentation of models using the anova() >> statement. >> I have found that this should be possible using the terms.formula() >> function, but if anyone has an example that would be much appreciated. >> >> Cheers >> >> Andrew >> >> >> Andrew Robinson >> Senior Lecturer in Statistics Tel: +61-3-8344-9763 >> Department of Mathematics and Statistics Fax: +61-3-8344 4599 >> University of Melbourne, VIC 3010 Australia >> Email: a.robinson at ms.unimelb.edu.au Website: >> http://www.ms.unimelb.edu.au >> >> ______________________________________________ >> R-help at stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide! >> http://www.R-project.org/posting-guide.html >> > > -- > Brian D. Ripley, ripley at stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 272595 >Andrew Robinson Senior Lecturer in Statistics Tel: +61-3-8344-9763 Department of Mathematics and Statistics Fax: +61-3-8344 4599 University of Melbourne, VIC 3010 Australia Email: a.robinson at ms.unimelb.edu.au Website: http://www.ms.unimelb.edu.au
Hi, I don't know why you want but to say the code you can try >body(lm) or simply type >lm The order in anova is important in nested design ! you can use the libre car and try another type of SS type. --------------------------------- [[alternative HTML version deleted]]