[R] Linear regression interaction terms

Ben Bolker bbolker at gmail.com
Mon Sep 19 15:06:51 CEST 2011


Andrey A <avakoa <at> gmail.com> writes:

> 
> Hello I performed a linear regression, my equation is Y = âo+ â1A + â2B +
> â3AB.
> Is there a way to separate interaction terms, say â3AB and plot it against a
> certain variable?
> Thanks, Andrew

  Not quite sure what you mean here.  Possibly something like

L1 <- lm(y~A*B,data=mydata)
p <- predict(L1,type="terms",terms="A:B")

 etc

?



More information about the R-help mailing list