-----------------------------------------------------------------------------------------
       log:  /Users/baum/doc/Courses 2008-2009/EC771 S2009/771mcsim1.smcl
  log type:  smcl
 opened on:  25 Mar 2009, 22:30:29


. . * Program to draw 1 sample of size 30 from uniform and return sample mean . program onesample, rclass 1. drop _all 2. quietly set obs 30 3. generate x = runiform() 4. summarize x 5. return scalar meanforonesample = r(mean) 6. end

. . * Run program onesample once as a check . set seed 10101

. onesample

Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- x | 30 .5459987 .2803788 .0524637 .9983786

. return list

scalars: r(meanforonesample) = .5459987225631873

. . * Run program onesample 10,000 times to get 10,000 sample means . simulate xbar = r(meanforonesample), seed(10101) reps(10000) nodots: onesample

command: onesample xbar: r(meanforonesample)



. . * Summarize the 10,000 sample means and draw histogram . summarize xbar

Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- xbar | 10000 .4995835 .0533809 .3008736 .6990562

. histogram xbar, normal xtitle("xbar from many samples") (bin=40, start=.30087364, width=.00995456)

. . quietly graph export mus04fig1clt2.pdf, replace

. . log close log: /Users/baum/doc/Courses 2008-2009/EC771 S2009/771mcsim1.smcl log type: smcl closed on: 25 Mar 2009, 22:31:17 -----------------------------------------------------------------------------------------