Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Package -ghansen- now available in SSC


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Package -ghansen- now available in SSC
Date   Fri, 2 Sep 2011 15:02:58 +0100

I don't know what "not working" means precisely. I have an unpublished
document which details 20 different senses of such vague expressions!

Testing on 11 is clearly not a certification that the code works on 9.2.

I did say that I wasn't certifying the program free of other problems.
However, I fixed the program for the specific bug in question and
found that Jorge's example commands seem to work fine on 10.1.

I don't know what Muhammad did differently. You do need to flush the
old Mata code out of the way.

. version
version 10.1

.  webuse balance2 ,clear
(macro data for VECM/balance study)

.  ghansen y i c, break(level) lagmethod(aic) maxlags(5)

Gregory-Hansen Test for Cointegration with Regime Shifts
Model: Change in Level                             Number of obs   =        96
Lags  =  1  chosen by Akaike criterion             Maximum Lags    =         5

              Test       Breakpoint   Date        Asymptotic Critical Values
            Statistic                            1%           5%          10%
------------------------------------------------------------------------------
   ADF       -3.62          80       1978q4     -5.44       -4.92       -4.69
   Zt        -3.89          82       1979q2     -5.44       -4.92       -4.69
   Za       -23.90          82       1979q2    -57.01      -46.98      -42.49
------------------------------------------------------------------------------

.  ghansen y i c, break(regime) lagmethod(fixed) maxlags(5)

Gregory-Hansen Test for Cointegration with Regime Shifts
Model: Change in Regime                            Number of obs   =        96
Lags  =  5  chosen by user                         Maximum Lags    =         5

              Test       Breakpoint   Date        Asymptotic Critical Values
            Statistic                            1%           5%          10%
------------------------------------------------------------------------------
   ADF       -4.03          59       1973q3     -5.97       -5.50       -5.23
   Zt        -4.75          62       1974q2     -5.97       -5.50       -5.23
   Za       -25.29          62       1974q2    -68.21      -58.33      -52.85
------------------------------------------------------------------------------

.  ghansen y i c, break(regimetrend) lagmethod(downt) level(0.99) trim(0.1)

Gregory-Hansen Test for Cointegration with Regime Shifts
Model: Change in Regime and Trend                  Number of obs   =        96
Lags  =  2  chosen by downward t-statistics        Maximum Lags    =         3

              Test       Breakpoint   Date        Asymptotic Critical Values
            Statistic                            1%           5%          10%
------------------------------------------------------------------------------
   ADF       -4.78          64       1974q4     -6.45       -5.96       -5.72
   Zt        -4.52          63       1974q3     -6.45       -5.96       -5.72
   Za       -30.30          63       1974q3    -79.65      -68.43      -63.10
------------------------------------------------------------------------------

.  ghansen y i c, break(level) lagmethod(aic) maxlags(5)

Gregory-Hansen Test for Cointegration with Regime Shifts
Model: Change in Level                             Number of obs   =        96
Lags  =  1  chosen by Akaike criterion             Maximum Lags    =         5

              Test       Breakpoint   Date        Asymptotic Critical Values
            Statistic                            1%           5%          10%
------------------------------------------------------------------------------
   ADF       -3.62          80       1978q4     -5.44       -4.92       -4.69
   Zt        -3.89          82       1979q2     -5.44       -4.92       -4.69
   Za       -23.90          82       1979q2    -57.01      -46.98      -42.49
------------------------------------------------------------------------------


2011/9/2 Jorge Eduardo Pérez Pérez <[email protected]>:
> Thank you Nick and Muhammad for helping me to identify this bug in the
> code. I developed the command in Stata 12, and tested it on both 11
> and 12, but I was not aware on this change in the behavior of st_data
> across versions.
>
> According to Muhammad, the fix suggested by Nick is not working.
> Unfortunately, I don't have access to a machine with Stata 10 or 9
> right now, so I can not confirm this right away. Once I get my hands
> on a machine with Stata 10 or 9, I will confirm whether the update
> works and publish an update.
>
> Users of versions 11 and 12 should be fine,
>
> Regards,
> _______________________
> Jorge Eduardo Pérez Pérez
>
>
>
>
> On Fri, Sep 2, 2011 at 9:16 AM, Muhammad Anees <[email protected]> wrote:
>> Yes Nick, he has confirmed by estimating my data over Stata 11 and 12.
>>
>> Is there a way to change the basics of ghansen.ado and allow it
>> working on Stata 10.1 if it is permissible, which I think would be
>> fine if referred. I have tried changing the line in the ado as you
>> suggested earlier, but that still gave the same problem.
>>
>> On Fri, Sep 2, 2011 at 5:32 PM, Nick Cox <[email protected]> wrote:
>>> My guess is that Jorge developed the program under Stata 11 or higher.
>>>
>>> Nick
>>>
>>> On Fri, Sep 2, 2011 at 12:56 PM, Muhammad Anees <[email protected]> wrote:
>>>> I am currently using Stata 10.1. Sorry for my late response to mention
>>>> the version.
>>>>
>>>> On Fri, Sep 2, 2011 at 3:57 PM, Muhammad Anees <[email protected]> wrote:
>>>>> Yes, Nick you identified the right point. Also I have further
>>>>> discussed it with the author in personal email to show that the same
>>>>> command works when used only one right hand side variable which
>>>>> confirms the point raised by Nick.
>>>>>
>>>>> Anees
>>>>>
>>>>> On Fri, Sep 2, 2011 at 12:39 PM, Nick Cox <[email protected]> wrote:
>>>>>> My guess is that there is no problem with Muhammad's data.
>>>>>>
>>>>>> There is a small problem with the code. Jorge is declaring -version
>>>>>> 9.2- for his Stata program, but probably developed his code under a
>>>>>> later version and did not actually test his code under version 9.2.
>>>>>> This is slightly risky as far as your users are concerned if they are
>>>>>> using an earlier version than you are. Recall that -version- is not a
>>>>>> time machine! (What it is and is not is discussed at greater length in
>>>>>> <http://www.stata.com/support/faqs/lang/version2.html>.)
>>>>>>
>>>>>> Also, Muhammad is not using the latest version of Stata; otherwise
>>>>>> this code should have worked. Recall that on Statalist you are
>>>>>> requested to make clear if you are not using the latest version.
>>>>>>
>>>>>> This line of Mata is biting
>>>>>>
>>>>>> x=st_data(.,X,touse)
>>>>>>
>>>>>> Jorge should for compatibility change this to
>>>>>>
>>>>>> x=st_data(., tokens(X), touse)
>>>>>>
>>>>>> In fact the problem is made clear by the error message.
>>>>>>
>>>>>> variable y z e t not found
>>>>>>
>>>>>> The version of -st_data()- on Muhammad's Stata thinks that he thinks
>>>>>> "y z e t" is a single variable name, because it doesn't parse on
>>>>>> spaces to make this a list of four variable names. It is of course not
>>>>>> a single variable name.
>>>>>>
>>>>>> In recent Statas, -st_data()- is more indulgent and will parse on
>>>>>> spaces for you.
>>>>>>
>>>>>> I didn't realise, or had forgotten, that -st_data()- had changed since
>>>>>> first introduced in Stata 9 until a thread started last month in
>>>>>>
>>>>>> http://www.stata.com/statalist/archive/2011-08/msg00403.html
>>>>>>
>>>>>> in which this difference was exposed as a cause of (my) misunderstanding.
>>>>>>
>>>>>> Any way, it is an easy fix, although I am not certifying that there
>>>>>> may not be other small problems of this type.
>>>>>>
>>>>>> Nick
>>>>>>
>>>>>> 2011/9/2 Jorge Eduardo Pérez Pérez <[email protected]>:
>>>>>>> Dear Anees
>>>>>>>
>>>>>>> Could you send me your database, or could you replicate your problem
>>>>>>> using a Stata example dataset? I want to look at the problem more
>>>>>>> closely.
>>>>>>>
>>>>>>> If you want to send me your database, please do so directly to my
>>>>>>> email address, because attachments are forbidden in Statalist.
>>>>>>>
>>>>>>> _______________________
>>>>>>> Jorge Eduardo Pérez Pérez
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Sep 2, 2011 at 12:34 AM, Muhammad Anees <[email protected]> wrote:
>>>>>>>> Thanks for your nice work, Baum and Pérez, facilitating to estimate
>>>>>>>> the Gregory and Hansen (1996) cointegration, which is most desirable
>>>>>>>> in a few cases.
>>>>>>>>
>>>>>>>> I have came up with a small query using the -ghensen- routine just
>>>>>>>> after installing it. I think it is related to mata type but I am
>>>>>>>> unable to sort out the issue.
>>>>>>>>
>>>>>>>> I have the following time series data, which is already -tsset-ed
>>>>>>>>
>>>>>>>> . des  c y z e t
>>>>>>>>
>>>>>>>>              storage  display     value
>>>>>>>> variable name   type   format      label      variable label
>>>>>>>> ------------------------------------------------------------------------------------------------------------------------------
>>>>>>>> c               float  %9.0g
>>>>>>>> y               float  %9.0g
>>>>>>>> z               float  %9.0g
>>>>>>>> e               float  %9.0g
>>>>>>>> t               float  %9.0g
>>>>>>>>
>>>>>>>> and the application of -gehansen results in below
>>>>>>>>
>>>>>>>> ghansen  c y z e t, break(level) lagmethod(aic) maxlags(5)
>>>>>>>> variable y z e t not found
>>>>>>>>               st_data():  3500  invalid Stata variable name
>>>>>>>>                  main():     -  function returned error
>>>>>>>>                 <istmt>:     -  function returned error
>>>>>>>>
>>>>>>>> I would be thankful for helping me in my case.
>>>>>>>>
>>>>>>>>
>>>>>>>> Anees
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2011/9/2 Jorge Eduardo Pérez Pérez <[email protected]>:
>>>>>>>>> Thanks to Christopher Baum, package -ghansen- has been uploaded to SSC.
>>>>>>>>>
>>>>>>>>> To install, write -ssc install ghansen-
>>>>>>>>>
>>>>>>>>> ghansen: Stata module to perform Gregory-Hansen test for cointegration
>>>>>>>>> with regime shifts.
>>>>>>>>>
>>>>>>>>> -ghansen- performs the Gregory-Hansen test for cointegration with
>>>>>>>>> regime shifts (structural breaks) proposed in Gregory and Hansen
>>>>>>>>> (1996). The test's null hypothesis is no cointegration against the
>>>>>>>>> alternative of cointegration with a single shift at an unknown point
>>>>>>>>> in time.
>>>>>>>>> ghansen makes use of Mata and requires Stata 9.2.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index