s-news
[Top] [All Lists]

Re: product of numeric variables in lm

To: <s-news@lists.biostat.wustl.edu>
Subject: Re: product of numeric variables in lm
From: "Harald Hoogstrate" <Hoogstrate@POINTLOGIC.NL>
Date: Mon, 20 Jan 2003 16:05:49 +0100
Thread-index: AcLAk64me3fxAHJwQtuHnJug7v/VgwAASWTg
Thread-topic: product of numeric variables in lm
OK, three answers within 5 minutes, must be a speedrecord.
 
This one from Beth Atkinson best explains the S+ behaviour:
 
"a*b is a + b + a:b
The definition you used of D$a*D$b only includes the interaction term and not the main effects.
If you only want the interaction, use lm(y~c+a:b,data="" class=987350115-20012003>"
 
Thanks all,
Harald
 
 
 
 
-----Original Message-----
From: Harald Hoogstrate
Sent: Monday, January 20, 2003 15:53
To: s-news@lists.biostat.wustl.edu
Subject: product of numeric variables in lm

Dear all,
 
I am doing a regression with lots of numerical variables on S+ 6.1.
Now I want to include the product of two variables a and b in my regression:
 
lm(y~c+a*b,data="">
 
and I find that the result is very different from what I get if I define D$ab<-D$a*D$b and try
 
lm(y~c+ab,data="">
 
So my questions: what does * do and, more importantly, how can I include the product of two variables without first defining them in my dataframe.
 
Thanks for any help,
 
Harald
<Prev in Thread] Current Thread [Next in Thread>