I'm trying to use interaction terms in lm and for the following types of models:

fit3_hs <- lm(kidmomhsage$kid_score ~ kidmomhsage$mom_age + kidmomhsage$mom_hs + kidmomhsage$mom_age * 1) fit3_nohs <- lm(kidmomhsage$kid_score ~ kidmomhsage$mom_age + kidmomhsage$mom_hs + kidmomhsage$mom_age * 0)

where you see the last term being the interaction term (it's mom_age*mom_hs where mom_hs takes values 0 or 1), the results are causing a bit of confusion.

fit3_hs returns:

Call:
lm(formula = kidmomhsage$kid_score ~ kidmomhsage$mom_age + kidmomhsage$mom_hs +
    kidmomhsage$mom_age * 1)

Coefficients:
        (Intercept)  kidmomhsage$mom_age
            70.4787               0.3261
 kidmomhsage$mom_hs
            11.3112


fit3_nohs returns:

Call:
lm(formula = kidmomhsage$kid_score ~ kidmomhsage$mom_age + kidmomhsage$mom_hs +
    kidmomhsage$mom_age * 0)

Coefficients:
kidmomhsage$mom_age   kidmomhsage$mom_hs
              3.368               11.568

Now why is (Intercept) term missing from the second one?
Also since in the first one the interaction term's coefficient should be added to the coefficient of mom_age, then is the return value of kidmomhsage$mom_age 0.3261 the sum of the coefficient of mom_age and the coefficient of the interaction term? Or would I need to produce the sum myself somehow?

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to