Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: xtreg y,re -last test not found-


From   vwiggins@stata.com (Vince Wiggins, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: xtreg y,re -last test not found-
Date   Thu, 07 Oct 2004 09:55:00 -0500

Garry Anderson <g.anderson@unimelb.edu.au> finds that Stata refuses to
estimate a random-effects regression when there are no regressors -- a
constant-only model,

> I am trying to estimate a constant only model with
> -xtreg y ,i(varname) re
>
> The returned error message is
> "last test not found"
> r(302);
> [...]

Kit Baum <baum@bc.edu> finds an example that does work,

> [...]
> webuse grunfeld
> xtreg invest, re
>
> works fine. [...]

They are both right, and -xtreg- SOMETIMES has a problem with constant-only
models.  The difference between Garry's and Kit's data is that Kit's panels
are balanced and Garry's are not.  By happy accident, the balanced panels
cause -xtreg- to skip a step in its computations that it should ALWAYS skip
with constant-only models, said step being an attempt to perform a Wald test
of the regressors, which is bound to fail when there are no regressors.

The good news is that -xtreg- has been fixed to ALWAYS bypass this Wald test
when there are no regressors and that fix will be included in the next ado
update.  The bad news is that if Garry absolutely must get some estimates for
his constant-only model, my suggested work around is both convoluted and
dangerous.

The only workaround I can come up with is to disable the -test- command while
running the -xtreg- command.  Garry can do this by putting a fake test.ado in
the local directory where he is working, then placing that directory at the
front of the ado path.  Here is a fake -test.ado-

---------------------------------- BEGIN --- test.ado --- CUT HERE -------
program define test
	exit
end
----------------------------------   END --- test.ado --- CUT HERE -------

After putting this in his working directory, Garry can type in Stata,

    . adopath ++ .

to place his working directory at the front of the search path for ados.

This leads to more good news and bad news.  The good is that -xtreg- will now
happily estimate Garry's constant-only model.  The bad is that if Garry
estimates an -xtreg- model with regressors he will NOT get the standard model
Wald test.  The worse news is that while Garry stays in this working directory
ANY official or unofficial ado files that rely on -test- will be broken in one
way or another.  Put another way, my work-around breaks at least 2 sacred
rules of Stata programming:

        1) never create an ado-file with the same name as an official Stata
           command

	2) never put any adopath ahead of the official ado paths (thus letting
	   other ado-files potentially occult official commands.

So, if Gary wants to use my workaround, I suggest he create a subdirectory
containing only the fake test.ado and a do file to reset his adopath then run
his constant-only regression.  Start Stata in that subdirectory and run his
do-file then exit Stata and go elsewhere to do the rest of his work.  Better
yet, just wait for the ado update.


-- Vince 
   vwiggins@stata.com

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index