Announcement

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

  • Problem with adjusting bins

    I am new at Stata and would appreciate some help. I have this code:

    [CODE]gen wm = winmargin2000 if reeleito==1
    replace wm = winmargin2000_inclost if incumbent==1
    gen running = wm
    replace running = -wm if incumbent==1
    gen running2 = running^2
    gen running3 = running^3
    gen running4 = running^4

    reg pcorrupt first running running2 running3 if esample2==1, robust
    predict fit
    predict stderror, stdp

    gen fit1 =fit if running < 0
    gen fit2 =fit if running >0
    gen stderror1 = stderror if running < 0
    gen stderror2 = stderror if running >0

    gen int1U = fit1 + 1.65*stderror1
    gen int1L = fit1 - 1.65*stderror1
    gen int2U = fit2 + 1.65*stderror2
    gen int2L = fit2 - 1.65*stderror2

    gen bin30 = int(running*30)/30
    sort bin30
    egen meanY30 = mean(pcorrupt) if esample2==1, by(bin30)


    replace bin = . if bin<-.65
    replace bin = . if bin>.65

    replace meanY30 = . if meanY30>.15
    replace int1U = . if int1U>.15
    replace int2U = . if int2U>.15

    twoway (scatter meanY30 bin , msymbol(oh) sort xline(0, lpattern(solid) lwidth(thin) lcolor(gs5))) (line fit1 bin , sort legend(off) lstyle(p1solid p2solid) lpattern(solid) lcolor(black) ) (line int1U bin , sort legend(off) lpattern(dash) lwidth(thin) lcolor(blue) ) (line int1L bin , sort legend(off) lpattern(dash) lwidth(thin) lcolor(blue) ) (line fit2 bin , sort legend(off) lstyle(p1solid p2solid) lpattern(solid) lcolor(black)) (line int2U bin , sort legend(off) lpattern(dash) lwidth(thin) lcolor(blue) ) (line int2L bin , sort legend(off) lpattern(dash) lwidth(thin) lcolor(blue) ), xtitle(Margin of victory) saving(rdd_graph, replace) ytitle(Corruption ) ylabel(0(.05).15)

    and get this result:
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	20.5 KB
ID:	1635891


    but if I want to drop the bin right in the center, where Margin of victory ~ 0, how would I proceed with that
Working...
X