table2.do open
file:script:do
# | content log |
---|---|
1 [+] | #delimit |
2 [+] | cap log close |
3 [+] | log using table2.log , |
5 [+] | clear |
6 [+] | set seed 10101 |
7 [+] | set more off |
9 [+] | /* load up the programs. each do file has a program that will be used */ |
11 [+] | do set_directory_macros |
12 [+] | set matsize 10000 |
13 [+] | run t2_mcloop |
14 [+] | run CR23_IK_CSS |
15 [+] | run t2_display |
17 [+] | cap prog drop runme |
18 [+] | prog def runme |
20 [+] | /* initialize the file names, lists, etc, that will be passed into the pgrograms */ |
22 [+] | local num_mc_reps = 100 |
23 [+] | local mc_reps_smallG = 4000 |
24 [+] | local mc_reps_bigG = 1000 |
26 [+] | local num_bs_reps = 399 |
*local num_states_list = "6 " ; |
|
28 [+] | local num_states_list = "6 10 20 30 50" |
*local mysourcedata = "$madedat/CPS_2012_micro_small" ; |
|
30 [+] | local mysourcedata = "$madedat/CPS_2012_micro_medium" |
/* ensure that the source data file is sorted on statefip */ |
|
33 [+] | tempfile statelist |
34 [+] | qui use "`mysourcedata'" |
35 [+] | cap drop resid |
36 [+] | sort statefip |
37 [+] | qui save "`mysourcedata'" , |
40 [+] | /* loop over number of states in the hum_states_list*/ |
42 [+] | foreach ns in `num_states_list' { |
/* do more MC reps for 6 and 10 states */ |
|
45 [+] | local num_mc_reps = `mc_reps_bigG' |
46 [+] | if `ns' < 11 { |
47 [+] | local num_mc_reps = `mc_reps_smallG' |
48 [+] | } |
51 [+] | tempfile mcout_`ns' |
52 [+] | di |
53 [+] | di "$S_DATE $S_TIME" |
54 [+] | do_the_monte_carlo , |
57 [+] | use `mcout_`ns'' , |
58 [+] | qui gen datetime = "$S_DATE $S_TIME" |
59 [+] | qui save "`mcout_`ns''" , |
61 [+] | qui save t2_mcout_G_`ns' , |
62 [+] | } |
/* this next loop will go through the "statelist" and swap-in the results into to_mcout_all this is to enable these results to be done in batches, in parallell. We just swap in those results in the list, leaving any results already in the file (and not in num_states_list) untouched. */ |
|
68 [+] | tempfile toappend |
69 [+] | foreach ns in `num_states_list' { |
70 [+] | clear |
71 [+] | cap erase `toappend' |
72 [+] | cap use t2_mcout_all |
73 [+] | cap drop if numstates == `ns' |
74 [+] | cap save `toappend' , |
75 [+] | use t2_mcout_G_`ns' |
76 [+] | cap append using `toappend' |
77 [+] | qui save t2_mcout_all , |
79 [+] | } |
82 [+] | display_results , |
85 [+] | end |
87 [+] | runme |
90 [+] | log close |
#delimit ; cap log close ; log using table2.log, text replace ; clear ; set seed 10101 ; set more off ; /* load up the programs. each do file has a program that will be used */ do set_directory_macros ; set matsize 10000 ; run t2_mcloop ; run CR23_IK_CSS ; run t2_display ; cap prog drop runme ; prog def runme ; /* initialize the file names, lists, etc, that will be passed into the pgrograms */ local num_mc_reps = 100 ; 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_2012_micro_small" ; local mysourcedata = "$madedat/CPS_2012_micro_medium" ; /* ensure that the source data file is sorted on statefip */ tempfile statelist ; qui use "`mysourcedata'" ; cap drop resid ; sort statefip ; qui save "`mysourcedata'" , replace ; /* now, do the Monte Carlo exercise*/ /* loop over number of states in the hum_states_list*/ foreach ns in `num_states_list' { ; /* do more MC reps for 6 and 10 states */ 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 , 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 t2_mcout_G_`ns' , replace ; } ; /* this next loop will go through the "statelist" and swap-in the results into to_mcout_all this is to enable these results to be done in batches, in parallell. We just swap in those results in the list, leaving any results already in the file (and not in num_states_list) untouched. */ tempfile toappend ; foreach ns in `num_states_list' { ; clear ; cap erase `toappend' ; cap use t2_mcout_all ; cap drop if numstates == `ns' ; cap save `toappend' , replace ; use t2_mcout_G_`ns' ; cap append using `toappend' ; qui save t2_mcout_all , replace ; } ; display_results , results_data(t2_mcout_all) numstates_list("`num_states_list'") sourcedata("`mysourcedata'"); end ; runme ; log close ;