30

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)

Leo Ohyama
  • 887
  • 1
  • 9
  • 26

1 Answers1

28

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’.
Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725