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]

Re: st: matrix operators that return matrices not allowed in this context


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: matrix operators that return matrices not allowed in this context
Date   Tue, 25 Jan 2011 10:09:00 +0000

It takes a lot of work to try to reconstruct exactly what you are
doing, as this code depends on previous calculations and assignments
and needs a closing brace.

I can't reproduce your main error. Perhaps it is a side-effect of
particular values of your local macros.

Incidentally, the choreography of -mkmat- and -svmat- to add what look
like variables looks unnecessarily complicated. You can just add
variables

Nick

On Tue, Jan 25, 2011 at 12:31 AM, Joe Case Orsini <[email protected]> wrote:

> 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/


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