Page 1 of 1

LM Threshold unit root tests

Posted: Fri Nov 02, 2018 1:06 pm
by ag_2018
Hi,
Would be grateful if anyone can help with the coding of the following paper:

Lee, J., Strazicich, M. C., & Yu, B. C. (2011). LM threshold unit root tests. Economics Letters, 110(2), 113-116.

It is very similar to the Enders Granger 1998 procedure, however, I am getting a bit stuck with transforming the threshold in to percentile value.

Any help would be appreciated.
many thanks!

Re: LM Threshold unit root tests

Posted: Fri Nov 02, 2018 2:24 pm
by TomDoan
set z 1 200 = %ran(1.0)
order(ranks=rr) z
set rr = rr/%nobs

will make RR the percentile of the corresponding element of Z.

Re: LM Threshold unit root tests

Posted: Sat Nov 03, 2018 5:15 am
by ag_2018
Thanks Tom! Much appreciated!

Re: LM Threshold unit root tests

Posted: Sat Nov 03, 2018 8:24 am
by ag_2018
Sorry Tom,
Just seems that I may be making a mistake somewhere. I have done the following code, but my results are completely different (actually opposite) in terms of the dynamics of the Enders and Granger (1998) method. I understand the results can be different, but the difference seems too drastic. I would appreciate if you could cast an eye on th code to see where I may be going wrong.
many thanks in advance!


* ----Reading the data file ----*
calendar 1980 1 12
allocate 2017:5
open data data_set.xlsx
data(format=xlsx,org=obs) /
table

*----Transform variables-----*
set lrw = log(rw)
diff lrw / dlrw
set y = lrw

compute start = 1980:3, last = 2017:5
smpl start last

set z = t
set dz 2 * = z - z{1}
set dy 2 * = y - y{1}

*-----Calculate st and dst----*
lin(noprint) dy ; # dz
com phi1 = y(1) - %beta(1)
set st = y - phi1 - %beta(1)*z
diff st / dst

*-----Calculate the threshold-----*

compute rss_test = 1000000.0
set thresh_test = dst
set T = %nobs
com sigma = 0.0869 ;*sigma calculated using the statistics instruction on dst
set thresh_test = (1/sigma*sqrt(%nobs))*thresh_test
order thresh_test
order(ranks=rr) thresh_test
set thresh_testp = rr/%nobs

compute low = start+fix(.15*%nobs), high = last-fix(.15*%nobs)
compute thresh = thresh_testp(low)
do i = low,high
set flag = %if(dst{1}<thresh_testp(i),0,1)
set st_plus = flag*st
set st_minus = (1-flag)*st

linreg(noprint) dy start last
#st_plus{1} st_minus{1}

if %rss<rss_test{
compute rss_test = %rss
compute thresh = thresh_testp(i)
}
end do i

dis 'The threshold is'
dis 'Threshold = ' thresh

*-------------------*
*-----MTAR Model----*
*-------------------*

set flag = %if(dst{1}<thresh,0,1)
set st_plus = flag*st
set st_minus = (1-flag)*st

lin dy / resids
#st_plus{1} st_minus{1} dst{1 to 11}

exclude
#st_plus{1} st_minus{1}

restrict 1
#1 2
#1 -1 0

cor(qstats,number=4) resids

Re: LM Threshold unit root tests

Posted: Sat Nov 03, 2018 8:10 pm
by TomDoan
I'm not sure what you intend with this, but this is completely wrong. T is a reserved name integer variable. Do not use it for anything else.

set T = %nobs


The nesting on this looks questionble. As written, that's (1/sigma)*sqrt(%nobs). If you mean to divide by the sqrt, you need change the parentheses to show that.

set thresh_test = (1/sigma*sqrt(%nobs))*thresh_test

Re: LM Threshold unit root tests

Posted: Mon Nov 05, 2018 4:47 am
by ag_2018
Dear Tom,

My apologies - but I am a bit confused. Indeed, there is no need for the T = %nobs. But not sure what you mean by the following:
set thresh_test = (1/sigma*sqrt(%nobs))*thresh_test
I do mean to divide by the square root. This is what I have in the code.
Of course, if the code is wrong, I would really appreciate any pointers to put me on the right path.
Many thanks!

Re: LM Threshold unit root tests

Posted: Mon Nov 05, 2018 6:37 am
by TomDoan
/ and * have the same precedence so without parentheses 1/sigma*sqrt(%nobs) means (1/sigma)*sqrt(%nobs). If that's not what you want, you need 1/(sigma*sqrt(%nobs)).