--- Rachel <[email protected]> wrote:
> I am using simulate to run a series of regressions and return the
> coefficients and standard errors. What's the easiest way to have
> Stata save the values of the independent and the residuals for each
> observation after each repetition?
I am assuming you do not want to save the dataset but some coeficients.
(If you want to save the dataset aswell it is better to just create one
big dataset in one go and not loop over various randomly generated
smaller datasets, which is essentially what -simulate- does.)
what about this:
*------------------ begin example -----------------
capture program drop simprog
program simprog, eclass
drop _all
set obs 1000
gen x=uniform()
drawnorm resid
local beta=2
gen y=`beta'*x+resid
regress y x
matrix b = e(b)
matrix V = e(V)
local rmse = e(rmse)
ereturn post b V
ereturn scalar rmse = `rmse'
end
simulate _b _se rmse=e(rmse), reps(20): simprog
*------------------ end example -------------------
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
___________________________________________________________
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/