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
Linear regression using a time variableHi all, I'm having some difficulties in doing a linear regression for my research. My dataset consi…
IV using panel data and fixed effectsHi, I am using panel data about women's wellbeing and influencing factors, therefore, I have been u…
Estimating asymmetrical confidence intervals for ICC using -nlcom-Dear all Out of curiosity I want to reproduce the calculations from: Code: cls use https://www.stat…
Forecasting a variableHi, I am using a panel dataset and for one of my variables I only have data 2014 to 2017. For my da…
Computing the consistency ratio and consistency index for analytic hierarchy process with matahey everyone, i'm completely new to stata and mata as well. im trying to figure out if there is a p…
Subscribe to:
Post Comments (Atom)
0 Response to Monte Carlo Simulation
Post a Comment