I always thought that *
and :
meant the same thing when adding interaction terms in R formulas. For example:
amount_of_gas ~ temperature*gas_type
amount_of_gas ~ temperature:gas_type
However, now that I've started using Generalized Linear Models (glm()
in R) I see that these generate different scores, different estimates, etc. when I switch between the two. Can someone explain to me why this happens? Is it a problem with the stats
package in R?
##UPDATE## April 26th, 2021
It's been ~4.5 years or so since I asked this question and I keep getting notified that it still has a lot of traffic. Here's the short answer: y~x*z basically means: y~x+z+x:z while y~x:z is just the interaction of x and z (as described in the answer below)
From help(formula)
:
In addition to ‘+’ and ‘:’, a number of other operators are useful
in model formulae. The ‘*’ operator denotes factor crossing:
‘a*b’ interpreted as ‘a+b+a:b’.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With