With the help from Trubador, I have written the following sets of codes for Gregory and Hansen (1996) cointegration test. Unfortunately, both codes seem to be correct but I am not sure why the results is vary between the programme used. In term of result, I think the second set of code should be correct, while the first set of code will produce more easy and presentable result. Therefore, I attempt to request the Eviews programming expert to improve the first codes. Of course, I would also appreciate that if the Eviews programming expert willing to write a more shorter and presentable code for the Gregory-Hansen test.

The Gregory-Hansen programming code were reported as below:

First set of GH code:

Code: Select all

`!trim = 0.15 'Trimming parameter`

!t_min = 1000

!min_aic = 1000

vector(1) breaks

for !i = @round(@obs(sy)*!trim) to @round(@obs(sy)*(1-!trim))

smpl @all

equation temp.ls SY c IY (@trend>!i)

temp.makeresid EEC

genr ZZ = EEC

genr DZZ = D(EEC)

for !lag = 0 to 4

if !lag = 0 then

equation temp.ls DZZ ZZ(-1)

else

equation temp.ls DZZ ZZ(-1) DZZ(-1 TO -!lag)

endif

if temp.@aic < !min_aic then

!best_lag = !lag

!min_aic = temp.@aic

if temp.@tstats(1) < !t_min then

!t_min = temp.@tstats(1)

breaks(1) = !i+2 'Identified first break point.

series DU1 = @trend> !i

series DT1 = DU1*(@trend-!i)

if !best_lag = 0 then

equation GH.ls DZZ ZZ(-1)

else

equation GH.ls DZZ ZZ(-1) DZZ(-1 TO -!best_lag) 'Selected equation

endif

endif

endif

next

next

delete temp

Second set of code:

Code: Select all

`!trim = 0.15 'Trimming parameter`

for !i = @round(@obs(sy)*!trim) to @round(@obs(sy)*(1-!trim))

matrix(!i,2) GHtest1

vector(1) breaks

smpl @all

equation ghc1.ls sy c iy (@trend>!i)

ghc1.makeresid EEC

genr ZZ = EEC

genr DZZ = D(EEC)

uroot(adf, none, info=aic, maxlag=4, save=level!i) ZZ

GHtest1(!i,1) = level!i(3,1)

GHtest1(!i,2) = level!i(2,1)

next

vector minaic = @cmin(GHtest1)

vector eqn_minaic = @cimin(GHtest1)

Thank you in advance,

Warmest regards,

tcfoon