Hello All,
I am having difficulty fitting a interaction graph over a histogram.
The primary issue is the x-axis extends beyond the observations that I have on the histogram. Additionally, the right y-axis should be the variable TE with proper magnitude.

The code I am using i as follows (this is the complete code):
xtgls flnfdiflow96dollars bitsumoecdweighted lnrgdpch lnpop econgrowth inflation resourcedepletion agreementwithdevcountry wtomemberdummy polcon3 bitsumoecdweightedpolcon3 te ie de c.lnrgdpch#c.te c.ie#c.lnrgdpch c.de#c.lnrgdpch, corr(ar1) force
sort lnrgdpch
matrix b=e(b)
matrix V=e(V)
scalar b2=b[1,2]
scalar b14=b[1,14]
scalar varb2=V[2,2]
scalar varb14=V[14,14]
scalar covb2b14=V[2,14]
scalar list b2 b14 varb2 varb14 covb2b14
generate MVZ=((_n-6)/100)
replace MVZ=. if _n>2720
gen conbx=b2+b14*MVZ if _n<2720
gen consx=sqrt(varb2+varb14*(MVZ^2)+2*covb2b14*MVZ)
gen ax=1.96*consx
gen upperx=conbx+ax
gen lowerx=conbx-ax
gen where=-0.045 *****This is potentially where the problem lies****
gen pipe = "|"
egen tag_te = tag(te)
egen tag_gdp = tag(lnrgdpch)
gen yline=0
graph twoway hist lnrgdpch, width(0.5) percent color(gs14) yaxis(2)
|| scatter where lnrgdpch if tag_gdp, plotr(m(b 4)) ms(none) mlabcolor(gs5) mlabel(pipe) mlabpos(6) legend(off)
|| line conbx MVZ, clpattern(solid) clwidth(medium) clcolor(black) yaxis(1),
|| line upperx MVZ, clpattern(dash) clwidth(thin) clcolor(black)
|| line lowerx MVZ, clpattern(dash) clwidth(thin) clcolor(black)
|| line yline MVZ, clwidth(thin) clcolor(black) clpattern(solid)
|| ,
xlabel(-2 0 2 4 6 8 10 12, nogrid labsize(2))
ylabel(-0.05 0 .05 .1 .15 .2 .25, axis(1) nogrid labsize(2))
ylabel(0 2 4 6 8 10 12 14 16, axis(2) nogrid labsize(2))
I apologize for the excessive code. But I realize my issues with the graph may stem from how I built the interaction and CIs.
Any help would be great.
Best,
Jesse
I am having difficulty fitting a interaction graph over a histogram.
The primary issue is the x-axis extends beyond the observations that I have on the histogram. Additionally, the right y-axis should be the variable TE with proper magnitude.
The code I am using i as follows (this is the complete code):
xtgls flnfdiflow96dollars bitsumoecdweighted lnrgdpch lnpop econgrowth inflation resourcedepletion agreementwithdevcountry wtomemberdummy polcon3 bitsumoecdweightedpolcon3 te ie de c.lnrgdpch#c.te c.ie#c.lnrgdpch c.de#c.lnrgdpch, corr(ar1) force
sort lnrgdpch
matrix b=e(b)
matrix V=e(V)
scalar b2=b[1,2]
scalar b14=b[1,14]
scalar varb2=V[2,2]
scalar varb14=V[14,14]
scalar covb2b14=V[2,14]
scalar list b2 b14 varb2 varb14 covb2b14
generate MVZ=((_n-6)/100)
replace MVZ=. if _n>2720
gen conbx=b2+b14*MVZ if _n<2720
gen consx=sqrt(varb2+varb14*(MVZ^2)+2*covb2b14*MVZ)
gen ax=1.96*consx
gen upperx=conbx+ax
gen lowerx=conbx-ax
gen where=-0.045 *****This is potentially where the problem lies****
gen pipe = "|"
egen tag_te = tag(te)
egen tag_gdp = tag(lnrgdpch)
gen yline=0
graph twoway hist lnrgdpch, width(0.5) percent color(gs14) yaxis(2)
|| scatter where lnrgdpch if tag_gdp, plotr(m(b 4)) ms(none) mlabcolor(gs5) mlabel(pipe) mlabpos(6) legend(off)
|| line conbx MVZ, clpattern(solid) clwidth(medium) clcolor(black) yaxis(1),
|| line upperx MVZ, clpattern(dash) clwidth(thin) clcolor(black)
|| line lowerx MVZ, clpattern(dash) clwidth(thin) clcolor(black)
|| line yline MVZ, clwidth(thin) clcolor(black) clpattern(solid)
|| ,
xlabel(-2 0 2 4 6 8 10 12, nogrid labsize(2))
ylabel(-0.05 0 .05 .1 .15 .2 .25, axis(1) nogrid labsize(2))
ylabel(0 2 4 6 8 10 12 14 16, axis(2) nogrid labsize(2))
I apologize for the excessive code. But I realize my issues with the graph may stem from how I built the interaction and CIs.
Any help would be great.
Best,
Jesse
Comment