Announcement

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

  • How to use margins command for a hybrid model with interaction effects(xtreg, re)

    Hi Statalisters,

    I would greatly appreciate it if anyone can help me with the following problem.

    I have a panel data and I am trying to run a hybrid model (Allison, 2009) with interactions.
    After running the model, I would like to use the "margins" command.

    In the following, yit is a dependent variable, x1it, x2it, x3it are time-variant independent variables and zi is time-fixed independent variable.
    x1it is a dummy variable, while yit, x2it, x3it and zi are not.

    Code:
    gen x1itXzi =x1it*zi
    by id, sort: center x1it x2it x3it x1itXzi, prefix(d) mean(m)
    xtset id time
    xtreg yit dx1it dx2it dx3it dx1itXzi zi mx1it mx2it mx3it mx1itXzi
    After this, I would like to run the following command.

    Code:
    margins x1it, at(zi=(-2 -1 0 1 2)) atmeans
    However, running margins command in this way would not be enough since margins command does not recognize "x1it"s in "dx1it" "dx1itXzi" "mx1itXzi" as the same variable (please correct me if I am wrong).
    Do you have any suggestions?

    Best,
    Tate

    Reference
    Allison, P. D. (2009). Fixed effects regression models (Vol. 160). SAGE publications.

  • #2
    -margins- does not work correctly with "roll your own" interaction terms. You have to use factor variable notation so that Stata will know what variables are interactions and which are not. Also, while there may be contexts where it makes sense to center a dichotomous variable, factor variable notation will not allow that. So you can't center x1it here. You need to revise your -xtreg- command accordingly.

    Code:
    xtreg yit i.x1it##c.z1 dx2it dx3it mx2it mx3it
    Then
    Code:
    margins x1it, at(zi = (-2 -1 0 1 2)) atmeans
    will work as you expect it to.

    Comment


    • #3
      On reflection, the model I proposed in #2 is not equivalent to the one you are trying to estimate, because it does not contain anything that reflects mx1it. I'm afraid I don't see how to add it to the model in a way that will enable -margins- to recognize that mx1it varies when x1it does. Off hand, though, the decomposition of x1it into mx1it and dx1it does not seem necessary if your purpose is to estimate the marginal effect of x1it as a whole.

      Comment


      • #4
        Check out David Drukker's talk from the 2016 Stata Conference in Chicago:

        http://www.stata.com/meeting/chicago...16_drukker.pdf

        He has this weird interaction type term, it=iexam/(hgpa^2). He shows how to deal with vars like that via generate options on the margins command. I haven't had a chance to try it yet myself but I suspect it will do what you want.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment

        Working...
        X