Announcement

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

  • Interaction terms

    Dear Stata experts,

    I have some problems understanding the regression outputs with interactions in Stata. I have 4 variables, 1 Dummy and 3 continuous, and want to interact them in a specific way (1 two-way and 1 three-way interaction). I always thought that it is the same to multiply the variables before the regression or to simply use the interaction command (#) in Stata. However, the following commands lead to completely different results:

    Code:
    1) reg var_1 var_2 c.var_2#D c.var_2#D#c.var_3
    
    2) gen int_1=var_2*D
       gen int_2=var_2*D*var_3
    
       reg var_1 var_2 int_1 int_2
    Like I said, var_1, var_2 and var_3 are continous variables and D is a 0/1-dummy.

    Does anyone know why this happens or what my mistake is?

    Thank you!

  • #2
    Rick:
    please report not only what you typed, but also what Stata gave you back. Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      1)
      Click image for larger version

Name:	1).PNG
Views:	1
Size:	14.1 KB
ID:	1324133


      2)
      Click image for larger version

Name:	2).PNG
Views:	1
Size:	11.8 KB
ID:	1324134



      I hope it's okay that way? Sorry, I know using dataex would be better, but I don't know yet how exactly to use it, so it's faster that way.

      Comment


      • #4
        Rick:
        when you create an interaction by hand the numbers in the categorical variable (which are meaningless in quantitative terms) do quantitatively contribute to the result of the multiplication, leading you astray.
        That's way is wiser to rely on -fvvarlist- wonderful capabilities for creating interactions.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Let me also note that in both approaches, you are including interaction terms without including the corresponding "main effects" of D and var3, nor the two-way subinteractions of your three way interaction. Now, that is OK in some rather unusual situations, but it is usually a badly-specified model whose results, even if you can get them consistently, would be uninterpretable. Are you sure that's what you want? Perhaps you really mean

          Code:
          regress var1 c.var2##c.var3##i.D

          Comment

          Working...
          X