[R] R stepping through multiplie interactions

Greg Snow Greg.Snow at imail.org
Fri Jan 23 19:08:46 CET 2009


Z ~ (A+B+C+D)^3 means give all main effects and interactions up to the 3 way interactions, but not above (change ^3 to ^2 to limit to 2 way interactions).

You can do a semi manual stepwise procedure using the add1 and drop1 commands or the addterm and dropterm commands in the MASS package.  But be aware that using a final model gained from stepwise procedures tends to give estimates of the slopes biased away from 0.  Better options have been discussed quite a bit on this list (search the archives) and Frank Harrell's book "Regression Modeling Strategies" gives more information.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of ppeetteerr
> Sent: Friday, January 23, 2009 10:45 AM
> To: r-help at r-project.org
> Subject: [R] R stepping through multiplie interactions
> 
> 
> I have a lm in R in the form
> model <- lm( Z ~ A*B*C*D,data=mydata)
> I want to run the model and include all interactions expect the 4 way
> (A:B:C:D) is there an easy way of doing this? I then want to step down
> the
> model eliminating the non-significant terms I understand step() does
> this
> but how would I do it by hand?
> --
> View this message in context: http://www.nabble.com/R-stepping-through-
> multiplie-interactions-tp21629339p21629339.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list