Last active
January 13, 2020 18:12
-
-
Save bbdaniels/bee9a0eed86d9043d2ad0447c152ca4a to your computer and use it in GitHub Desktop.
Simulation: Big and small effects from RCTs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simulation 1: Big effects from small RCTs | |
cap mat drop results | |
qui forv iter = 1/1000 { | |
clear | |
set obs 10000 | |
gen x = rnormal() > 0 | |
gen e = rnormal() * 4 | |
gen y = 5 + 0*x + e | |
reg y x | |
mat temp = r(table) | |
mat result = temp[....,1] | |
mat result = result' | |
mat results = nullmat(results) /// | |
\ result | |
} | |
clear | |
svmat results , n(col) | |
// End of dofile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simulation 2: Small effects from measurement errors | |
cap mat drop results | |
qui forv iter = 1/1000 { | |
clear | |
set obs 10000 | |
gen x = runiform() * 100 | |
gen me = rnormal() * 50 | |
gen temp = x + me | |
gen x_obs = max(temp,0) | |
gen e = rnormal() * 4 | |
gen y = 5 + 20*x + e | |
reg y x | |
mat temp = r(table) | |
mat result = temp[....,1] | |
mat result = result' | |
mat results = nullmat(results) /// | |
\ result | |
} | |
clear | |
svmat results , n(col) | |
// End of dofile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment