clear *Create paths to folders global data "C:\Users\aapo.kivinen\Dropbox (Aalto)\PhD\teaching\Principles_of_Economic_Analysis\aapo\session two\data" global output "C:\Users\aapo.kivinen\Dropbox (Aalto)\PhD\teaching\Principles_of_Economic_Analysis\aapo\session two\output" *To make nicer graphs *ssc install grstyle (Run this if you have not downloaded it yet) set scheme s2color grstyle init grstyle set plain *Import data set to Stata use "$data\cleaned_data.dta", clear *Plot the cumulative distribution function of fathers age ssc install distplot distplot fathers_age if age_group == 10, xtitle(Fathers age) graph export "$output\c_dist.pdf", replace *Plot the density function of fathers age twoway (kdensity fathers_age), xtitle(Fathers age) graph export "$output\p_dist.pdf", replace xtile father_age_group=fathers_age, nq(10) egen min = min(fathers_age), by(father_age_group) egen max = max(fathers_age), by(father_age_group) graph bar (mean) max, over(father_age_group) ytitle(Years) title(Fathers age by decile) blabel(bar) graph export "$output\percentile.pdf", replace drop if age<11 preserve collapse (mean) income, by(age_group sex high_school) local sc_opt "c(l)" local opt "xlab(20(10)70, valuelabel) xtitle("Age group") ytitle("Income decile") legend(lab(1 "Not Academic") lab(2 "Academic"))" twoway (scatter income age_group if high_school==0 & sex==1, `sc_opt') /// (scatter income age_group if high_school==1 & sex==1, `sc_opt'), `opt' subtitle(A. Men) name(wages_men, replace) twoway (scatter income age_group if high_school==0 & sex==2, `sc_opt') /// (scatter income age_group if high_school==1 & sex==2, `sc_opt'), `opt' subtitle(B. Female) name(wages_women, replace) graph combine wages_men wages_women, ycommon name(combined1, replace) graph export "$output\development.pdf", replace restore preserve * Growth in groups forvalues yy=20(10)70{ egen mean_income_`yy' = mean(income) if age_group==`yy', by(high_school sex) } collapse (min) mean_income_*, by(high_school sex) gen change = mean_income_50-mean_income_30 graph bar (mean) change, over(sex) over(high_school) blabel(bar, format(%9.2g)) ytitle(Change) title("Change in income decile from age group 20-30 to 40-50""by degree and sex", size(medium)) graph export "$output\change.pdf", replace restore