Announcement

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

  • Plotting interactions - please help with the commands

    Hello dear forum members,

    I am interested in examining the impact of the moderator variable on a relationship b/w a number of continuous predictors and continuous DV. There is also a squared term included in the model.

    The estimated model is (properly specified, OLS assumptions are met):

    reg y x1 x2 x2^2 x3 x4 x5 x2x3 x2x4, vce(hc3)

    What would be the proper commands to plot and examine the relationships b/w the predicted y and x3 and x4 depending on x2 (at say -1sd, mean, and +1sd)?

    Both interactions included in the model have significant coefficients and also significant R^2 change.

    Thank you in advance for help with this.

  • #2
    http://maartenbuis.nl/wp/inter_quadr/inter_quadr.html
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thank you Mr. Buis, great "tip" paper.
      Last edited by Anton Ivanov; 28 Jan 2015, 09:04.

      Comment


      • #4
        Maarten perfectly demonstrates how to do things from first principles. With margins and marginsplot things might be a little easier for starters, though what happens behind the doors has more of a "black-box" character.

        Code:
        sysuse auto ,clear
        
        reg price c.mpg##c.weight##c.weight i.foreign
        
        su mpg
        loc mean = r(mean)
        loc plus_sd = r(mean) + r(sd)
        loc minus_sd = r(mean) - r(sd)
        
        su weight
        loc min = r(min)
        loc max = r(max)
        
        margins ///
        ,at(weight = (`min'(100)`max') ///
        mpg = (`minus_sd' `mean' `plus_sd'))
        
        marginsplot ,noci
        Best
        Daniel

        Comment


        • #5
          I have created a do-file following exactly the way Buis specified it in his article, but I get this error that I don't understand

          reg [my varlist]
          qui sum ln_likes_c if e(sample)
          local m = r(mean)
          local sd = r(sd)
          preserve
          qui replace hsa_c = 0
          forvalues i = -2/2 {
          qui replace ln_likes_c = `m ́ + `i ́*`sd ́
          local j=`i ́+2
          qui predict yhat`j ́
          }
          format yhat* %8.0gc
          sort weight

          when I run it, I get the following error. Why is m an invalid name if I specified it earlier?
          `m ́ invalid name
          r(198);

          Please help

          Comment


          • #6
            I think you have the right single quote wrong. It is the simple apostrophe:
            Code:
            `m'
            not
            Code:
            `m´

            Comment


            • #7
              Originally posted by Svend Juul View Post
              I think you have the right single quote wrong. It is the simple apostrophe:
              Code:
              `m'
              not
              Code:
              `m´
              Thank you, Sir. Worked right away.

              Comment

              Working...
              X