Announcement

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

  • recovering the estimate of an interaction term using margins

    Hi All,

    I am trying to recover the estimates of an interaction term produced by -regress- using -margins- (followed by -lincom-).

    In the example below, the estimates for foreign and bin_wt derived by -margins- / -lincom- are the same as those as the coefficients in the regress output.

    However, I can't figure out how to replicate the interaction term estimate of -2.742342 for 1.foreign#1.bin_wt in the regression output.

    Thanks in advance!

    Ariel


    Code:
    sysuse auto
    gen bin_wt = weight > 3020
    regress mpg i.foreign##i.bin_wt
    margins foreign#bin_wt, coefl post
    lincom _b[1.foreign#0bn.bin_wt]-_b[0bn.foreign#0bn.bin_wt] // reproduces coefficient for foreign
    lincom _b[0bn.foreign#1.bin_wt]- _b[0bn.foreign#0bn.bin_wt] // reproduces coefficient for bin_wt

  • #2
    Code:
    lincom (_b[1.foreign#1.bin_wt]-_b[0.foreign#1.bin_wt]) - (_b[1.foreign#0.bin_wt] - _b[0.foreign#0.bin_wt])
    That is why interaction terms like this are the basis of "difference in differences" analysis.

    Comment


    • #3
      Well, in this saturated model, the coefficient of the interaction term is recovered as

      Code:
      lincom  ///
          (_b[1.foreign#1.bin_wt]-_b[0bn.foreign#1.bin_wt]) ///
          - (_b[1.foreign#0bn.bin_wt]-_b[0bn.foreign#0bn.bin_wt])

      Comment


      • #4
        To add to the suggestions, you could also use -margins- directly.

        Code:
        margins foreign, dydx(bin_wt) pwcompare
        margins r.foreign, dydx(bin_wt)
        This approach would also work to get interaction effects if -bin_wt- were a continuous variable. Think about it as -margins- computing double derivatives.

        Comment


        • #5
          Thank you all!

          Comment

          Working...
          X