table4.do open
file:script:do
# | content log |
---|---|
1 [+] | #delimit |
2 [+] | cap log close |
3 [+] | log using table4.log , |
5 [+] | set more off |
6 [+] | clear |
7 [+] | set seed 10104 |
9 [+] | /* load up the programs. each do file has a program that will be used */ |
11 [+] | do set_directory_macros |
13 [+] | set matsize 10000 |
14 [+] | run t4_mcloop |
15 [+] | run t4_display |
16 [+] | run t34_programs |
18 [+] | cap prog drop runme |
19 [+] | prog def runme |
21 [+] | /* initialize the file names, lists, etc, that will be passed into the pgrograms */ |
23 [+] | local start = "$S_DATE $S_TIME" |
25 [+] | local num_mc_reps = 4 |
*local mc_reps_smallG = 1000 ; *local mc_reps_bigG = 4 ; |
|
28 [+] | local mc_reps_smallG = 4000 |
29 [+] | local mc_reps_bigG = 1000 |
31 [+] | local num_bs_reps = 399 |
*local num_states_list = "6 " ; |
|
33 [+] | local num_states_list = "6 10 20 30 50" |
34 [+] | local mysourcedata = "$madedat/CPS_panel" |
/* prepare the state list, and ensure that all files are sorted on statefip */ |
|
37 [+] | tempfile statelist mcout_all |
38 [+] | qui use "`mysourcedata'" |
39 [+] | cap drop resid |
40 [+] | sort statefip year |
41 [+] | qui save "`mysourcedata'" , |
42 [+] | contract statefip |
43 [+] | keep statefip |
44 [+] | sort statefip |
45 [+] | qui save "`statelist'" |
48 [+] | /* loop over number of states in the hum_states_list*/ |
50 [+] | cap erase `mcout_all' |
51 [+] | foreach ns in `num_states_list' { |
53 [+] | local num_mc_reps = `mc_reps_bigG' |
54 [+] | if `ns' < 11 { |
55 [+] | local num_mc_reps = `mc_reps_smallG' |
56 [+] | } |
58 [+] | tempfile mcout_`ns' |
59 [+] | di |
60 [+] | di "$S_DATE $S_TIME" |
61 [+] | do_the_monte_carlo , |
64 [+] | use `mcout_`ns'' , |
65 [+] | qui gen datetime = "$S_DATE $S_TIME" |
66 [+] | qui save "`mcout_`ns''" , |
68 [+] | qui save t4_mcout_G_`ns' , |
70 [+] | } |
72 [+] | tempfile toappend |
73 [+] | foreach ns in `num_states_list' { |
74 [+] | clear |
75 [+] | cap erase `toappend' |
76 [+] | cap use t4_mcout_all |
77 [+] | cap drop if numstates == `ns' |
78 [+] | cap save `toappend' , |
79 [+] | use t4_mcout_G_`ns' |
80 [+] | cap append using `toappend' |
81 [+] | qui save t4_mcout_all , |
83 [+] | } |
/* processes the results, produces the output */ |
|
87 [+] | display_results , |
90 [+] | local stop = "$S_DATE $S_TIME" |
92 [+] | di "start = `start'" |
93 [+] | di "stop = `stop'" |
95 [+] | end |
97 [+] | runme |
100 [+] | log close |
#delimit ; cap log close ; log using table4.log, text replace ; set more off ; clear ; set seed 10104 ; /* load up the programs. each do file has a program that will be used */ do set_directory_macros ; set matsize 10000 ; run t4_mcloop ; run t4_display ; run t34_programs ; cap prog drop runme ; prog def runme ; /* initialize the file names, lists, etc, that will be passed into the pgrograms */ local start = "$S_DATE $S_TIME" ; local num_mc_reps = 4 ; *local mc_reps_smallG = 1000 ; *local mc_reps_bigG = 4 ; local mc_reps_smallG = 4000 ; local mc_reps_bigG = 1000 ; local num_bs_reps = 399 ; *local num_states_list = "6 " ; local num_states_list = "6 10 20 30 50" ; local mysourcedata = "$madedat/CPS_panel" ; /* prepare the state list, and ensure that all files are sorted on statefip */ tempfile statelist mcout_all ; qui use "`mysourcedata'" ; cap drop resid ; sort statefip year ; qui save "`mysourcedata'" , replace ; contract statefip ; keep statefip ; sort statefip ; qui save "`statelist'" ; /* now, do the Monte Carlo exercise*/ /* loop over number of states in the hum_states_list*/ cap erase `mcout_all' ; foreach ns in `num_states_list' { ; local num_mc_reps = `mc_reps_bigG' ; if `ns' < 11 { ; local num_mc_reps = `mc_reps_smallG' ; } ; tempfile mcout_`ns' ; di ; di "$S_DATE $S_TIME" ; do_the_monte_carlo , statelist("`statelist'") sourcedata("`mysourcedata'") savedata("`mcout_`ns''") mcreps(`num_mc_reps') bsreps(`num_bs_reps') numstates(`ns') ; use `mcout_`ns'' , replace ; qui gen datetime = "$S_DATE $S_TIME" ; /* keeps track of when this batch of data was generated */ qui save "`mcout_`ns''" , replace ; qui save t4_mcout_G_`ns' , replace ; } ; tempfile toappend ; foreach ns in `num_states_list' { ; clear ; cap erase `toappend' ; cap use t4_mcout_all ; cap drop if numstates == `ns' ; cap save `toappend' , replace ; use t4_mcout_G_`ns' ; cap append using `toappend' ; qui save t4_mcout_all , replace ; } ; /* processes the results, produces the output */ display_results , results_data(t4_mcout_all) numstates_list("`num_states_list'") ; local stop = "$S_DATE $S_TIME" ; di "start = `start'" ; di "stop = `stop'" ; end ; runme ; log close ;