Announcement

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

  • Logit Marginal Effects at means with interaction terms

    Hi all,

    I am working on my MSc. and I have data for 201 participants who each made 457 choices (total choices ~ 91,000 choices). I am using a binary logit model of choice 1 and choice 2 groupings. I am using STATA 15. I have no problems running my logit regression (see example below) but I am having trouble with the interaction terms showing up when I do the marginal effects. The marginal effects for the interaction term disappears so I can't estimate the effect size for the interaction term. I have been trying to find the answer to this for a few days and I have read a lot about how to operationalize the commands (Thank you, Richard Williams & Clyde Schechter for all your answers especially). Obviously, I am either trying to do something I shouldn't be doing or going about it the wrong way. Any help would be appreciated greatly. I am clustering the standard errors by ID (of each person)-- also unsure if I should be doing that but it isn't the focus of this question.

    Background: anything with i. is a factor variable (0,1) and otherwise, it is continuous.

    . logit buy i.treatment##i.income_low i.female i.young i.fulltime i.children i.recentimmigrin
    > t i.highschool_or_below price nvs_score_total, cluster(ID)

    Iteration 0: log pseudolikelihood = -4419.9312
    Iteration 1: log pseudolikelihood = -4386.08
    Iteration 2: log pseudolikelihood = -4384.7678
    Iteration 3: log pseudolikelihood = -4384.765
    Iteration 4: log pseudolikelihood = -4384.765

    Logistic regression Number of obs = 91,857
    Wald chi2(11) = 59.14
    Prob > chi2 = 0.0000
    Log pseudolikelihood = -4384.765 Pseudo R2 = 0.0080

    (Std. Err. adjusted for 201 clusters in ID)
    ---------------------------------------------------------------------------------------
    | Robust
    buy | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    ----------------------+----------------------------------------------------------------
    1.treatment | -.2627016 .0917476 -2.86 0.004 -.4425235 -.0828797
    1.income_low | -.2187479 .1241379 -1.76 0.078 -.4620536 .0245579
    |
    treatment#income_low |
    1 1 | .4124181 .217789 1.89 0.058 -.0144404 .8392766
    |
    1.female | .0782018 .084832 0.92 0.357 -.0880658 .2444695
    1.young | -.2152019 .099856 -2.16 0.031 -.4109162 -.0194877
    1.fulltime | .0954429 .0888683 1.07 0.283 -.0787357 .2696215
    1.children | .0427962 .1040897 0.41 0.681 -.1612158 .2468082
    1.recentimmigrint | -.2436619 .1236873 -1.97 0.049 -.4860846 -.0012392
    1.highschool_or_below | .2040199 .1194476 1.71 0.088 -.030093 .4381329
    price | -.1089045 .0244309 -4.46 0.000 -.1567883 -.0610208
    n_score_total | .0225023 .0299007 0.75 0.452 -.0361019 .0811065
    _cons | -4.385361 .1775846 -24.69 0.000 -4.73342 -4.037301
    ---------------------------------------------------------------------------------------

    margins, dydx(*) atmeans

    ---------------------------------------------------------------------------------------
    | Delta-method
    | dy/dx Std. Err. z P>|z| [95% Conf. Interval]
    ----------------------+----------------------------------------------------------------
    1.treatment | -.0014183 .0006661 -2.13 0.033 -.0027239 -.0001127
    1.income_low | -.0000747 .0009576 -0.08 0.938 -.0019515 .001802
    1.female | .0006153 .000663 0.93 0.353 -.0006841 .0019147
    1.young | -.0016644 .0007549 -2.20 0.027 -.0031441 -.0001847
    1.fulltime | .000764 .000719 1.06 0.288 -.0006453 .0021733
    1.children | .0003424 .0008402 0.41 0.684 -.0013044 .0019891
    1.recentimmigrint | -.0018043 .0008555 -2.11 0.035 -.0034811 -.0001276
    1.highschool_or_below | .0017283 .0010859 1.59 0.111 -.0004 .0038566
    price | -.0008627 .0001912 -4.51 0.000 -.0012374 -.0004881
    nvs_score_total | .0001783 .0002363 0.75 0.451 -.0002848 .0006413
    ---------------------------------------------------------------------------------------
    Note: dy/dx for factor levels is the discrete change from the base level.
    Attached Files
    Last edited by Laura Stortz; 31 Mar 2020, 18:56.

  • #2
    Hi Laura,
    this is actually a very common mistake most people do when thinking about marginal effects.
    A good source for a better understanding of how margins work is Williams (2012) paper.
    the bottom line is that margins for interactions cannot be directly estimated with margins. Why?
    Margins can only estimate first order effects (first derivatives) (dydx). So it can comfortably estimate the effects of "treatment" or of income_low. It cannot estimate the marginal effects of interaction because that implies a second derivative.
    What you can do alternatively is to use something like this:
    Code:
    margins r.treatment t.income_low 
    margins r.treatment#t.income_low
    The second one will give you something like the "treatment effect" that comes from the interaction.
    HTH
    Fernando

    Comment


    • #3
      Originally posted by FernandoRios View Post
      Hi Laura,
      this is actually a very common mistake most people do when thinking about marginal effects.
      A good source for a better understanding of how margins work is Williams (2012) paper.
      the bottom line is that margins for interactions cannot be directly estimated with margins. Why?
      Margins can only estimate first order effects (first derivatives) (dydx). So it can comfortably estimate the effects of "treatment" or of income_low. It cannot estimate the marginal effects of interaction because that implies a second derivative.
      What you can do alternatively is to use something like this:
      Code:
      margins r.treatment t.income_low
      margins r.treatment#t.income_low
      The second one will give you something like the "treatment effect" that comes from the interaction.
      HTH
      Fernando
      Hi Fernando,

      Thank you for your response, that was really helpful to me. I have a follow-up question to your code:

      Should I write
      margins r.treatment t.income_low, dydx(*) atmeans
      margins r.treatment#t.income_low, dydx(*) atmeans

      Or is that unnecessary? Also I didn't find in the margins documentation what r. and t. mean? Sorry for my many follow up questions, I just want to make sure I understand before I use it.

      Comment


      • #4
        That was a typo
        it should be r in both cases
        and the dydx is not necessary.
        I haven’t tried it with atmeans option

        also I did provide you with both codes so you could see how the dif in dif worked.
        Last edited by FernandoRios; 31 Mar 2020, 21:07.

        Comment


        • #5
          Hi Fernando,

          Thank you very much for your response! It has helped me very much. I will read up on it.

          Cheers,
          Laura

          Comment

          Working...
          X