Hacking the esttab for rdmc.
I have been working on a project with an RD design. The design has different cutoffs for different years. To that end, I came across the Stata package, rdmc, which has been developed for these kind of scenarios: multiple cutoffs across different years.
Now, in general, I use the esttab package to output my regression results as very nicely formatted publishable tables. In this case though, the rdmc command puts out two kind of coefficients: the normal ones and the robust-bias corrected ones. If you run esttab after rdmc, two things will happen. First, it will only publish robust-bias corrected coefficients. Secondly, it will not publish the number of observations (N).
So, what if you want to report normal co-efficients and N too?
Well, when you run esttab after a regression or rdmc result, it will go and fetch something called e(b), which is an e-matrix (a Stata thing), and put it as output.
But we want to report the normal coefficients too. So, you will rewrite the e(b) matrix. In this case, I only wanted the pooled results from the rdmc command. Here’s the function:
capture program drop mypost5
program define mypost5, eclass
args pooled_val pooled_se sample_size
/* Creating three matrices that are accessed by esttab
e(b), e(V) and N.
*/
matrix b = (`pooled_val')
matrix colnames b = "Pooled_Effect"
* Calculate variance (SE squared) for the variance matrix
local pooled_var = `pooled_se'^2
matrix V = (`pooled_var')
matrix colnames V = "Pooled_Effect"
matrix rownames V = "Pooled_Effect"
ereturn post b V, obs(`sample_size') dof(`sample_size')
ereturn scalar N = `sample_size'
end
And then you call the aforesaid function
local pooled_val = e(coefs)[1, "pooled"]
local pooled_se = e(se_pool_rb)
mypost5 `pooled_val' `pooled_se' 1200
esttab using "rd_table_1.tex", ///
b(3) se(3) star ///
mtitle("CTC") ///
varlabels(Pooled_Effect "RD estimate") ///
style(tex) ///
replace
Now esstab has a new regression result that has been hacked to work with esttab. You can also extend it for more co-efficients of course. I also need to thank Claude to help me think through this hack.