Hello, I need to overlay a simple line plot on the top of a coefplot graph (obtained by combining two regressions using reghdfe). In theory, the two should have the same values on the x-axis. In practice, they don't, because I manually renamed the interactions in coefplot with years.
This is my code:
The best I obtained is this graph, using "addplot" with xaxis(2)
Does anyone have a solution? I thought about using marginsplot, but I would not know how given the multiple nested groups.
This is my code:
eststo mig1: reghdfe asinh_mig_ss high_rei##ib2000.year if year <2006, absorb (district#year country#year district#country ) cluster(district)
eststo mig2: reghdfe asinh_mig_podes high_rei##ib2005.year, absorb (district#year country#year district#country ) cluster(district)
coefplot (mig1, mcolor(maroon) symbol(X) ciopts(recast(rcap) color(maroon)) keep(1.high_rei#2000.year 1.high_rei#*.year) drop(1.high_rei#2005.year 1.high_rei#2008.year 1.high_rei#2011.year 1.high_rei#2014.year ) omitted baselevels ///
rename( 1.high_rei#2000.year = 2000 ///
1.high_rei#2001.year = 2001 ///
1.high_rei#2002.year = 2002 ///
1.high_rei#2003.year = 2003 ///
1.high_rei#2004.year = 2004)) ///
(mig2, keep(1.high_rei#2005.year 1.high_rei#2008.year 1.high_rei#2011.year 1.high_rei#2014.year ) omitted baselevels ///
rename(1.high_rei#2005.year = 2005 ///
1.high_rei#2008.year = 2008 ///
1.high_rei#2011.year = 2011 ///
1.high_rei#2014.year = 2014) mcolor(black) ciopts(recast(rcap) color(black)) ), ///
label yline(0) levels(95) vertical ylabel(, angle(horizontal)) graphregion(color(white)) bgcolor(white) offset(0)
addplot: line REI_med_1 year if tag1, sort xaxis(2)
eststo mig2: reghdfe asinh_mig_podes high_rei##ib2005.year, absorb (district#year country#year district#country ) cluster(district)
coefplot (mig1, mcolor(maroon) symbol(X) ciopts(recast(rcap) color(maroon)) keep(1.high_rei#2000.year 1.high_rei#*.year) drop(1.high_rei#2005.year 1.high_rei#2008.year 1.high_rei#2011.year 1.high_rei#2014.year ) omitted baselevels ///
rename( 1.high_rei#2000.year = 2000 ///
1.high_rei#2001.year = 2001 ///
1.high_rei#2002.year = 2002 ///
1.high_rei#2003.year = 2003 ///
1.high_rei#2004.year = 2004)) ///
(mig2, keep(1.high_rei#2005.year 1.high_rei#2008.year 1.high_rei#2011.year 1.high_rei#2014.year ) omitted baselevels ///
rename(1.high_rei#2005.year = 2005 ///
1.high_rei#2008.year = 2008 ///
1.high_rei#2011.year = 2011 ///
1.high_rei#2014.year = 2014) mcolor(black) ciopts(recast(rcap) color(black)) ), ///
label yline(0) levels(95) vertical ylabel(, angle(horizontal)) graphregion(color(white)) bgcolor(white) offset(0)
addplot: line REI_med_1 year if tag1, sort xaxis(2)
The best I obtained is this graph, using "addplot" with xaxis(2)
Does anyone have a solution? I thought about using marginsplot, but I would not know how given the multiple nested groups.
Comment