Bookmark and Share

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


From   Benjamin Hong <[email protected]>
To   [email protected]
Subject   st: monte carlo simulation
Date   Sun, 24 Feb 2013 20:57:55 +0000

Dear all,

Hi, I am trying to do basic monte carlo simulation with Stata, but for
some reason it doesnt work.
Would you tell me the reason?

below is my code
-------------------
program define benreg, rclass
version 10.0
syntax [, c(real 1)]
drop _all
set obs 10000
gen u=invnorm(uniform())
gen x=invnorm(uniform())
gen y = 2 + 3*x^3+u
reg y x
sum
return scalar b0=_b[_cons]
return scalar b1=_b[x]
simulate b_0=r(b0) b_1=r(b1), reps(10000): benreg
----------------------------
it always returns "non r-class program may not set r()" after reg y x.
(before return scalar)

I appreciate if somebody gives me advise!

Thanks in advance.

Best,

Ben




******************************************
Benjamin (Wonki) Hong
Certified Financial Risk Manager
MSc Finance, Edinburgh University
Phone: +44(0)752-121-9910
E-mail: [email protected]
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index