set scheme s1mono /* Note this file takes the output of cps_ipums_final is the file that is produced by read_ipums. Depending on how you did things, you might want to change this file name*/ /* Problem 5 */ use earnings asset_inc year wt using cps_ipums_final, replace gen earnings_plus=earnings+asset_inc gen asset_share=asset_inc/earnings_plus collapse (sd) earnings asset_inc earnings_plus [aw=wt], by(year) foreach var of varlist earnings asset_inc earnings_plus { replace `var'=`var'^2 /* std-> variance */ } gen term_labor=earnings/1e6 gen term_asset=asset_inc/1e6 gen term_covariance=1e-6*earnings_plus-term_labor-term_asset /* the covariance term is whatever is left over */ line term_labor term_asset term_covariance year, color(red blue black) xtitle("Year") ytitle("Components of Inequality" "(thousands of dollars)") legend(lab(1 "Labor") lab(2 "Asset") lab(3 "Covariance")) graph export "ps1_problem5.eps", replace /* Problem 4*/ use if firstHH==1 using cps_ipums_final, replace collapse (p90) earnings_HH_p90=earnings_HH earnings_plus_HH_p90=earnings_plus_HH pre_gov_HH_p90=pre_gov_HH pre_tax_HH_p90=pre_tax_HH /* */ (p50) earnings_HH_p50=earnings_HH earnings_plus_HH_p50=earnings_plus_HH pre_gov_HH_p50=pre_gov_HH pre_tax_HH_p50=pre_tax_HH /* */ (p10) earnings_HH_p10=earnings_HH earnings_plus_HH_p10=earnings_plus_HH pre_gov_HH_p10=pre_gov_HH pre_tax_HH_p10=pre_tax_HH [aw=hwtsupp], by(year) local varlist="earnings_HH earnings_plus_HH pre_gov_HH pre_tax_HH" foreach var of local varlist { gen `var'_90_50= `var'_p90/ `var'_p50 gen `var'_50_10= `var'_p50/ `var'_p10 } by year: keep if _n==1 keep year earnings_HH_90_50-pre_tax_HH_50_10 line earnings_HH_90_50 earnings_HH_50_10 year, xtitle("Year") ytitle("Labor Earnings") color(red blue) legend(lab(1 "90-50 Ratio") lab(2 "50-10 Ratio")) xlab(1980(10)2010) graph save problem4_1.gph, replace line earnings_plus_HH_90_50 earnings_plus_HH_50_10 year, xtitle("Year") ytitle("Labor+Asset Earnings") color(red blue) legend(lab(1 "90-50 Ratio") lab(2 "50-10 Ratio")) xlab(1980(10)2010) graph save problem4_2.gph, replace line pre_gov_HH_90_50 pre_gov_HH_50_10 year, xtitle("Year") ytitle("Pre-Government") color(red blue) legend(lab(1 "90-50 Ratio") lab(2 "50-10 Ratio")) xlab(1980(10)2010) graph save problem4_3.gph, replace line pre_tax_HH_90_50 pre_tax_HH_50_10 year, xtitle("Year") ytitle("Pre-Tax") color(red blue) legend(lab(1 "90-50 Ratio") lab(2 "50-10 Ratio")) xlab(1980(10)2010) graph save problem4_4.gph, replace graph combine problem4_1.gph problem4_2.gph problem4_3.gph problem4_4.gph graph export "ps1_problem4.eps", replace /* Problem 6 */ use if year==1976 | year==2007 | year==2013 using cps_ipums_final, replace collapse (sum) hours (mean) wage [aw=wt], by(year occ1990) reshape wide hours wage, i(occ1990) j(year) keep if hours1976>0 & hours1976<. & hours2007>0 & hours2007<. & hours2013>0 & hours2013<. sort wage1976 gen skillrank=_n/_N gen grow_wage_2007_1976=log(wage2007/wage1976)/31 gen grow_wage_2013_2007=log(wage2013/wage2007)/6 gen grow_hours_2007_1976=log(hours2007/hours1976)/31 gen grow_hours_2013_2007=log(hours2013/hours2007)/6 lpoly grow_wage_2007_1976 skillrank if skillrank>.05 & skillrank<.95, xtitle("Skill Percentile") ytitle("(Smoothed) Wage Growth 1976-2007") noscatter title("") note("") graph save problem6_1.gph, replace lpoly grow_wage_2013_2007 skillrank if skillrank>.05 & skillrank<.95, xtitle("Skill Percentile") ytitle("(Smoothed) Wage Growth 2007-2013") noscatter title("") note("") graph save problem6_2.gph, replace lpoly grow_hours_2007_1976 skillrank if skillrank>.05 & skillrank<.95, xtitle("Skill Percentile") ytitle("(Smoothed) Hours Growth 1976-2007") noscatter title("") note("") graph save problem6_3.gph, replace lpoly grow_hours_2013_2007 skillrank if skillrank>.05 & skillrank<.95, xtitle("Skill Percentile") ytitle("(Smoothed) Hours Growth 2007-2013") noscatter title("") note("") graph save problem6_4.gph, replace graph combine problem6_1.gph problem6_2.gph problem6_3.gph problem6_4.gph graph export "ps1_problem6.eps", replace