Announcement

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

  • Creating RDD Tables with Rdrobust and Estout Packages

    I'm working on a project where I'm using running a regression discontinuity design for multiple bandwidths and I'm having trouble with the interactions between estout and rdrobust.
    The table I would like to have would be something formatted similar to this table from Lee et. al. 2004.
    Click image for larger version

Name:	ex.png
Views:	1
Size:	189.5 KB
ID:	1709444

    The code I currently have is below here. It works to create a table but the columns and rows are rotated and I'm unable to report the number of effective observations for different bandwidths.
    I used The Stata-to-LaTex Guide, regression table 5 as reference when trying to find a solution.
    Code:
    // directory setup:
    local root_dir //input desired directory
    cd "`root_dir'"
    
    // packages:
    
    ssc install estout, replace
    net install rdrobust, from(https://raw.githubusercontent.com/rdpackages/rdrobust/master/stata) replace
    
    //data:
    use "https://raw.githubusercontent.com/rdpackages/rdrobust/master/stata/rdrobust_senate.dta", clear
    
    //Rdrobust Regressions:
    eststo class_bwauto: rdrobust class margin, all
    eststo class_bw5: rdrobust class margin, all h(5 5)
    eststo class_bw10: rdrobust class margin, all h(10 10)
    
    eststo population_bwauto: rdrobust class margin, all
    eststo population_bw5: rdrobust class margin, all h(5 5)
    eststo population_bw10: rdrobust class margin, all h(10 10)
    
    // Table creation:
    esttab *_bwauto using "table.tex", replace f ///
      prehead(\begin{tabular}{l*{@M}{r}} \\\toprule) ///
      b(3) se(3) star(* 0.10 ** 0.05 *** 0.01)  ///
      keep(Robust) varlabels(Robust " MSE-optimal bandwidth") ///
      label booktabs noobs nonotes collabels(none) ///
      alignment(D{.}{.}{-1})
    
    esttab *_bw5 using "table.tex", append f ///
      b(3) se(3) star(* 0.10 ** 0.05 *** 0.01)  ///
      keep(Robust) varlabels(Robust "Bandwidth = 5") ///
      label booktabs nodep nonum nomtitles nolines noobs nonotes collabels(none) ///
      alignment(D{.}{.}{-1})
    
    esttab *_bw10 using "table.tex", append f ///
      postfoot(\bottomrule \end{tabular}) ///
      b(3) se(3) star(* 0.10 ** 0.05 *** 0.01)  ///
      keep(Robust) varlabels(Robust "Bandwidth = 10", elist(Robust \bottomrule)) ///
      label booktabs collabels(none) nomtitles nolines nonum ///
      alignment(D{.}{.}{-1}) sfmt(%6.0fc)
    Thank you so much for any help you are able to offer!
    Last edited by Patrick Rhatigan; 11 Apr 2023, 21:33.

  • #2
    I was able to rotate the table so the columns and rows are switched by changing the way I was grouping things together in esttab, but still can't figure out how to replace the total number of observations in the data with the effective observations.

    Comment

    Working...
    X