Statalist


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

Re: st: Problem with foreach in Stata 10.1


From   "Joao Ricardo F. Lima" <jricardofl@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Problem with foreach in Stata 10.1
Date   Mon, 17 Nov 2008 20:45:06 -0300

Dear Brian,

thanks for the explanation!

Best Regards,

Joao Lima

2008/11/17 Brian P. Poi <bpoi@stata.com>:
> 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
>  -- bpoi@stata.com
> *
> *   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/
>



-- 
-------------------------------
Joao Ricardo Lima
Professor
UFPB-CCA-DCFS
+553138923914
-------------------------------
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index