Announcement

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

  • RDD bandwidth sensitivity analysis graph

    Dear all,

    I am performing a RDD analysis and would like to plot point estimates of treatment effect and respective confidence intervals against chosen bandwidth.
    I am not using rdrobust, rather a linear regression with a dummy for the observation being above the cutoff.
    I am running a loop for each bandwidth size I want to plot, each time estimating
    Code:
    reg TOT2011 more300 x_vs , [iweights=kernel] vce(robust)
    estimates store bw`size'
    where more300 is 1[st_pc01>=0], st_pc01 is the standardized population (running variable) and 0 is the cutoff.

    The command which gets me closer to what I want is coefplot.
    I am running
    Code:
    coefplot bw50 bw60 bw70 bw80 bw90 bw100 bw110 bw120 bw130 bw140 bw150 bw160 bw170 \\\
    bw180 bw190 bw200 bw210 bw220 bw230 bw240 bw250 bw260 bw270 bw280 bw290 bw300 , \\\
    keep(more300) vertical yline(0) legend(off) replace mcolor(black) \\\
    ciopts(lcolor(black) recast(rcap)) xtick(#25)
    This gives me the graph below:

    Click image for larger version

Name:	bw_sensitivity.png
Views:	2
Size:	22.5 KB
ID:	1554407


    This almost looks like what I want, but if I try to rename the xaxis "RD bandwidth" and label the ticks from 50 to 300, the graph squeezes to the left and nothing can be seen.
    I guess I am not using the right command? Is somebody able to help me with this?
    What I would like is something like this:

    Click image for larger version

Name:	bwsens_bp.PNG
Views:	2
Size:	22.0 KB
ID:	1554408

    Thank you very much,
    Marianna

  • #2
    I am not too familiar with Ben Jann's -coefplot-, but it does appear that the plotting positions is not simply 1, 2, 3,... . Perhaps there are options I am aware of, but you can use generate() option to save the results and then re-plot the coefficients with x-axis labeled how you want it..

    For example:
    Code:
    clear*
    webuse grunfeld
    levelsof year, local(levels)
    foreach l of local levels {
            qui reg invest kstock if year == `l'
            est store est`l'
    }
    
    coefplot est* , keep(kstock)  vertical mcolor(black)  ciopts(lcolor(black) recast(rcap) ) /// 
        legend(off)  gen(_c) name(coefplot1,replace)
    levelsof year, local(l1)
    levelsof _cat, loca(l2)
    local mylabel ""
    forv i = 1/20 {
        local at: word `i' of `l2'
        local yr: word `i' of `l1'
        local mylabel `mylabel' `at' `"`yr'"'
    
    }
    scatter _cb _cat , mc(black)  /// 
        || rcap _cul1 _cll1 _cat,  lc(black) /// 
        ||, legend(off)  xlabel(`mylabel', nogrid) xtitle(My title)

    Comment


    • #3
      Hi Scott,

      Thank you very much. The gen() option of coefplot helped a lot.
      If this can help anyone else, I solved the problem with the following code.

      Code:
      forvalues size = 50(10)300{
      preserve
      gen bw`size' = st_pc01 >= -`size' & st_pc01 <= `size'
      keep if bw`size' //keep only observations within the bandwidth
      keep if TOT_shrid2005 <= r(p99)
      
      reg TOT_shrid2011 more300 x_vs , vce(robust) //run regression on different bandwidth size
      estimates store bw`size'
      
      restore
      }
      
      #delimit ;
      coefplot bw50 bw60 bw70 bw80 bw90 bw100 bw110 bw120 bw130 bw140 bw150 bw160 bw170
      bw180 bw190 bw200 bw210 bw220 bw230 bw240 bw250 bw260 bw270 bw280 bw290 bw300 ,
      keep(more300) vertical yline(0) legend(off) replace mcolor(black)
      ciopts(lcolor(black) recast(rcap)) gen(_c) ;
      #delimit cr
      
      keep _c*
      cap drop bw
      gen bw = . //identify to which bandwidth size the estimates belong
      local bw_sizes 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 \\\
      240 250 260 270 280 290 300  
      forvalues i = 1/26{
      local bw_value: word `i' of `bw_sizes'
      replace bw = `bw_value' if [_n] == `i'
      }
      
      // Plot point estimates and CI against bandwidth size
      #delimit ;
      scatter _cb bw, mc(black) || rcap _cul1 _cll1 bw, lc(black) ||,
      yline(0, lp(dash)) xtitle("RD bandwidth", margin(small))
      ytitle("RD coefficiant (95% CI)", margin(small)) legend(off)
      title("Bandwidth sensitivity analysis") graphregion(color(white))
      saving("$graphs/BWsensitivity.gph", replace) ;
      graph export "$graphs/BWsensitivity.png", replace ;
      #delimit cr
      which results in the following graph

      Comment


      • #4
        This is so useful, I have been struggling with this!

        Comment

        Working...
        X