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
Wildcards with noccurHi there, Can I use wildcards with the egen function noccur? If not, is there another way to use wi…
How can I extract a portion of a string variable using regular expressions?Hi everyone! Thanks in advance for your time and help. I have the following problem....Some of the …
Using svyset for melogitHello, I am analyzing a binary outcome (depvar) using melogit so that I may 1) account for the comp…
Reporting R-squared values in System GMM estimationHi everyone, This is a query on how to report the R-squared (or Adjusted R-squared) value in a syst…
Regression and Outreg2 variable label displayHello I am running a normal regression and i labeled my variables and their values (they are all cat…
Subscribe to:
Post Comments (Atom)
0 Response to Monte Carlo Simulation
Post a Comment