Announcement

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

  • Nonlinear interactions in Stata

    Hi,

    I have two variables X and Z that are hypothesized to influence Y. The effect of X on Y is nonlinear, that is, X squared is also significant. So we have:

    Y = B0 + B 1X + B 2X2 + B 3Z

    The code in stata (a mixed model regression is as follows): mixed Y c.X##c.X Z

    Now if I want to estimate how the interaction effect of X and Z are, that is, how does Z moderate the impact of X on Y, which of the following codes are correct:

    1. mixed Y c.X##c.X c.X##c.Z

    2. mixed Y c.X##c.X##c.Z

    In other words, should I interact Z with X, or should I interact it with X#X again?

    As usual, I tag dear Clyde since his comments have always been helpful for me.

  • #2
    You can always try it and see what you get. But I think you want the first one. Otherwise you will get X^2 * Z.

    Personally, I like to write things out instead of using the shortcuts. I feel like I am surer of what I am doing. So

    mixed Y c.X c.X#c.X c.Z c.X#c.Z
    -------------------------------------------
    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