An "interaction" term in a regression model is just another name for "product" regardless of whether you are doing ordinary least-squares, logistic, or other types of regression. If 0/1 means FALSE/TRUE (in that order) in your coding for each of cough
and fever
, then their product is 1 only when both are TRUE. In that case, either way will work: in principle.
There are three practical considerations in applying that principle, however, that argue against trying to construct the interaction term as a separate predictor yourself.
The first is terminological. The "*
" symbol generally used for multiplication in an expression has a special meaning in an R formula. In an R formula, as Glen_b says in comments, cough*fever
expands to each of the individual terms plus their product. With the ":
" symbol representing just the product (as R interprets it within a formula), cough*fever
in a formula expands to cough + fever + cough:fever
. If R processes the last formula you showed, it expands cough*fever
that way and removes the extra individual cough
and fever
terms before proceeding.
Second is the coding of categorical predictors. If you coded your binary predictors as 1/2 instead of 0/1 and tried to construct your own product/interaction term, you wouldn't get the same regression coefficients as if R had done the expansion of cough*fever
for you. That's the case in this related question. With an unordered categorical predictor, R chooses one level to be the "reference" category and sets its internal coding to 0. A related source of confusion: the choice of 0-coded reference category that R makes can be different from what other software makes (e.g., choosing the first versus the last among category names in alphabetical order). Be careful in comparing results obtained with different statistical software systems.
Third, as Noah emphasizes in another answer, letting the software do the expansion can help with downstream processing of the regression results. For example, the rms
package in R has some very useful functions for evaluating the overall significance of interactions and nonlinear terms in regressions. Those functions, however, need to know that there were interactions in the original model. If you code an interaction as a separate predictor yourself, you lose that downstream functionality.
*
is a symbol for the 'full' interaction model -- main effects plus interaction. That is,cough*fever
is equivalent tocough + fever + cough:fever
and that last term of the three is actually the interaction term. When you specifycough + fever + cough*fever
you're asking forcough + fever + cough + fever + cough:fever
-- but of course the redundant terms are all dropped. $\endgroup$?formula
for details, or the manual An Introduction to R Sec 11.1 (which manual comes with R and is accessible from theHelp
menu tab). $\endgroup$