-------------------------------------------------------------------------------
       log:  /Users/baum/Desktop/771simul1.smcl
  log type:  smcl
 opened on:  13 Jan 2004, 15:09:56


. set more off

. local reps 1000

. . * set up model: y1 contains a homoskedastic error . * y2 contains an error term which is heteroskedastic across reg > ions . . . * define the simulation experiment . capture program drop mcsimul1

. program define mcsimul1, rclass 1. version 8.0 2. syntax [, c(real 1)] 3. tempvar e1 e2 4. . gen `e1' = invnorm(uniform())*`c'*zmu 5. gen `e2' = invnorm(uniform())*`c'*z_factor 6. replace y1 = true_y + `e1' 7. replace y2 = true_y + `e2' 8. summ y1 9. return scalar mu1 = r(mean) 10. return scalar se_mu1 = r(sd)/sqrt(r(N)) 11. summ y2 12. return scalar mu2 = r(mean) 13. return scalar se_mu2 = r(sd)/sqrt(r(N)) 14. return scalar c = `c' 15. end

. . forv i=1/10 { 2. * 50 states' data from US Census . webuse census2, clear 3. * true_y indicates the variable being used as base for the noisy measureme > nt . gen true_y = age 4. * z_factor is the variable generating heteroskedasticity in e2 . gen z_factor = region 5. sum z_factor, meanonly 6. scalar zmu = r(mean) 7. qui gen y1 = . 8. qui gen y2 = . 9. local c = `i'/10 10. simulate "mcsimul1, c(`c')" c= r(c) mu1=r(mu1) se_mu1=r(se > _mu1) mu2=r(mu2) /// > se_mu2=r(se_mu2), saving(c`i') reps(`reps') replace 11. } (1980 Census data by state)

command: mcsimul1 , c(.1) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(.2) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(.3) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(.4) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(.5) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(.6) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(.7) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(.8) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(.9) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2) (1980 Census data by state)

command: mcsimul1 , c(1) statistics: c = r(c) mu1 = r(mu1) se_mu1 = r(se_mu1) mu2 = r(mu2) se_mu2 = r(se_mu2)

. . * combine the results files into a single file for tabulation . use c1 (simulate: mcsimul1 , c(.1))

. forv i=2/10 { 2. append using c`i' 3. }

. gen het_infl = se_mu2 / se_mu1

. save c_1_5,replace file c_1_5.dta saved

. . * get descriptives on results file . tabstat mu1 se_mu1 mu2 se_mu2 het_infl, stat(mean) by(c)

Summary statistics: mean by categories of: c (r(c))

c | mu1 se_mu1 mu2 se_mu2 het_infl ---------+-------------------------------------------------- .1000000 | 29.50054 .2506937 29.50148 .250786 1.000809 .2000000 | 29.50132 .258681 29.50103 .2607732 1.009665 .3000000 | 29.49898 .2708054 29.49896 .2750963 1.019275 .4000000 | 29.49683 .2904351 29.49859 .2941107 1.017217 .5 | 29.4943 .3109184 29.50441 .3196732 1.034358 .6000000 | 29.50113 .3355029 29.50338 .3436218 1.031785 .6999999 | 29.49642 .3609801 29.50695 .3747851 1.046705 .8000000 | 29.49534 .388573 29.50361 .4052817 1.051592 .8999999 | 29.4884 .4179468 29.51082 .4362244 1.054253 1 | 29.47597 .4469752 29.49738 .4702556 1.062467 ---------+-------------------------------------------------- Total | 29.49492 .3331512 29.50266 .3430608 1.032813 ------------------------------------------------------------

. . tabstat het_infl, stat(mean q iqr) by(c)

Summary for variables: het_infl by categories of: c (r(c))

c | mean p25 p50 p75 iqr ---------+-------------------------------------------------- .1000000 | 1.000809 .977846 1.001489 1.02282 .044974 .2000000 | 1.009665 .9672523 1.008276 1.052025 .0847728 .3000000 | 1.019275 .9575091 1.015244 1.082557 .1250474 .4000000 | 1.017217 .9451016 1.010521 1.084836 .1397345 .5 | 1.034358 .9464142 1.029698 1.109589 .1631753 .6000000 | 1.031785 .9366941 1.025416 1.116515 .1798214 .6999999 | 1.046705 .9423029 1.038557 1.138606 .1963029 .8000000 | 1.051592 .9479856 1.038734 1.141216 .1932307 .8999999 | 1.054253 .9355309 1.038686 1.152963 .2174317 1 | 1.062467 .9460132 1.045486 1.165483 .2194697 ---------+-------------------------------------------------- Total | 1.032813 .9553461 1.017531 1.098257 .1429107 ------------------------------------------------------------

. . set more on

. log close log: /Users/baum/Desktop/771simul1.smcl log type: smcl closed on: 13 Jan 2004, 15:10:46 -------------------------------------------------------------------------------