Announcement

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

  • interaction plots

    Dear All,
    I know that there have been numerous posts about interaction plots but I still have not found an answer to my problem. I have been trying to plot my regressions for two months now with no success, so maybe you can help me out.
    For my research I am running the following regression analysis:

    xtgls builtlastyear c.c_ACG2##c.c_existingboats c.c_rprov##c.c_existingboats c.c_mastlength##c.c_existingboats c.c_disadv##c.c_exboatsnd c.c_standalone##c.c_existingboats GDPgrowth2 leisure olympic texist i.year, panel(hetero) //
    builtlastyear is my dependent variable, existingboats my moderating variable, others independet variables and finally control variables.
    I now want to display each of the interactions in an interaction margins plot.

    As example one plot for xtgls builtlastyear c.c_ACG2##c.c_existingboats
    And now comes my difficulty: I want to set each minimum value to 5% and each maxmimum value to 95%, so I want to see the distribution between 5 to 95%. How do I do that?
    I greatly appreciate any help in this.
    Many thanks,
    Valerie


  • #2
    It seems like you are having trouble understanding continuous by continuous interactions. Have you seen this posting?

    https://www.stata.com/stata-news/news32-1/spotlight/

    Or this older posting?

    https://stats.idre.ucla.edu/stata/fa...tion-stata-12/

    Comment


    • #3
      I am not sure that is my Problem.
      Again builtlastyear is my dependent variable, existingboats my moderating variable, others independet variables
      Anyone able to help?
      This is what I did

      clear all

      set more off

      use "W", clear
      xtset id year
      xtgls builtlastyear ACG2 existingboats c.c_ACG2##c.c_existingboats
      predict m1b

      matrix beta_coeff=e(b)
      matrix Var_cov=e(V)

      scalar beta1=beta_coeff[1,1]
      scalar beta3=beta_coeff[1,3]

      scalar varbeta1=Var_cov[1,1]
      scalar varbeta3=Var_cov[3,3]

      scalar covb1b3=Var_cov[1,3]

      scalar list beta1 beta3 varbeta1 varbeta3 covb1b3
      drop if existingboats < 93
      drop if existingboats > 10000

      gen marginal_effect_builtlastyear=beta1+beta3*existing boats if _n<100000

      gen stderror_me_ACG2=sqrt(varbeta1+varbeta3*(existingb oats^2)+2*covb1b3*existingboats) if _n<100000

      gen ninefiveband=2*stderror_me_ACG2

      gen upper_me_ACG2=marginal_effect_ACG2+ninefiveband

      gen lower_me_ACG2=marginal_effect_ACG2-ninefiveband

      gen zeroyline=0

      graph twoway hist existingboats, width(4) start(93) freq color(gs14) yaxis(2) //////
      || line marginal_effect_ACG2 existingboats, clpattern(solid) clwidth(medium) clcolor(black) yaxis(1) ///
      || line upper_me_ACG2 existingboats, clpattern(dash) clwidth(thin) clcolor(red) ///
      || line lower_me_ACG2 existingboats, clpattern(dash) clwidth(thin) clcolor(black) ///
      || line zeroyline existingboats, clwidth(thin) clcolor(black) clpattern(solid) ///
      || , ///
      xlabel(15(3)66, nogrid labsize(2)) ///
      ylabel(0 4 8 12 16 20, axis(1) nogrid labsize(2)) ///
      ylabel(0 4 8 12 16 20, axis(2) nogrid labsize(2)) ///
      yscale(noline alt) ///
      yscale(noline alt axis(2)) ///
      xscale(noline) ///
      legend(off) ///
      xtitle("adoption" , size(2.5) ) ///
      ytitle("Observation Frequency" , axis(2) size(2.5)) ///
      ytitle("Marginal Effect of participation on adoption" , axis(1) size(2.5)) ///
      xsca(titlegap(2)) ///
      ysca(titlegap(2)) ///
      ysca(titlegap(2) axis(2)) ///
      title("Marginal Effect Experience with 95% Confidence Bands") ///
      subtitle("Frequency Distribution of participation -- right hand scale")
      #delimit cr

      Comment

      Working...
      X