Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: monte carlo simulation on panel data
From
Ghazal Zulfiqar <[email protected]>
To
[email protected]
Subject
st: monte carlo simulation on panel data
Date
Fri, 7 Feb 2014 20:24:00 -0500
Hello,
I need help with a Monte Carlo simulation on panel data with 500 observations (the panel is organized by year and country_code). I need to run a regression and then collect fitted values in 1000 runs, so that I have a new dataset of 500,000. The program I wrote only gives me 1000 observations, that is, it is giving me one statistic per run. Can someone please help?
set seed 3213799
gen random=.
gen diversity=.
tempname sim
postfile `sim' xb using results, replace
quietly {
forvalues i=1/1000 {
replace random=runiform()
replace diversity=median(conc_diversity)+random
regress stddev diversity asia latin_am europe africa_mideast log_gdp_capita log_gdp_capita_1 log_gdp_capita_2 pop_g_rate barro_ipol investment_rate t t_sqrd
predict xb
post `sim' (xb)
drop xb
}
}
postclose `sim'
summarize
Thanks,
Ghazal Zulfiqar
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/