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


. . * Define global macros for sample size and number of simulations . global numobs 150 // sample size N

. global numsims "1000" // number of simulations

. . * Program for finite-sample properties of OLS . program chi2data, rclass 1. version 10.1 2. drop _all 3. set obs $numobs 4. generate double x = rchi2(1) 5. generate y = 1 + 2*x + rchi2(1)-1 // demeaned chi^2 error 6. regress y x 7. return scalar b2 =_b[x] 8. return scalar se2 = _se[x] 9. return scalar t2 = (_b[x]-2)/_se[x] 10. return scalar r2 = abs(return(t2))>invttail($numobs-2,.025) 11. return scalar p2 = 2*ttail($numobs-2,abs(return(t2))) 12. end

. . set seed 10101

. * Simulation for finite-sample properties of OLS . simulate b2f=r(b2) se2f=r(se2) t2f=r(t2) reject2f=r(r2) p2f=r(p2), /// > reps($numsims) saving(chi2datares, replace) nolegend nodots: chi2data



. . summarize b2f se2f reject2f

Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- b2f | 1000 2.000506 .08427 1.719513 2.40565 se2f | 1000 .0839776 .0172588 .0415919 .145264 reject2f | 1000 .046 .2095899 0 1

. * Summarize results . mean b2f se2f reject2f

Mean estimation Number of obs = 1000

-------------------------------------------------------------- | Mean Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ b2f | 2.000506 .0026649 1.995277 2.005735 se2f | .0839776 .0005458 .0829066 .0850486 reject2f | .046 .0066278 .032994 .059006 --------------------------------------------------------------

. . // histogram t2f . histogram p2f (bin=29, start=.0000108, width=.0344747)

. graph export mus04p2test.pdf, replace (file /Users/baum/doc/Courses 2008-2009/EC771 S2009/mus04p2test.pdf written in PDF format > )

. . * t-statistic distribution . kdensity t2f, n(1000) gen(t2_x t2_d) nograph

. generate double t2_d2 = tden(148, t2_x)

. graph twoway (line t2_d t2_x) (line t2_d2 t2_x)

. . graph export mus04ttest.pdf, replace (file /Users/baum/doc/Courses 2008-2009/EC771 S2009/mus04ttest.pdf written in PDF format)

. . * Program for finite-sample properties of OLS: power . program chi2datab, rclass 1. version 10.1 2. drop _all 3. set obs $numobs 4. generate double x = rchi2(1) 5. generate y = 1 + 2*x + rchi2(1)-1 // demeaned chi^2 error 6. regress y x 7. return scalar b2 =_b[x] 8. return scalar se2 =_se[x] 9. test x=2.1 10. return scalar r2 = (r(p)<.05) 11. end

. . * Power simulation for finite-sample properties of OLS . simulate b2f=r(b2) se2f=r(se2) reject2f=r(r2), /// > reps($numsims) saving(chi2databres, replace) nolegend nodots: chi2datab



. . mean b2f se2f reject2f

Mean estimation Number of obs = 1000

-------------------------------------------------------------- | Mean Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ b2f | 2.001852 .0026976 1.996559 2.007146 se2f | .0836442 .0005591 .0825471 .0847414 reject2f | .241 .0135315 .2144465 .2675535 --------------------------------------------------------------

. . log close log: /Users/baum/doc/Courses 2008-2009/EC771 S2009/771mcsim2.smcl log type: smcl closed on: 25 Mar 2009, 22:42:48 -----------------------------------------------------------------------------------------