Announcement

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

  • Plotting Moderating effect on curvilinear relationship

    Dear Stata Users,

    I am attempting to use marginsplot to show in graph the moderating effect of a variable on the main (curvilinear relationship). I report below the model.

    In particular my main relationship is between X1 and X1squared ("c.L.X1##c.L.X1") and the dep. variable "rd_sales2_w2".
    I want to see the moderating effect of the variable "GII". So, in the model, I include GII and the interaction between GII and X1 ("X1_GII").

    Code:
    . xtreg rd_sales2_w2 c.L.X1##c.L.X1 l.Employee l.Tdeb_Tc l.Roa l.Capex l.Bsize   l.Bind    l.CEOsep    l.CEO_bMemb   l.GII l.X1_GII    l.GDPper    i
    > .year if Region != "Africa" &  Region != "Middle-east" , fe
    
    F(21,865)         =       5.69
    corr(u_i, Xb)  = -0.0255                        Prob > F          =     0.0000
    
    
    rd_sales2_w2       Coef.   Std. Err.      t    P>t     [95% Conf. Interval]
    
    X1
    L1.    .1088029   .0246564     4.41   0.000     .0604095    .1571963
                  
    cL.X1#cL.X1-.0012465   .0004478    -2.78   0.005    -.0021255   -.0003676
                  
    Employee 
    L1.    9.18e-07   2.53e-06     0.36   0.716    -4.04e-06    5.88e-06
                  
    Tdeb_Tc 
    L1.    7.32e-06   .0008716     0.01   0.993    -.0017033    .0017179
                  
    Roa 
    L1.   -.0396293   .0072838    -5.44   0.000    -.0539253   -.0253332
                  
    Capex 
    L1.   -.0046327   .0137816    -0.34   0.737     -.031682    .0224166
                  
    Bsize 
    L1.    -.016503   .0342187    -0.48   0.630    -.0836644    .0506584
                  
    Bind 
    L1.   -.0100269   .0044302    -2.26   0.024    -.0187221   -.0013316
                  
    CEOsep 
    L1.   -.1390527   .1711974    -0.81   0.417    -.4750635    .1969582
                  
    CEO_bMemb 
    L1.   -1.134796   .3335148    -3.40   0.001    -1.789388   -.4802026
                  
    GII 
    L1.    28.97293   8.051821     3.60   0.000     13.16954    44.77632
                  
    X1_GII 
    L1.   -.1919284   .0731795    -2.62   0.009    -.3355585   -.0482983
                  
    GDPper 
    L1.    .0000713   .0000134     5.32   0.000      .000045    .0000976
                  
    year 
    2012    -.0878556   .1936203    -0.45   0.650    -.4678761     .292165
    2013    -.0978832   .1975297    -0.50   0.620    -.4855768    .2898104
    2014     .1055205    .198037     0.53   0.594    -.2831688    .4942098
    2015     .1892702   .2333239     0.81   0.417    -.2686771    .6472175
    2016     .4074635   .2378825     1.71   0.087     -.059431     .874358
    2017     .4754091   .2531208     1.88   0.061    -.0213937    .9722119
    2018     .6449463   .2853322     2.26   0.024     .0849219    1.204971
    2019     .9432578   .3573599     2.64   0.008     .2418638    1.644652
                  
    _cons    1.910243   1.941787     0.98   0.326    -1.900923    5.721409

    After launching the model, I have tried to work with margins and marginsplot command, but I did not obtain what I am looking for.
    I want to show how my main curvilinear relationship changes for low and high levels of GII.
    I would like to show graphs as in the following paper (page 207 fig. 2 and 3).

    https://onlinelibrary.wiley.com/doi/...aCXoHwmVXDJQOA


    Any suggestions would be really useful for my research, if you have any questions do not hesitate to ask

    Thank you in advance


  • #2
    Hi Nicola,

    Please always try to provide example data with your question. The actual margins/margins plot code that you've already written would also be very helpful even if it is incorrect. It seems like you need to add a call to at() in your margins command. Give at() the values of GII you want to test. Check the documentation with -help margins- for examples regarding how to do this.

    Comment


    • #3
      Hi Daniel, thanks. This is the code that I am using.
      Code:
      margins, at(l.X1=(1 (5) 50) l.GII =(0(1)1))
      marginsplot
      I obtain two "parallel curves", when GII is 0 or 1, respectively. It is in line with the economic interpretation. However, my plot seems not consistent with those I find in prior literature, see the paper above I referred to for example. The two curves in my graph follow exactly the same path at different levels. In this way, I cannot see if the curves change the slope or how they actually move across the graph. I am wondering if I am using the correct command for what I would like to see.
      Last edited by Nicola Rossi; 01 Jul 2022, 11:30.

      Comment


      • #4
        Hi Nicola,

        My guess is that margins will typically hold all else equal at the mean - including the interaction term. There may be a better way to specify margins after the model is run, I really don't know. My suggestion is that you change your interaction term in your model to c.l.X1#l.i.GII. Here is some example data:

        Code:
        clear
        set obs 100
        gen x1 = rnormal(10,2)
        gen gll = runiform()
        replace gll = 1 if gll > 0.7
        replace gll = 0 if gll <= 0.7
        gen x1_gll = x1 * gll
        gen outcome = rnormal(0) + (x1*x1) + (10 * x1) + (30 * gll) + (50 * x1_gll)
        Now I run a version of the model with a similar setup:

        Code:
        reg outcome c.x1##c.x1 i.gll x1_gll
        margins gll, at(x1=(1(1)10))
        marginsplot
        In this case the lines are parallel. Now I change the model syntax:

        Code:
        reg outcome c.x1##c.x1 i.gll i.gll#c.x1
        margins gll, at(x1=(1(1)10))
        marginsplot
        And I can now see the interaction in the plot.

        As an addendum, I notice you are not using the i. prefix to denote categorical or dummy variables in your model. Is this intentional?

        Comment


        • #5
          Hi Daniel, I still obtain parallel curves, even changing the interaction terms. I do not know...I will try to differently specify the margins (and use i. prefix).
          Thanks for your suggestions

          Comment

          Working...
          X