/*************************************************************************************** ECO304 DePaul University Jin Man Lee An Example of Population, Sample and Sample Mean Distribuion using House Price in Chicago The house prices are the listing prices at MLS in 2017. Consider the whole listing price is the population. ****************************************************************************************/ clear all use https://bigblue.depaul.edu/jlee141/econdata/eco375/mls2017chi.dta summarize hprice keep hprice hist hprice, xline(279358) title(Distribution of All House Price N=48523) name(g1,replace) save mls2007, replace sample 1000, count summarize hprice hist hprice, xline(279358) title(Sample Distribution of House Price n=1000) name(g2,replace) graph combine g1 g2, col(1) /* Sample Size of 25 */ program housep, rclass drop _all use mls2017 sample 25, count summarize hprice return scalar meanx = r(mean) end simulate xbar = r(meanx), reps(500) : housep sum xbar hist xbar, xline(279358) bin(15) name(sg1,replace) title(A. Sample Mean Distribution from Sample Size of 25) program drop housep /* Sample Size of 100 */ program housep, rclass drop _all use mls2017 sample 100, count summarize hprice return scalar meanx = r(mean) end simulate xbar = r(meanx), reps(500) : housep sum xbar hist xbar, xline(279358) bin(15) name(sg2,replace) title(B. Sample Mean Distribution from Sample Size of 100) program drop housep /* Sample Size of 2500 */ program housep, rclass drop _all use mls2017 sample 2500, count summarize hprice return scalar meanx = r(mean) end simulate xbar = r(meanx), reps(500) : housep sum xbar hist xbar, xline(279358) bin(15) name(sg3,replace) title(C. Sample Mean Distribution from Sample Size of 2500) program drop housep graph combine g1 g2 sg1 sg2 sg3, col(1) xcommon xsize(7) ysize(10)