Announcement

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

  • Creating a marginsplot for my quadratic interaction term

    Dear all,

    I'm working on my masters thesis switched from SPSS to Stata in order to create plots for my interactions. I read that I can create plots using the margins command. However, I can't finy any how-to's for my problem. I have a linear direct effect and want to plot an interaction based on my quadratic moderator (MODSQ).

    Code:
    reg DV IV MOD MODSQ IVxMOD IVxMODSQ CONTROL1 CONTROL2 CONTROL3
    Can anyone help me creating a plot showing the marginal effect of IV on DV for different values of my moderator (MODSQ)?

    Thank you so much.

    Best,
    Jean

  • #2
    Jean:
    welcome to this forum.
    Just one step behind: if you have created square term and/or interactions by hand, there's nothing that -margins-and -marginsplot- can do for you, as Stata will interpret those independent variable as different predictors.
    The easy fix is to use -fvvarlist- for creating categorical variables, square terms and interactions, run -regress- and then rely on the wonderful capabilities of -margins- and -marginsplot-.
    Kind regards,
    Carlo
    (Stata 15.1 SE)

    Comment


    • #3
      Hi Carlo,

      Thank you for your quick reply.

      I changed the syntax to the following. I guess that is what you meant?

      Code:
      reg DV c.IV c.MOD c.MOD#c.MOD c.IV#c.MOD c.IV#c.MOD#c.MOD

      Comment


      • #4
        Jean:
        try the following more compact code and check if you get the same results from your regression:
        Code:
        reg DV c.IV c.MOD##c.MOD c.IV##c.MOD
        Kind regards,
        Carlo
        (Stata 15.1 SE)

        Comment


        • #5
          I get different results. I don't know why.

          I used the following syntax to create a graph showing the marginal effect of IV on DV at different levels for the moderator (MOD). Is that correct?

          Code:
          margins, dydx(IV) at(MOD=(0(0.5)7))
          marginsplot, yline(0)

          Comment


          • #6
            Jean:
            check if what follows give you what you want:
            Code:
            reg DV c.IV##(c.IV##c.MOD)
            -margins- and -marginsplot- codes seem OK, although I cannot see what the resulting graphs looks like.
            Kind regards,
            Carlo
            (Stata 15.1 SE)

            Comment

            Working...
            X