Code: Select all

`'HEGY test for unit roots and seasonal unit roots of MONTHLY series`

call hegy(name of your series)

subroutine hegy(series y)

'generate auxiliary polynomials

series Z1 = y + y(-1) + y(-2) + y(-3) + y(-4) + y(-5) + y(-6) + y(-7) + y(-8) + y(-9) + y(-10) + y(-11)

series Z2 = - y + y(-1) - y(-2) + y(-3) - y(-4) + y(-5) - y(-6) + y(-7) - y(-8) + y(-9) - y(-10) + y(-11)

series Z3 = - y + y(-2) - y(-4) + y(-6) - y(-8) + y(-10)

series Z4 = - y + @sqrt(3)*y(-1) - 2*y(-2) + @sqrt(3)*y(-3) - y(-4) + y(-6) - @sqrt(3)*y(-7) + 2*y(-8) - @sqrt(3)*y(-9) + y(-10)

series Z5 = - y - @sqrt(3)*y(-1) - 2*y(-2) - @sqrt(3)*y(-3) - y(-4) + y(-6) + @sqrt(3)*y(-7) + 2*y(-8) + @sqrt(3)*y(-9) + y(-10)

series Z6 = - y + y(-1) - y(-3) + y(-4) - y(-6) + y(-7) - y(-9) + y(-10)

series Z7 = - y - y(-1) + y(-3) + y(-4) - y(-6) - y(-7) + y(-9) + y(-10)

series Z8 = y - y(-12)

'create seasonal dummies

for !i=1 to 11

series s!i = @seas(!i) - @seas(12)

next

'estimate the equation

equation eq1.ls(showopts,c=1e-5,m=1000) Z8 c s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 Z1(-1) Z2(-1) Z3(-1) Z3(-2) Z4(-1) Z4(-2) Z5(-1) Z5(-2) Z6(-1) Z6(-2) Z7(-1) Z7(-2) Z8(-1 to -12)

show eq1.output

'generate the test statistics that are not given in the equation output (Warning: critical values are different from those of EViews'. You should find true values for accurate hypothesis testing!)

freeze eq1.wald c(15)=0, c(16)=0

freeze eq1.wald c(17)=0, c(18)=0

freeze eq1.wald c(19)=0, c(20)=0

freeze eq1.wald c(21)=0, c(22)=0

freeze eq1.wald c(23)=0, c(24)=0

freeze eq1.wald c(14)=0, c(15)=0, c(16)=0, c(17)=0, c(18)=0, c(19)=0, c(20)=0, c(21)=0, c(22)=0, c(23)=0, c(24)=0

freeze eq1.wald c(13)=0, c(14)=0, c(15)=0, c(16)=0, c(17)=0, c(18)=0, c(19)=0, c(20)=0, c(21)=0, c(22)=0, c(23)=0, c(24)=0

'delete auxiliary series and seasonal dummies

delete z* s*

endsub