For some reason I cannot capture several scalars in this loop:
eststo clear
foreach x of local lambdatypesr{
eststo: xtreg `x' lambda_cumr i.ym if ym<773, fe i(spgrid_id) vce(cluster spgrid_id)
summarize `x' if lambda_cumr > 0
estadd scalar ypost = r(mean)
estadd scalar lightchangemean = `mean_lights'
estadd scalar adjcoeff = (_b[lambda_cumr] * `mean_lights')/(abs(_b[lambda_cumr])+e(ypost))*100
estadd scalar adjCIlower = ((_b[lambda_cumr]- 1.96*_se[lambda_cumr]) * `mean_lights') / (abs((_b[lambda_cumr]- 1.96*_se[lambda_cumr])) + e(ypost))*100
estadd scalar adjCIupper = ((_b[lambda_cumr]+ 1.96*_se[lambda_cumr]) * `mean_lights') / (abs((_b[lambda_cumr]+ 1.96*_se[lambda_cumr])) + e(ypost))*100
}
esttab using "paper/kde/tables/regress_kde_`i'`j'.rtf", ///
keep(lambda_cumr) ///
depvar se stats(ypost adjcoeff adjCIlower adjCIupper N, labels ("Ave. Post" "% Change" "Lower 5%" "Upper 95%" "N")) ///
label nonumber ///
title("Changes in Lights on `i' `j' Crime ") ///
mtitle("Total" "Gun" "Violent" "Property" "Nuisance" "Fraud") ///
note(Standard errors in parentheses; Hexagon and year-month fixed effects) ///
replace
eststo clear
foreach x of local lambdatypesr{
eststo: xtreg `x' lambda_cumr i.ym if ym<773, fe i(spgrid_id) vce(cluster spgrid_id)
summarize `x' if lambda_cumr > 0
estadd scalar ypost = r(mean)
estadd scalar lightchangemean = `mean_lights'
estadd scalar adjcoeff = (_b[lambda_cumr] * `mean_lights')/(abs(_b[lambda_cumr])+e(ypost))*100
estadd scalar adjCIlower = ((_b[lambda_cumr]- 1.96*_se[lambda_cumr]) * `mean_lights') / (abs((_b[lambda_cumr]- 1.96*_se[lambda_cumr])) + e(ypost))*100
estadd scalar adjCIupper = ((_b[lambda_cumr]+ 1.96*_se[lambda_cumr]) * `mean_lights') / (abs((_b[lambda_cumr]+ 1.96*_se[lambda_cumr])) + e(ypost))*100
}
esttab using "paper/kde/tables/regress_kde_`i'`j'.rtf", ///
keep(lambda_cumr) ///
depvar se stats(ypost adjcoeff adjCIlower adjCIupper N, labels ("Ave. Post" "% Change" "Lower 5%" "Upper 95%" "N")) ///
label nonumber ///
title("Changes in Lights on `i' `j' Crime ") ///
mtitle("Total" "Gun" "Violent" "Property" "Nuisance" "Fraud") ///
note(Standard errors in parentheses; Hexagon and year-month fixed effects) ///
replace
Comment