Hello Members,
Below is a code taken from this post: https://www.statalist.org/forums/for...nel-data-graph
Is there a way to modify this code to include parallel trends?
I would appreciate any help!
Thanks,
Anoush
Below is a code taken from this post: https://www.statalist.org/forums/for...nel-data-graph
Is there a way to modify this code to include parallel trends?
I would appreciate any help!
Thanks,
Anoush
Code:
// open some example data clear all use "https://www.rug.nl/ggdc/docs/pwt90.dta", clear gen gdppc = rgdpe/ pop eep country year gdppc pl_con // keep the first 35 countries bys country (year) : gen mark = _n == 1 replace mark = sum(mark) keep if mark <= 35 drop mark // sort countries by their average price level bys country : egen mean = mean(pl_con) egen order = rank(mean), track labmask order, values(country) // add background lines tempfile temp save `temp' separate pl_con, by(country) veryshortlabel forvalues i = 1/35 { bys year (pl_con`i') : replace pl_con`i' = pl_con`i'[1] by year : gen gdppc`i' = gdppc[1] } keep if country == "Albania" keep year pl_con? pl_con?? gdppc? gdppc?? merge 1:m year using `temp' local gr "" forvalues i = 1/35 { local gr `gr' line pl_con`i' gdppc`i', lpattern(solid) lcolor(gs12) || } // final graph sort order year twoway `gr' /// line pl_con gdppc , by(order, legend(off) compact note("")) /// lpattern(solid) lwidth(*1.2) /// xscale(log) xlab(1000 "10{sup:3}" 10000 "10{sup:4}" 100000 "10{sup:5}") /// xtitle("GDP per capita (log scale)") ytitle("price level (USA 2011 = 1)")
Comment