Announcement

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

  • Suggestions for the visualization of a triple interaction effect

    I am looking to create some figure(s) that visualize a triple interaction effect I am observing in the data.
    I reprint the basic results below

    Code:
    xtreg fwd log_dom t_s_d c.log_dom#c.t_s_d p_pria_timew p_pria_usew c.log_dom#c.p_pria_usew c.p_pria_usew#c.t_s_degree_cent c.log_dom#c.p_pria_usew#c.t_s_d log_other t_k_s team_t_1st col_difpairs team_m_patcount_5y p_classes dif_cpc p_cpc_1 p_pria p_claims p_inv f_inv_prod_5y f_search f_acap f_dar f_emp i.p_appy i.p_gry if compustat == 1 , fe
    
    Fixed-effects (within) regression               Number of obs     =     40,282
    Group variable: fid                             Number of groups  =        109
    
    R-sq:                                           Obs per group:
         within  = 0.0831                                         min =          1
         between = 0.0728                                         avg =      369.6
         overall = 0.0679                                         max =      8,495
    
                                                    F(36,40137)       =     101.00
    corr(u_i, Xb)  = -0.2782                        Prob > F          =     0.0000
    
    -------------------------------------------------------------------------------------------------------------
                                            fwd |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    --------------------------------------------+----------------------------------------------------------------
                                      log_dom_t |   .5544467   .0850644     6.52   0.000     .3877186    .7211748
                                t_s_degree_cent |    .052213     .02431     2.15   0.032     .0045649    .0998612
                                                |
                  c.log_dom_t#c.t_s_degree_cent |  -.0276355   .0060148    -4.59   0.000    -.0394246   -.0158464
                                                |
                                   p_pria_timew |  -1.091934   .0910784   -11.99   0.000     -1.27045   -.9134187
                                    p_pria_usew |   .3448452   .1871209     1.84   0.065    -.0219161    .7116065
                                                |
                      c.log_dom_t#c.p_pria_usew |   .1115617    .063443     1.76   0.079     -.012788    .2359115
                                                |
                c.p_pria_usew#c.t_s_degree_cent |   .1329657   .0234215     5.68   0.000     .0870591    .1788722
                                                |
    c.log_dom_t#c.p_pria_usew#c.t_s_degree_cent |  -.0285318   .0052981    -5.39   0.000    -.0389161   -.0181474
    Normally, for a simple interaction effect I would use something like

    Code:
    marginscontplot log_dom_t t_s_d, at1(0(.25)6) at2(0 5.7 14.3 22.9)
    So I am wondering
    1) Is it possible to run marginscontplot for specific values of my variable p_pria_usew (e.g. by using by, for, or over)? This should create multiple graphs that exhibit the effects
    2) Is there a way to create a 3D plot (with fwd on the Y axis, log_dom_t on the X-axis, and t_s_degree_cent on the Z-axis for three different values of p_pria_usew (e.g. mean +/- 1 standard deviation
    3) If either 1 or 2 is possible, would the solution be different if I would run a negative binomial regression instead of a simple OLS?

    Thanks heaps in advance!

    Simon

  • #2
    Here is an example from a workshop I gave at last German Stata Users's meeting: http://maartenbuis.nl/workshops/grap...l#slide57.smcl

    All materials from the workshop can be accessed here: http://maartenbuis.nl/workshops/
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      HI Maarten,

      Thanks a lot (bedankt!). This is quite a helpful resource. I managed to replicate your first approach with my data to create a plot (see below).
      This is the code I used (for three continuous variables)

      Code:
      xtnbreg fwd10 c.log_dom##c.t_s_d##c.p_pria_usew p_pria_timew f_emp f_acap f_dar f_search f_inv_prod_5y  p_inv log_other t_k_s team_t_1st col_difpairs team_m_patcount_5y p_classes dif_cpc p_cpc_1 p_pria p_claims priordum ts i.p_appy i.p_gry if compustat == 1 , fe
      est sto A5
              margins, dydx(log_dom_t) at(t_s_d = (0 5.66 14.4 23) p_pria_usew = (-1.5 -.9 0 .9 1.8 3.6))
              _marg_save, saving(temp, replace)
              use temp, clear
              twoway contour _margin _at2 _at3, ccut(-1(.5)6) ztitle(effect of team domain experience) name(margins3d_try1, replace)
              graph export "C:\User\...\margins3d_try1.png", as(png) replace
      Could you help me make sense of the interpretation please? Specifically, it is unclear to me how this plot relates to the response variable fwd.


      Click image for larger version

Name:	margins3d_try1.png
Views:	1
Size:	26.9 KB
ID:	1453899

      I was actually hoping to create an image that was more like the one you can see on this link
      https://www.researchgate.net/figure/...fig2_321711274

      Basically, a combination of three graphs in which a 3-dimensional surface connects log_dom_t (X axis) and t_s_d (Z axis) to the response fwd (Y axis).
      One graph would show this for high value of moderator p_pria_usew, and the others for an average and a low value of that moderator.
      Is this possible with Stata or should I turn to R or some other program?

      Comment


      • #4
        Adrian Mander wrote a command called surface that could produce the 3D plot you seek.

        Comment


        • #5
          Thanks Dimitriy, I will look at that today.

          If you could help me locate the exact file that would be helpful. I did not find it by using
          Code:
          findit surface
          but found this link. Is that what you had in mind?
          http://fmwww.bc.edu/RePEc/bocode/s/surface.ado
          Last edited by Simon Schillebeeckx; 22 Jul 2018, 22:39.

          Comment


          • #6
            Yes, that is one. Try
            Code:
            ssc install surface

            Comment

            Working...
            X