log using ex1_201920_log, text replace ***************************************** * Econometrics 1 * University of Warwick * Exercise 1: Introduction ****************************************** *NOTE: Ensure that the right directory is set before running the do files *Type help cd in the command window to know how to set your work directory *q2: load data into Stata use icfforworkbook, clear *q3: review data in data editor browse *q4: open a log file to record output *see line 1 of this DO file *q5: describe data describe *q6: data codebook to examine the dataset codebook, compact *q7: summarise expenditure su expenditure su expenditure, detail *summarise income su income su income, detail *histograms of expenditure and income histogram expenditure, percent title("Histogram of weekly expenditure") histogram income, percent title("Histogram of weekly income") *q8: create variables after trimming the top 1% of income and expenditure clonevar inc = income qui sum income, detail replace inc =. if income>=`r(p99)' la var inc "Income" clonevar exp = expenditure qui sum expenditure, detail replace exp =. if expenditure>=`r(p99)' la var exp "Total expenditure" *q9: histogram after trimming top 1% of expenditure histogram exp, /// percent title("Histogram of weekly expenditure, Top 1% trimmed") graph save fig1_exercise_sheet1.gph, replace histogram inc, /// percent title("Histogram of weekly income, Top 1% trimmed") graph save fig2_exercise_sheet1.gph, replace *q10: summary of exp by main source of income bys maininc: su exp *q11: histogram of exp by main income source histogram exp, percent by(maininc) *q12: mean of expenditure by main income source and internet connection *ren A172 internet gen internet = 0 replace internet = 1 if A172 == 1 bys maininc internet: su exp *q13: Testing equality of means by main income sources in weekly expenditure ttest exp, by(maininc) unequal *q14: Testing equality of means by access to internet in weekly expenditure ttest exp, by(internet) unequal *q15: Testing equality of means by main income sources and internet access in weekly expenditure anova exp maininc internet maininc#internet *q16: Plotting exp agains income categories gen inc_cat = 1 if (income <250) replace inc_cat = 2 if (income >= 250 & income < 500) replace inc_cat = 3 if (income >= 500 & income < 750) replace inc_cat = 4 if (income >= 750 & income < 1000) replace inc_cat = 5 if (income >= 1000) label define inc_cat_l 1 "<250" 2 "250-499" 3 "500-749" 4 "750-999" 5 ">= 1000" label val inc_cat inc_cat_l graph bar (mean) exp, over(inc_cat, label(angle(forty_five))) by(, title(Average expenditure over Income categories by income source)) by(maininc) *q17: Testing equality of means of exp over income categories oneway exp inc_cat oneway exp inc_cat, tabulate *q18: Plotting and testing equality of mean expenditure against income categories by main income source, for hosueholds with an internet connection graph bar (mean) exp if internet == 1, over(inc_cat, label(angle(forty_five))) by(, title(Average expenditure over Income categories by income source) subtitle("(For households with internet)")) by(maininc) oneway exp inc_cat if (internet == 1) *save data save icfforworkbook_1, replace * close do file log close *---- eof ---