Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Interaction between dichotomous and continuous predictors

    This is probably a stupid question, but I have a problem with the common technique for testing an interaction effect between a dichotomous variable and a continuous variable.

    Dichotomous variables should generelly be coded 0,1 rather than 1,2.

    An interaction variable is defined by multiplication. Commonly, researchers keep the 0,1 coding for the dichotomous variable when multiplying with the (centered) continuous variable to form an interaction variable. That is, the interaction variable is the same as the original continuous variable, except for all scores being defined as 0 if the individual scores 0 on the dichotomous variable (and being mean-centered).

    Why is this better than using 1,2 as scores to represent the dichotomous variable in the multiplication to form an interaction variable? (And, did I read someewhere a suggestion to code the dichotomous variable as -1,+1 in the multiplication procedure)?

    I understand the answer will lie in the simultaniously estimated main effects. It is still counterintuitive to me to use 0,1 when multiplying with a continuous variable to estimate interaction effects.

  • #2
    Guest:
    the following link might be interesting as far as dummy (or categorical at large) variables coding is concerned: https://www.researchgate.net/post/Do...inal_variables.
    The main reason why 0/1 dummy coding (when two categories are of interest) is preferred rests on the fact that it makes easier (i.e., with no rescaling) to retrieve a proportion (which is, in turn, the point estimate of a probability, mandatorily bounded between 0 and 1),as you can see from the following toy-example:
    Code:
    . set obs 10
    number of observations (_N) was 0, now 10
    
    . g A=1 in 1/5
    (5 missing values generated)
    
    . replace A=0 if A==.
    (5 real changes made)
    
    . g B=1 in 1/5
    (5 missing values generated)
    
    . replace B=2 if B==.
    (5 real changes made)
    
    . su
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
               A |         10          .5    .5270463          0          1
               B |         10         1.5    .5270463          1          2
    As fa as interaction mechanism in concerned, I would point you out to the following (lovely short) textbook: https://uk.sagepub.com/en-gb/eur/int...ion/book225910.
    Last edited by sladmin; 11 Dec 2017, 09:53. Reason: anonymize poster
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      The underlying concept behind interactions is this:

      y = b0 + b1*x + b2*z+ other terms, where b1 depends on another variable, z: b1 = c0 + c1*z. If you substitute this second equation into the first, you get:

      y = b0 + (c0 + c1*z)*x + b2*z + etc. = b0 + c0*x + c1*x*z + b2*z +etc .

      So that's why interaction terms are represented as products. Now notice that there is nothing at all in this derivation that relies on any particular coding of either x or z. So you can code the variables in any way that makes sense to you and this rubric still applies.

      But the coding does affect the interpretation. If x is coded 0,1, then the equations for y conditional on the values of x are:

      y = b0 + b2*z + etc. if x = 0
      y = (b0 +c0) + (c1+b2)*z +etc. if x = 1.

      If, however, x is coded 1, 2, then the equations for y conditional on the values of x are:

      y = (b0 + c0) + (c1+b2)*z + etc. if x = 1
      y = (b0 + 2*c0) + (2*c1+b2)*z + etc. if x = 2

      This is clearly more complicated and inconvenient to work with. The virtue of the 0,1 coding is that the coefficients generated have simple and direct relationships to the effects in the model and require only trivial amounts of calculation. Any coding other than 0, 1 requires that you sit down and algebraically work out how to put the regression coefficients together in order to calculate any particular marginal effect. With 0, 1 coding, it's maximally simple, to the point of being almost brainless.

      When coding models in Stata, you are strongly advised to use factor variable notation. Coding this model as -regress y i.x##i.z- (or, if, say z is continuous, i.x##c.z), Even if you originally coded x as 7, 823, Stata will generate a new virtual variable with 0/1 coding for you and calculate the interaction terms with for you. So you can, in effect, have your cake and eat it too. Better still, when you later want the predicted values of y at interesting values of x and z, or marginal effects of x and z at interesting values of the other, you can get them with the -margins- command, without having to do the algebra of figuring out what combinations of the regression coefficients are needed. Stata does all the recoding to 0/1 variables (for dichotomies) internally and handles the interaction calculations correctly for you.

      Added: Crossed with Carlo's post, which makes another good point.

      Comment


      • #4
        Thanks to both Carlo and Clyde for answers!

        I was strongly in favour of coding dichotomous variables 0 and 1 (Group_1 = 0, Group_2 = 1), but I think that Carlo and Clyde provide nice answers. My confustion was about the interaction variable.

        The coding with 0 for everyone in Group 1 on the interaction variable may be counterintuitive at first sight, but their scores on the continuous variable is already reflected by the main effect.
        Last edited by sladmin; 11 Dec 2017, 09:53. Reason: anonymize poster

        Comment

        Working...
        X