Interaction in logistic regression in R [closed]

The terms sex*weight and sex:weight have different meanings. The first one (*) is a shorthand for sex + weight + sex:weight, that is, for including each parameter AND the interaction. sex:weight only adds the interaction term. Therefore the resulting models differ.

As far as I know, models should always include the lower level terms which are involved in interactions. Otherwise, the interaction can not be interpreted (easily), see for instance here: https://stats.stackexchange.com/q/11009/133735

#model including both parameters and their interaction with "*"
m1 <- lm(Sepal.Length ~  Petal.Width * Petal.Length, data = iris)
coef(m1)

             (Intercept)              Petal.Width             Petal.Length Petal.Width:Petal.Length 
               4.5771709               -1.2393154                0.4416762                0.1885887 
#model including both pars and interaction (all terms spelled out)
m2 <- lm(Sepal.Length ~  Petal.Width + Petal.Length + Petal.Width:Petal.Length, data = iris)
coef(m2)
             (Intercept)              Petal.Width             Petal.Length Petal.Width:Petal.Length 
               4.5771709               -1.2393154                0.4416762                0.1885887

#model only including the interaction
m3 <- lm(Sepal.Length ~  Petal.Width:Petal.Length, data = iris)
coef(m3)
             (Intercept) Petal.Width:Petal.Length 
               4.9704818                0.1506457

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top