[R] interaction effects in a Linear model

Chuck Cleland ccleland at optonline.net
Mon Nov 23 12:35:43 CET 2009


On 11/23/2009 1:06 AM, ashok varma wrote:
> hello,
> 
> i am fitting a Linear model using R. I have to fit the model considering all
> the interaction effects of order 1 of the independent variables. But I have
> 9 variables. So, it will be difficult for me to write all the 36
> combinations in the model. Can anyone please help how to get this done in
> much smarter way??

  This will include all main effects and two-way interactions:

lm(Y ~ (A + B + C + D + E + F + G + H + I)^2, data=mydata)

> thanks a lot,
> Ashok Varma.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list