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 create control group against fraud firms?Dear all, I want to create a control sample of non-fraud firms against firms that committed fraud. I…
Estimate GARCH-DCC with asymmetriesHas anyone had experience estimating GARCH-DCC models with asymmetries (GJR for example)? Can this b…
ElasticitiesHello, I would like to estimate the exports elasticity and the imports elasticity of some countries…
Multiple time-failure analysis, event-specific coeffcients?Dear all, I am using stcox along with a stratification variable to estimate the hazard functions fo…
bysort queryHello, I am trying to use bys to generate sequential and total number of Lines of treatments by pati…
Subscribe to:
Post Comments (Atom)
0 Response to Monte Carlo Simulation
Post a Comment