Statalist


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

Re: st: Problem with foreach in Stata 10.1


From   "Brian P. Poi" <[email protected]>
To   [email protected]
Subject   Re: st: Problem with foreach in Stata 10.1
Date   Mon, 17 Nov 2008 16:37:49 -0600 (CST)

On Mon, 17 Nov 2008, Joao Ricardo F. Lima wrote:

Dear Statalister,

I`m with one problem using foreach with Stata 10.1. I was teaching
unit root test, I was demonstrating how to use the foreach command
too. The, the surprise:

***begin example****
webuse air2
forvalues i=1/3 {
	dfuller air, lags(`i')
	estat ic
}
***end example****

This works fine with Stata 9.2, but don't with 10.1. ...

-dfuller- is an r-class command, but prior to Stata 10 it had been leaving behind regression results in the e-class macros. In general, r-class commands should not affect any estimation results the user has lying around, so in Stata 10 we modified -dfuller- to back up and restore the user's prior estimation results.

In Joao Ricardo's example using Stata 10.1, his -estat ic- results are always showing the results for the first call to -dfuller-; presumably he did not do any estimation before calling -dfuller-, since in that case -dfuller- did not see any estimation results that it needed to back up and restore. In fact, -dfuller- should not be saving e-class results in that case, either; we will address that in an ado-file update.

Using -estat ic- in conjunction with -dfuller- to choose the optimal number of lags to include might at first blush seem like a good idea. However, looking at his results using Stata 9 reveal a problem: the sample size used in each case depends on the number of lags specified with -dfuller-. When using an information criterion to select the lag order, you should restrict the estimation sample to the subset of observations that can be used with the maximum number of lags you wish to consider.

  -- Brian Poi
  -- [email protected]
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index