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: matrix operators that return matrices not allowed in this context
From
Joe Case Orsini <[email protected]>
To
[email protected]
Subject
st: matrix operators that return matrices not allowed in this context
Date
Mon, 24 Jan 2011 16:31:31 -0800 (PST)
I'm trying to run a monte carlo simulation, and when i run it with one repetition, everything goes through fine. when i run it for 2 repetitions, stata returns the error message in the subject line.
the problem is with the matrix b in the code below, defined using the OLS coefficient estimates. also, if i add drop b to the end of the code, stata returns "b not found" even though it will display b during the loop. I'm sure there is an obvious fix here, but would really appreciate an explanation of what's going wrong.
forvalues i=1/`reps'{
gen eps= rnormal(0,exp(`gamma'*x1))
mkmat eps
mat y = yfit + eps
svmat y
qui reg y x1 x2
predict e, r
mat b=_b[_cons]\_b[x1]\_b[x2]
mat list b
gen e2=e^2
qui reg e2 x1 x2
scalar chi2=`T'*e(r2)
mat CHISTAT`beta'`gamma'=nullmat(CHISTAT`beta'`gamma')\chi2
drop y eps e e2
mat drop y eps
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/