Announcement

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

  • How to create a matrix for an interaction effect?

    Dear community
    I'm now almost in the final stage of my master thesis and need to create a graphic for en interaction effect:

    I have an effect (panel model fixed effects, countries, 5 years) between immigration and unemployment and wanna show the effect of a policy on this first effect.
    Some years ago, I did this very clear interaction graphic, but I don't remember how the code for it was. Can anyone help me to create more or less this graph (of course with my variables and not with FDI, GE and Gini Values).

    Thanks a lot for your help!

  • #2
    Code:
    sysuse nlsw88, clear
    reg hours c.grade##c.ttl_exp i.south i.union
    margins , dydx(ttl_exp) at(grade=(4/18))
    marginsplot, recastci(rarea)    ///
                 ciopts(astyle(ci)) ///
                 recast(line)
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Dear Maaarten Buis, thanks a lot for your help. I have Stata 11 and when I enter your code there is a error message:
      marginsplot, recastci(rarea) ///
      unrecognized command: marginsplot
      r(199);

      .
      . ciopts(astyle(ci)) ///
      unrecognized command: ciopts
      r(199);

      .
      . recast(line)
      varlist required
      r(100);
      In the last work, the code looked like that, but I don't know which parameters I have to enter in this code...

      matrix define b = e(b)
      matrix define V = e(V)

      scalar b1 = b[1,1]
      scalar b3 = b[1,7]

      scalar varb1 = V[1,1]
      scalar varb3 = V[7,7]
      scalar covb1b3 = V[1,7]

      egen MV = fill(1(0.05)3.1)
      replace MV = . if MV > 0.9

      gen conb=b1+b3*MV
      gen conse=sqrt(varb1+varb3*MV^2+2*covb1b3*MV)
      gen a=1.96*conse
      gen top=conb+a
      gen bottom=conb-a
      sort MV

      *Grafik mit 95% Konfidenzintervall der Interaktion*
      graph twoway (line conb MV, clpattern(solid) clwidth(medium) clcolor(black) ) (line top MV, clpattern(dash) clwidth(thin) clcolor(black) ) (line bottom MV, clpattern(dash) clwidth(thin) clcolor(black) ) , aspectratio(0.4) xlabel(-1.5(0.25)1, labsize(2.5) nogrid) ylabel(-0.1 0 0.1 , labsize(2.5)) yscale(noline) xscale(noline) legend(col(1) order(2 1) label(2 "95% Konfidenzintervall") label(1 "Marginaler Effekt der FDI bei X GE") position(12) keygap(*1.5) symysize(*0.6) symxsize(*0.5) region(lcolor(white)) size(small) ) text(-1.3 1.55 "signifikanter Bereich", size(small) color(black)) xline(25, lcolor(black*0.6)) text(-2.4 16 "beobachteter Bereich", size(small) color(black*0.6)) xtitle("Government Effectiveness", size(3)) xsca(titlegap(2)) ysca(titlegap(4)) ytitle("Marginaler Effekt der FDI", size(3)) scheme(s2mono) graphregion(fcolor(white))
      Last edited by Luca Huber; 01 Apr 2015, 05:23.

      Comment


      • #4
        Unfortunately marginsplot was introduced in Stata 12. If not using the most current version of Stata, be sure to say so. Otherwise you may get advice you can't use.

        Also, because Maarten used continuation lines, you would need to enter the commands in the do file editor. If you try to run them from the command line you will get errors like what you got.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Dear Richard Williams, thanks a lot too. So I can't use the command with Stata 11 (also in the do file editor)? But the code I posted before should run with Stata 11 (I did it with this work some years ago) .. but I absolutely have no idea which parameters I have to enter in that code....

          Comment


          • #6
            And how is it possible to run a simple time series regression with only one country over 5 years? I tried it with
            regress
            , but than, there are no standard errors, t-values and conf. interv. I know that a Regression with only 5 observations is probably not significant, but I want to analyse a variable for which I have only data for one year in all countries over time - and for one country, I have them over 5 years. So I should analyse this country over time after doing a cross sectional analysis over all countires.

            Comment

            Working...
            X