*USP 2/2017 *Course: FLS6183 *Author: Lorena Barberia *Lab 3 - What is the difference between the population regression function and the sample regression functions? * Do these differences depending on how we select our sample? *In order to examine this question, we will use the data provided by Gujarati in his textbook. * We are also going to learn how to summarize the information we have gathered in a regression table using estout. * ssc install estout *Loading data cd "C:\Data\", clear *Let's see how our data looks like: sum consumption income *This is our population model: reg consumption income est sto m1 twoway (scatter consumption income) (lfit consumption income) * Note that there are 10 income categories. *Now, let's draw our random samples and run the models: *Sample A: n=10 use "gujarti", clear set seed 1245 sample 10, count sum consumption income reg consumption income est sto m2 twoway (scatter consumption income) (lfit consumption income) *Sample B: n=10 use "gujarti", clear set seed 1245 sample 10, count sum consumption income reg consumption income est sto m3 twoway (scatter consumption income) (lfit consumption income) esttab m1 m2 m3, ci *Sample C: n=30 use "gujarti", clear set seed 1245 sample 30, count sum consumption income reg consumption income est sto m4 twoway (scatter consumption income) (lfit consumption income) *Sample D: n=30 use "gujarti", clear set seed 1245 sample 30, count sum consumption income reg consumption income est sto m5 twoway (scatter consumption income) (lfit consumption income) esttab m1 m4 m5, ci ** Now let's stratify the sample by income and random sample from each group (this is similar to Gujarati) ** First we will need to install two user-written packages. *ssc install moremata *ssc install gsample use "gujarti", clear gsample 10, percent strata(income) reg consumption income twoway (scatter consumption income) (lfit consumption income) est sto m6 esttab m1 m2 m6, ci * This command draws a 10% sample. * For stratified sampling, a 10-percent sample is drawn from each stratum, thus maintaining the proportion of each stratum.