Page 7 of 7

Re: Gregory-Hansen Cointegration Test

Posted: Wed Mar 23, 2016 1:05 am
by Mobeen ur Rehman
Dear brother,

Can you please tell me how to install the add in for gregory hansen cointegration in eviews8

Re: Gregory-Hansen Cointegration Test

Posted: Wed Mar 23, 2016 11:57 am
by trubador
This is not an add-in. Just copy-paste the code into a new program window and change only the part above the subroutine before running it.

Re: Gregory-Hansen Cointegration Test

Posted: Tue Aug 02, 2016 1:27 am
by hafizah0486
Dear Mr. Trubador, thank you very much for sharing. Your post really help me in conducting my research. I really appreciate if you could also share on how to conduct the unit root test with break proposed by Narayan and Popp (2010) and Johansen, Mosconi & Nielsen (2000) cointegration test with break. You kind help is highly appreciated :)

Re: Gregory-Hansen Cointegration Test

Posted: Tue Aug 02, 2016 1:34 am
by hafizah0486
I have found the program file for Johansen et al (2000) from Prof. Dave Giles website. However, I am not sure on how can I conduct the test. Hope you can help.
http://web.uvic.ca/~dgiles/downloads/johansen/

' COMPUTATION OF ASYMPTOTIC CRITICAL VALUES FOR THE H(c) and H(L) COINTEGRATION TESTS WHEN THERE ARE 2 or 3 STRUCTURAL BREAKS
' =============================================================

' Written by David Giles, Dept. of Economics, University of Victoria.
' Last Modified: 28 June, 2011.

' The total sample size is T. The number of sub-samples due to the structural breaks is "q". So, q=2 corresponds to one structural break, and q=3 corresponds to 2 structural breaks. If q=1 there are no structural breaks.
' The break-points occur at T1, when q=2, and at T1 and T2, when q=3.
' The break-point proportions are V1=(T1/T), when q=2; and V1 and V2=(T2/T), when q=3.
' (If q=2, the value of V2 below is not used)

' r = cointegrating rank
' p = no. of variables in system

' To cross-check the results for the H(c) test with the last column of Table 5 in Johansen et al., set q=1 (V1 and V2 can be left at their current values as they will not be used)
'===================================
' EDIT THE NEXT 3 LINES, AS APPROPRIATE:

scalar q=3
scalar V1=0.3
scalar V2=0.85
'================================
'EDIT THE NEXT 2 LINES IF P-VALUES ARE REQUIRED

scalar traceL=123.6
scalar traceC=114.7
'================================
vector(2) c2
vector(3) c3
vector(2) c4
vector(2) c5
vector(2) c6
scalar a
scalar b
' The values of "a" and "b" depend on the number (q-1) of structural breaks.
' When q=2, we set a=0 in Table 4 of Johansen et al. (2000) & b = min[ V1 , (1-V1)]
' When q=3, we set a=min[V1, (V2-V1), (1-V2)] & b = min[remaining two V expressions ]

if q=2 then
c2.fill v1, 1-v1
a=0
b=@min(c2)
endif
if q=3 then
c3.fill v1, v2-v1, 1-v2
a=@min(c3)
b=@median(c3)
endif
if q=1 then
a=0
b=0
endif
' Let pr denote (p-r)
vector(10) pr
vector(10) lmL
vector(10) lvL
vector(10) meanL
vector(10) varL
vector(10) lmC
vector(10) lvC
vector(10) meanC
vector(10) varC
vector(10) theta
vector(10) k
vector(10) crit_HL90
vector(10) crit_HL95
vector(10) crit_HL99
vector(10) crit_HC90
vector(10) crit_HC95
vector(10) crit_HC99
vector(10) pvalL
vector(10) pvalC

' lm denotes the logarithm of the mean of the asymptotic distribution
' lv denotes the logarithm of the variance of the asymptotic distribution
' See Table 4 of Johansen et al. (2000). We then add L or C to the names to reflect the H(L) test or the H(c) test.

' First construct critical values for the H(L) test, and then for the H(c) test
for !pr = 1 to 10
pr(!pr)=!pr

lmL(!pr)=3.06+0.456*!pr+1.47*a+0.993*b-0.0269*!pr^2-0.0363*a*!pr-0.0195*b*!pr-4.21*a^2-2.35*b^2+0.000840*!pr^3+6.01*a^3-1.33*a^2*b+2.04*b^3-2.05/!pr-0.304*a/!pr+1.06*b/!pr+9.35*a^2/!pr+3.82*a*b/!pr+2.12*b^2/!pr-22.8*a^3/!pr-7.15*a*b^2/!pr-4.95*b^3/!pr+0.681/!pr^2-0.828*b/!pr^2-5.43*a^2/!pr^2+13.1*a^3/!pr^2+1.5*b^3/!pr^2

lvL(!pr)= 3.97+0.314*!pr+1.79*a+0.256*b-0.00898*!pr^2-0.0688*a*!pr-4.08*a^2+4.75*a^3-0.587*b^3-2.47/!pr+1.62*a/!pr+3.13*b/!pr-4.52*a^2/!pr-1.21*a*b/!pr-5.87*b^2/!pr+4.89*b^3/!pr+0.874/!pr^2-0.865*b/!pr^2

meanL(!pr)=exp(lmL(!pr))-(3-q)*!pr
varL(!pr)=exp(lvL(!pr))-2*(3-q)*!pr

' Use the asymptotic mean and variance to obtain the shape and scale parameters of the gamma distribution to be used to approximate the asymptotic distribution of the test statistic, and hence obtain the desired quantiles under the null:

theta(!pr)=(varL(!pr)/meanL(!pr))
k(!pr)=meanL(!pr)^2/varL(!pr)
crit_HL90(!pr)=@qgamma(0.90, theta(!pr),k(!pr))
crit_HL95(!pr)=@qgamma(0.95, theta(!pr),k(!pr))
crit_HL99(!pr)=@qgamma(0.99, theta(!pr),k(!pr))

if traceL>0 then
pvalL(!pr)=1-@cgamma(traceL, theta(!pr),k(!pr))
endif

lmC(!pr)=2.80+0.501*!pr+1.43*a+0.399*b-0.0309*!pr^2-0.0600*a*!pr-5.72*a^2-1.12*a*b-1.70*b^2+0.000974*!pr^3+0.168*a^2*!pr+6.34*a^3+1.89*a*b^2+1.85*b^3-2.19/!pr-0.438*a/!pr+1.79*b/!pr+6.03*a^2/!pr+3.08*a*b/!pr-1.97*b^2/!pr-8.08*a^3/!pr-5.79*a*b^2/!pr+0.717/!pr^2-1.29*b/!pr^2-1.52*a^2/!pr^2+2.87*b^2/!pr^2-2.03*b^3/!pr^2

lvC(!pr)= 3.78+0.346*!pr+0.859*a-0.0106*!pr^2-0.0339*a*!pr-2.35*a^2+3.95*a^3-0.282*b^3-2.73/!pr+0.874*a/!pr+2.36*b/!pr-2.88*a^2/!pr-4.44*b^2/!pr+4.31*b^3/!pr+1.02/!pr^2-0.807*b/!pr^2

meanC(!pr)=exp(lmC(!pr))-(3-q)*!pr
varC(!pr)=exp(lvC(!pr))-2*(3-q)*!pr

' use the asymptotic mean and variance to obtain the shape and scale parameters of the gamma distribution to be used to approximate the asymptotic distribution of the test statistic, and hence obtain the desired quantiles under the null:

theta(!pr)=varC(!pr)/meanC(!pr)
k(!pr)=meanC(!pr)^2/varC(!pr)
crit_HC90(!pr)=@qgamma(0.90, theta(!pr),k(!pr))
crit_HC95(!pr)=@qgamma(0.95, theta(!pr),k(!pr))
crit_HC99(!pr)=@qgamma(0.99, theta(!pr),k(!pr))


if traceC>0 then
pvalC(!pr)=1-@cgamma(traceC, theta(!pr),k(!pr))
endif
next

smpl 1 10
mtos(pr,p_minus_r)
mtos(crit_HL90, crit_HL_90)
mtos(crit_HL95, crit_HL_95)
mtos(crit_HL99, crit_HL_99)
mtos(crit_HC90, crit_HC_90)
mtos(crit_HC95, crit_HC_95)
mtos(crit_HC99, crit_HC_99)
group crit_vals p_minus_r crit_HL_90 crit_HL_95 crit_HL_99 crit_HC_90 crit_HC_95 crit_HC_99

show crit_vals

if traceL>0 then
mtos(pvalL,p_val_HL)
group pval_HL p_minus_r p_val_HL
show pval_HL
endif

if traceC>0 then
mtos(pvalC,p_val_HC)
group pval_HC p_minus_r p_val_HC
show pval_HC
endif

Re: Gregory-Hansen Cointegration Test

Posted: Wed Aug 03, 2016 9:08 pm
by baah
Please, I am new in using EVIEWS 9. I wish to perform the Gregory-Hansen ; and Hatemi -J cointegration test . I have copied the codes stated above into the proceedure shown( File/New/Program). I have also edited to suit my variables. Now, what do i do next to run the following 1. Gregory Hansen cointegration test and 2. Hatemi-J cointegration test.
Thank you.

Re: Gregory-Hansen Cointegration Test

Posted: Thu Aug 04, 2016 4:58 pm
by Kahn
Dear Trubador,

Assuming we do find evidence of cointegration, how would we proceed with our analysis if we had to estimate a VECM? How would the structural break or regime change be modelled in EViews? Would it suffice to simply split the sample into two sub-periods and estimate two models?

I appreciate any guidance,

Kahn.

Re: Gregory-Hansen Cointegration Test

Posted: Sun Aug 21, 2016 11:37 am
by Kahn
Would it be valid to use the GH test for multiple series at once?

Re: Gregory-Hansen Cointegration Test

Posted: Sat Jan 28, 2017 12:49 pm
by albertozzio
Dear trubador,
I know NOTHING about subroutines on Eviews but i need to learn them for my master thesis. I am a student of Economics but unfortunately we didn't learn on time how to work on Eviews.
Basically, you wrote a subroutine for this G-H test, that I need to apply to my time-series variables. How can I do that? I mean, I should just substitute my variables putting them in your subroutine and then press "run". How to do that?

Thanks a lot, you can save me!
Alberto

Re: Gregory-Hansen Cointegration Test

Posted: Sat Jan 28, 2017 6:55 pm
by EViews Gareth
Probably the best thing to do is to learn about subroutines.

http://www.eviews.com/help/helpintro.ht ... ng.html%23

Re: Gregory-Hansen Cointegration Test

Posted: Tue Apr 11, 2017 3:15 pm
by maragloria
Hello Trubador,

Thanks very much for your code.

I'm using EViews 9 and I got the following error message:
"Near singular matrix error. Regressors may be perfectly collinear in "DO_ GHC.LS Y C (@TREND>9-2) G"
I've tested for different values of scalar Model (2 to 4); the same error message appears.

Please find attached my data and the program.

Many thanks!
breakpts.WF1
(18.6 KiB) Downloaded 79 times

coint_greghansen.prg
(4.95 KiB) Downloaded 98 times

Re: Gregory-Hansen Cointegration Test

Posted: Tue Apr 11, 2017 3:33 pm
by maragloria
Hello Trubador,

I found this post; Thinking my problem was related, I run you suggestion but I still get the same error message.

Thanks again.

Capture.PNG
Capture.PNG (30.75 KiB) Viewed 2819 times

Re: Gregory-Hansen Cointegration Test

Posted: Tue Apr 11, 2017 3:34 pm
by startz
(@TREND>9-2) is constant in your sample period.

Re: Gregory-Hansen Cointegration Test

Posted: Wed Apr 12, 2017 10:00 am
by maragloria
Hello startz,

Thanks for your prompt reply.

Sorry, I can't grasp the implications of your answer. What should I do to fix the problem?

Best regards, Mara

Re: Gregory-Hansen Cointegration Test

Posted: Wed Apr 12, 2017 10:43 am
by startz
Perhaps just delete that variable.

Re: Gregory-Hansen Cointegration Test

Posted: Thu Mar 08, 2018 1:20 am
by salwan
Hi,

I would like to know, how to apply Gregory - Hansen Cointegration Test using Eviews 10?
Taking into account that I have Y as the dependent variable and X1, X2 and X3 as the independent variables

Best wishes,
Salwan