I am using the reghdfe command for estimations at the subnational level (i.e. states and provinces) and would like to add a row at the bottom of the table which lists the number of countries in each column.
The country variable in the example below is CodeNum. While the number of countries in the example below does not change with columns, I envision future tables in the paper where the number of countries will intentionally change by column.
I tried N_hdfe as a scalar, but (a) that does not solve the problem since at least two columns do not have fixed effects, and (b) it returned a value of 1 for every column in the table when I tried initially (I am puzzled as to why that happened.)
The country variable in the example below is CodeNum. While the number of countries in the example below does not change with columns, I envision future tables in the paper where the number of countries will intentionally change by column.
I tried N_hdfe as a scalar, but (a) that does not solve the problem since at least two columns do not have fixed effects, and (b) it returned a value of 1 for every column in the table when I tried initially (I am puzzled as to why that happened.)
Code:
eststo clear reghdfe LnRegGDP denIn1850_25km_5k densqIn1850_25km_5k $coregeog if harmonized==1, noabsorb vce(robust) qui estimates store model1 reghdfe LnRegGDP denIn1850_25km_5k densqIn1850_25km_5k $coregeog $Xlist1 if harmonized==1, noabsorb vce(robust) qui estimates store model2 reghdfe LnRegGDP denIn1850_25km_5k densqIn1850_25km_5k $coregeog $Xlist1 if harmonized==1, absorb(contno) vce(robust) qui estimates store model3 reghdfe LnRegGDP denIn1850_25km_5k densqIn1850_25km_5k $coregeog $Xlist1 if harmonized==1, absorb(CodeNum) cluster(CodeNum) qui estimates store model4 local indepvar "denIn1850_25km_5k densqIn1850_25km_5k" local tabletitle: var lab LnRegGDP * Prepare estimates for -estout- *Check estfe is installed. estfe model3 model4, labels(contno "Cont. FE" CodeNum "Country FE") return list local addgeog "temp_mean alt_mean rain_mean rug_mean temp_stdev rain_stdev inversedistcoast inversedistriver " * Run estout/esttab esttab model* using "$results\baselinecityden_LnRegGDP_1850.tex", replace /// indicate("Addl. Geog. Cntrl.=`addgeog'" `r(indicate_fe)') /// keep(`indepvar' $coregeog ) /// cells(b(star fmt(2)) se(par([ ]) fmt(2))) starlevels( * 0.10 ** 0.05 *** 0.010) nocons /// label booktabs nonotes nomtitle collabels(none) /// title (`tabletitle') /// scalars( "N Obs." "r2_a Adj. R2" "r2_a_within Adj. Wn. R2") sfmt(0 0 2 2) * Return stored estimates to their previous state estfe model3 model4, restore