version 10.0 capture log close *--------------------------------------------------- * the above command closes a log file that has * inadvertently been left open. Trying to open a new * log file when one is already open causes an error. *--------------------------------------------------- log using chap02, replace use food, clear *------------------------------------------------ * Be careful when using above command that you do * want to clear Stata's memory. *------------------------------------------------ * examine data describe browse list list in 1/2 list in 11/20 * compute summary statistics summarize * summarize food expenditure with detail summarize food_exp, detail * simple plot data twoway (scatter food_exp income) more *------------------------------------------------ * The more command pauses output so graph can be * examined. *------------------------------------------------ * enhanced plot twoway (scatter food_exp income), ylabel(0(100)600) xlabel(0(5)35) title(Food Expenditure Data) more * compute least squares regression regress food_exp income * compute elasticity at means mfx compute, eyex at(mean) * calculate fitted values & residuals predict yhat, xb predict ehat, residuals browse * plot fitted values and data scatter twoway (scatter food_exp income) (lfit food_exp income), ylabel(0(100)600) xlabel(0(5)35) title(Fitted Regression Line) more * examine variances and covariances estat vce * add observation to data file edit set obs 41 replace income=20 in 41 * obtain prediction predict yhat0 list income yhat0 in 41 * save data save chap02.dta, replace * close log log close * translate smcl to text file translate chap02.smcl chap02.txt, replace