Announcement

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

  • Best way to run a regression in STATA with a quadratic term for IV and plotting it.

    Hi all,

    I am trying to do regression analysis in STATA and I want to include the quadratic term for my IV. I am trying to see what might be the most elegant way to do this. Posting two options below - should I expect different answers from these models?

    Step 2 is to test a moderation effect on this main effect. I have also included the proposed code for this in each option. For step 2, I also wanted to enquire how to plot the interaction between a quadratic IV term and a linear moderator term in STATA.

    Code:
    //option 1
    gen ivsq=iv*iv //creating a square term
    reg dv ivsq iv 
    
    reg dv c.iv##c.mod c.ivsq##c.mod // adding a moderator - it works but I feel uncomfortable about this lol
    
    //option 2
    reg dv c.iv##c.iv //self moderation
    
    reg dv c.iv##c.iv##c.mod //looks better to me! Would be great to confirm and learn how to plot this.

  • #2
    Neal, the two options are technically equivalent but the second is correct for calculating the marginal effect of the IV. You may try the code below after the two regressions of option 2 to see how the effect of IV on the DV changes with the value of mod.

    Code:
    margins, dydx(iv) at(mod=(values of interest))
    marginsplot

    Comment


    • #3
      Hey Fei,

      Thanks for this! I actually have used margins commands before but I was just not sure if it would work well even with a quadratic term /self-moderation of the IV. I will try this and get back if it does not work!

      Comment

      Working...
      X