Statalist


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

st: Problem with foreach in Stata 10.1


From   "Joao Ricardo F. Lima" <[email protected]>
To   [email protected]
Subject   st: Problem with foreach in Stata 10.1
Date   Mon, 17 Nov 2008 14:34:01 -0300

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. With Stata 9.2:

. webuse air2
(TIMESLAB: Airline passengers)

. forvalues i=1/3 {
  2.         dfuller air, lags(`i')
  3.         estat ic
  4. }

Augmented Dickey-Fuller test for unit root         Number of obs   =       142

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -2.345            -3.496            -2.887            -2.577
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.1579

------------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+----------------------------------------------------------------
           . |    142   -701.1962   -691.5394      3     1389.079    1397.946
------------------------------------------------------------------------------

Augmented Dickey-Fuller test for unit root         Number of obs   =       141

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -1.811            -3.496            -2.887            -2.577
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.3751

------------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+----------------------------------------------------------------
           . |    141   -696.6955   -684.4298      4      1376.86    1388.655
------------------------------------------------------------------------------

Augmented Dickey-Fuller test for unit root         Number of obs   =       140

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -1.536            -3.497            -2.887            -2.577
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.5158

------------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+----------------------------------------------------------------
           . |    140   -692.2411   -678.5628      5     1367.126    1381.834
------------------------------------------------------------------------------

.
end of do-file

.

With Stata 10.1:

. webuse air2
(TIMESLAB: Airline passengers)

. forvalues i=1/3 {
  2.         dfuller air, lags(`i')
  3.         estat ic
  4. }

Augmented Dickey-Fuller test for unit root         Number of obs   =       142

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -2.345            -3.496            -2.887            -2.577
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.1579

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |    142   -701.1962   -691.5394      3     1389.079    1397.946
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

Augmented Dickey-Fuller test for unit root         Number of obs   =       141

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -1.811            -3.496            -2.887            -2.577
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.3751

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |    142   -701.1962   -691.5394      3     1389.079    1397.946
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

Augmented Dickey-Fuller test for unit root         Number of obs   =       140

                               ---------- Interpolated Dickey-Fuller ---------
                  Test         1% Critical       5% Critical      10% Critical
               Statistic           Value             Value             Value
------------------------------------------------------------------------------
 Z(t)             -1.536            -3.497            -2.887            -2.577
------------------------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.5158

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |    142   -701.1962   -691.5394      3     1389.079    1397.946
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

.
end of do-file


How you can see, the estat ic is repeated in each looping...

Can someone reproduce my problem and explain what am I doing wrong?

Thanks a lot

-- 
-------------------------------
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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index