Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: monte carlo simulation

From   Benjamin Hong <>
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
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.



Benjamin (Wonki) Hong
Certified Financial Risk Manager
MSc Finance, Edinburgh University
Phone: +44(0)752-121-9910
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index