-----------------------------------------------------------------------------------------
       log:  /Users/baum/doc/Courses 2008-2009/EC771 S2009/771irwd.smcl
  log type:  smcl
 opened on:  28 Mar 2009, 10:23:29


. capt prog drop _all

. prog irwd, rclass 1. version 10.1 2. drop _all 3. set obs $N 4. g en = _n - $N/2 5. g double x = 0 in 1 6. g double y = 0 in 1 7. replace x = x[_n - 1] + $trcoef * en + rnormal() in 2/l 8. replace y = y[_n - 1] + $trcoef * en + rnormal() in 2/l 9. reg y x 10. return scalar b = _b[x] 11. return scalar se = _se[x] 12. return scalar t = _b[x]/_se[x] 13. return scalar r2 = abs(return(t)) > invttail($N - 2, 0.025) 14. end

. . global N 100

. global nsim 10000

. set seed 1010101

. . // consider IRWs with no drift . global trcoef 0

. simulate birwd=r(b) sirwd=r(se) tirwd=r(t) rejirwd=r(r2), /// > reps($nsim) nodots saving(irw0, replace): irwd

command: irwd birwd: r(b) sirwd: r(se) tirwd: r(t) rejirwd: r(r2)



. su

Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- birwd | 10000 .0003267 .6336891 -3.682241 3.301136 sirwd | 10000 .100645 .0649186 .0116683 .6898782 tirwd | 10000 -.0225758 7.390102 -34.39042 35.8372 rejirwd | 10000 .7572 .4287966 0 1

. l in 1/20

+--------------------------------------------+ | birwd sirwd tirwd rejirwd | |--------------------------------------------| 1. | .4797036 .0366694 13.08186 1 | 2. | -.3215804 .126415 -2.543845 1 | 3. | .5518465 .0509739 10.82607 1 | 4. | -.9704604 .0774199 -12.53502 1 | 5. | .9274789 .0991612 9.353246 1 | |--------------------------------------------| 6. | -.7858061 .0432042 -18.18819 1 | 7. | -.5938631 .0538909 -11.01972 1 | 8. | .6821204 .1127544 6.049611 1 | 9. | .5334677 .0528825 10.0878 1 | 10. | .0958101 .0618102 1.550069 0 | |--------------------------------------------| 11. | -.3524039 .0844574 -4.172564 1 | 12. | .251032 .1512837 1.659346 0 | 13. | .8574678 .1752042 4.894105 1 | 14. | -.3218689 .0791635 -4.065877 1 | 15. | .2293266 .0713637 3.21349 1 | |--------------------------------------------| 16. | -.3609286 .1122861 -3.214365 1 | 17. | -.5108765 .1038393 -4.919877 1 | 18. | -.0265709 .0448767 -.5920879 0 | 19. | -1.321453 .0955171 -13.83473 1 | 20. | -1.061208 .0308577 -34.39042 1 | +--------------------------------------------+

. . // consider IRWs with drift . global trcoef 1

. simulate birwd=r(b) sirwd=r(se) tirwd=r(t) rejirwd=r(r2), /// > reps($nsim) nodots saving(irw1, replace): irwd

command: irwd birwd: r(b) sirwd: r(se) tirwd: r(t) rejirwd: r(r2) (note: file irw1.dta not found)



. su

Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- birwd | 10000 1.000051 .0059501 .9779344 1.020759 sirwd | 10000 .0013194 .0005875 .0004052 .0048519 tirwd | 10000 898.6508 356.9464 205.0394 2464.296 rejirwd | 10000 1 0 1 1

. l in 1/20

+------------------------------------------+ | birwd sirwd tirwd rejirwd | |------------------------------------------| 1. | 1.006996 .0006071 1658.826 1 | 2. | 1.003831 .0017482 574.2126 1 | 3. | .9950045 .0015522 641.0201 1 | 4. | 1.00533 .0009019 1114.629 1 | 5. | 1.004174 .0013782 728.6036 1 | |------------------------------------------| 6. | .9963799 .0016361 609.0062 1 | 7. | .991939 .0013959 710.623 1 | 8. | .9926373 .001226 809.6337 1 | 9. | .9976078 .00183 545.1342 1 | 10. | .9944842 .0006148 1617.636 1 | |------------------------------------------| 11. | 1.006605 .0021063 477.9079 1 | 12. | 1.000501 .0017072 586.0491 1 | 13. | .9992536 .0008514 1173.694 1 | 14. | .9968744 .0008095 1231.394 1 | 15. | .9952904 .0014757 674.4478 1 | |------------------------------------------| 16. | 1.010844 .0019668 513.9488 1 | 17. | 1.002531 .0007761 1291.714 1 | 18. | 1.010013 .0018247 553.519 1 | 19. | 1.000184 .0013261 754.2089 1 | 20. | 1.002476 .001661 603.5215 1 | +------------------------------------------+

. . log close log: /Users/baum/doc/Courses 2008-2009/EC771 S2009/771irwd.smcl log type: smcl closed on: 28 Mar 2009, 10:25:37 -----------------------------------------------------------------------------------------