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, statalist.org is already up and running.

 From John Luke Gallup To statalist@hsphsun2.harvard.edu Subject Re: st: Outreg2 error "matrix __000009 not found" Date Wed, 13 Feb 2013 16:49:51 -0800

```<Redacted>,

The source of your problem is that with the first regression,

quietly regress dy0, noconstant

you have no independent variable, and with no constant, you have no coefficient estimates at all. -regress- does not complain, but -outreg2- depends on their being content in the e(b) and e(V) matrices after an estimation command.  This is a bug - instead you should get an error message saying that e(b) is missing.

You can fix this by removing the -noconstant- option from -regress- and instead use the -nocons- option in -outreg2-:

local p dy0 //get AIC BIC
forvalues d=1/7 {
quietly regress `p'
estat ic
matrix OUT = r(S) //store matrix
local AIC =  OUT[1,5] //store AIC
local BIC = OUT[1,6] //store BIC
outreg2 using temp.tex, nocons append tex(fragment) ///
local p = "`p' dy`d'"
}

John

On Feb 13, 2013, at 3:20 PM, Redacted <redacted> wrote:

> Dear Stata listers,
>
> I'm having trouble with what should actually be a relatively simple piece of code. With the loop below I was planning to store AIC and BIC values to an outreg table. The code works perfectly fine, until the "noconstant" option is added to the regression (line 3).
>
> ----------
>
> 	local p dy0 //get AIC BIC
> forvalues d=1/7 {
> 	quietly regress `p', noconstant
> 	estat ic
> 	matrix OUT = r(S) //store matrix
> 	local AIC =  OUT[1,5] //store AIC
> 	local BIC = OUT[1,6] //store BIC
> 	outreg2 using temp.tex, append tex(fragment) ///
> 	local p = "`p' dy`d'"
> }
>
> ! mv "./temp.tex" "./2ay.tex" /*rename temp.tex to 2a.tex
> 							may not work outside unix
> 							overwrites existing 2a.tex
> 							*/
> ! rm -r "./temp.txt"
>
> ----------
>
> With "[...], noconstant" specified, the code returns the error "matrix __000009 not found". The same happens when running all the lines individually. The code, however, works without issues when the noconstant option is omitted.
>
> I am not sure whether this is a bug or if I am overlooking something. I really hope someone can find what's the problem here.
>
> Thanks and cheers,
> <Redacted>
> *
> *   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/

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