Announcement

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

  • Graph for regression with inverted U-shape and moderators

    Hello,

    I hope to get some help with Stata again.

    I would now like to graph the inverted U-shape relationship between q_tot (dependent variable) and rdalliances (independent variable).

    My regression still looks like this:

    Code:
    Code:
    xtreg q_tot rdalliances rdalliances_2 rdi_w adi_w ln_emp1_w lev_w
    ​​​​​​​
    with 4 control variables (rdi_w, adi_w, ln_emp1_w and lev_w


    My questions:

    1) Is there a special command to use for a graphic solution in the presence of an inverted U-shape relationship?

    2) And what to I have to do, if I want to include a moderator in the graph to show, if the moderator compresses or stretches the main relationship?

    Thanks in advance.

    Kind regards,
    Hanna

  • #2
    Here's a start.

    Re-specify using interactions.

    Code:
    xtreg q_tot c.rdalliances##c.rdalliances rdi_w adi_w ln_empl_w lev_w
    margins, over(rdalliances)
    margingsplot
    Also see
    HTML Code:
    https://stats.oarc.ucla.edu/stata/seminars/interactions-stata/
    https://stats.oarc.ucla.edu/stata/faq/how-can-i-use-the-margins-command-to-understand-multiple-interactions-in-regression-and-anova-stata-11/
    may youtube videos on it.

    Comment


    • #3
      Also see 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


      • #4
        Hello George and Maarten,

        thanks for your help!

        I followed the description of the Paper Maarten posted and got the following graphic. I overwrote my Stata code by accident, that is why I can't post it here, but I did the exact same steps as written in the paper.

        Dependent Variable : Total Q (q_tot)
        Independent Variable: R&D Alliances (rdalliances)
        Moderator: Munificence (munificence)

        I do not really understand the graphic as it does not really show the inverted U-shape the U-test (utest) predicted me with its highly significant result.

        Could somebody help mw with this issue?

        Thanks and kind regards,
        Hanna
        Click image for larger version

Name:	Screenshot 2022-01-06 225819.jpg
Views:	1
Size:	120.2 KB
ID:	1643914

        Last edited by Hanna Marie; 06 Jan 2022, 15:08.

        Comment


        • #5
          Show the regression commands and the results you have used as you have been requested to in the FAQ section. In the original post #1, your regression equation does not have any moderation (munificence) variable and in the last one #4, you have a moderation variable. Obviously the inverted u relationship you have seen in #1 will be different now after #4 and that should be reflected in your regression results which we cannot see because you have not posted them. You are not helping us by not posting them. Anyway on the problem: Maarten's codes are for earlier versions of Stata before 'margins' was introduced. You can try the codes below (I added the munificence interaction term):

          Code:
          xtreg q_tot c.rdalliances##c.rdalliances##c.munificence rdi_w adi_w ln_emp1_w lev_w
          
          qui su munificence
          loc m : di %8.2f r(mean)
          loc m1sd : di %8.2f r(mean)+r(sd)
          loc m2sd : di %8.2f r(mean)+r(sd)*2
          loc m_1sd : di %8.2f r(mean)-r(sd)
          loc m_2sd : di %8.2f r(mean)-r(sd)*2
          
          margins, at(rdalliances=(0 (5) 60) munificence=(`m_2sd' `m_1sd' `m' `m1sd' `m2sd' ))
          
          #delimit ;
          marginsplot, xdim(rdalliances)  
          legend(order(6 "Mean-2SD"  7  "Mean-1SD" 8 "Mean" 9 "Mean+1SD" 10 "Mean+2SD") col(1) pos(3))
          ;
          Roman

          Comment


          • #6
            Looking at the graph suggests to me that you added rdalliances squared but not rdalliances. That way you forced the maximum/minimum to occur at rdalliances = 0, which is typically not what you want. Something like c.rdalliances#c.rdalliances#c.munificence or c.rdalliances#c.rdalliances##c.munificence. Notice the single # instead of the double ##. What you need is the double ##, so c.rdalliances##c.rdalliances##c.munificence.

            There are other problems with your graph, there are 10 lines, while there should be 5. So we really need the code to diagnose what went wrong. I am sorry, but to help you, we need you to do this again and save the do-file.
            Last edited by Maarten Buis; 07 Jan 2022, 01:46.
            ---------------------------------
            Maarten L. Buis
            University of Konstanz
            Department of history and sociology
            box 40
            78457 Konstanz
            Germany
            http://www.maartenbuis.nl
            ---------------------------------

            Comment

            Working...
            X