Hi all,
I want to be able to run a Monte Carlo simulation for an econometrics assignment that I have. From what I can tell, I need to design an experiment that has sample sizes of n{10, 100, 1000, 10000]}, each requiring R=1000, where R= replications. For each of the sample sizes, I need to calculate the 25th, 50th, and 75th percentile values. I have some code from stata for this experiment and it listed below. The question I have is how can I create a loop within this program to allow for changing the n number of observations?
clear
local mc = 1000
set seed 368
set obs `mc'
gen data_store_x = .
gen data_store_cons = .
quietly {
forvalues i = 1(1) `mc' {
if floor((`i'-1)/100) == (`i' -1)/100 {
noisily display "Working on `i' out of `mc at $S_TIME'"
}
preserve
clear
set obs = 1000
gen x = rnormal() *3 + 6
gen e = runiform() - 0.5
gen y = 3 + 4*x + e
reg y x, robust
local xcoef = _b[x]
local const = _b[_cons]
restore
replace data_store_x = `xcoef' in `i'
replace data_store_cons = `const' in `i'
}
}
summ data_store_x data_store_cons
Related Posts with Monte Carlo Simulation
How to retrieve all the coefficient of independent variables of did_imputation package?Hi all, Normally, in a research paper, we need to present a table of coefficients of all independen…
How many pre-treatment periods we should test for paralell trend in the case of daily data?In a difference-in-differences setting, if we deal with yearly data, we normally test the parallel t…
Getting a different result w. do-file and copy-pastHello everyone, I am getting a different result when I run my do-file and when I copy-past my code …
How to perform the pre-trend test in did_imputation?From reading the help file of did_imputation, I saw that pretrends(integer): if some value k>…
Merging two datasetsHi all, Im new to STATA so I apologise if this is a silly question. I am trying to combine two data…
Subscribe to:
Post Comments (Atom)
0 Response to Monte Carlo Simulation
Post a Comment