TsayNLTest—Tsay's test for non-linearities in an autoreg

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

TsayNLTest—Tsay's test for non-linearities in an autoreg

Unread post by TomDoan »

This does the Tsay(1996) test for neglected non-linearities in an autoregression. Optionally, it will do the related test by Luukkonen, Saikkonen and Terasvirta(1988).

Code: Select all

*
* @TsayNLTest(options) x start end
*
* TsayNLTest does the Tsay Ori-F test for neglected non-linearities in an
* autoregression. Optionally, it can do the LST variant (which tests more
* specifically against STAR).
*
* Parameters:
*  x           Series to test
*  start end   Range over which to estimate autoregression.
*
* Options:
*  LAGS=number of lags to use [4]
*  LST/[NOLST] determines whether to use Tsay or LST variant.
*  [PRINT]/NOPRINT
*
* References:
*  Tsay(1996), "Nonlinearity Tests for Time Series", Biometrika, vol 73, 461-466.
*
*  Luukkonen, Saikkonen and Terasvirta(1988), "Testing Linearity against smooth
*  transition autoregressive models", Biometrika vol 75, 491-499.
*
* Revision Schedule:
*  06/2008 Written by Tom Doan, Estima
*
procedure TsayNLTest x start end
type series x
type integer start end
*
option integer lags  4
option switch  print 1
option switch  lst   1
*
local symm[series] m
local vect[series] l
local integer i j
local series u
*
dim m(lags,lags) l(lags)
*
if .not.%defined(x) {
   display "Syntax: @TsayNLTest(options) >>x<< start end"
   return
}
*
* Do the base autoregression
*
linreg(noprint) x start end u
# constant x{1 to lags}
*
* Set up the auxiliary variables. The M variables are for the Tsay Ori-F test. The
* L variables are the additional variables for the STAR test.
*
do i=1,lags
   set l(i) %regstart() %regend() = x{i}**3
   do j=1,i
      set m(i,j) %regstart() %regend() = x{i}*x{j}
   end do j
end do i
*
if lst==0 {
   linreg(noprint) x %regstart() %regend()
   # x{1 to lags} m
   exclude(print=print,title="Tsay Ori-F Test with "+lags+" lags")
   # m
}
else {
   linreg(noprint) x %regstart() %regend()
   # x{1 to lags} m l
   exclude(print=print,title="LST Test for STAR with "+lags+" lags")
   # m l
}
end
guillaume
Posts: 7
Joined: Wed Jun 17, 2009 9:21 am

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by guillaume »

Is there a procedure in RATS in order to apply the threshold test of Tsay (1998) in a multivariate case?
Thanks
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by TomDoan »

guillaume wrote:Is there a procedure in RATS in order to apply the threshold test of Tsay (1998) in a multivariate case?
Thanks
This looks like it will do that. The test procedure starts with the RLS instructions. Those estimate the model recursively with entries added based upon the threshold variable (here, the lagged average spread). The next step regresses the recursive residuals on the regressors. The residuals from that are compared with the recursive residuals using the RATIO instruction. The 30 degrees of freedom are the total number of regressors in the system of equations (2 equations x 15 each).

Code: Select all

open data "c:\rats\usecon.rat"
calendar(m) 1959
all 1993:2
data(format=rats) / fcm3 ftb3
set g3year = log(fcm3/fcm3{1})
set g3month = log(ftb3/ftb3{1})
set spread  = log(ftb3)-log(fcm3)
set sspread = (spread+spread{1}+spread{2})/3
compute sspread(1959:1)=spread(1959:1)
compute sspread(1959:2)=(spread(1959:1)+spread(1959:2))/2
*
rls(order=sspread{1}) g3year / rr3year
# constant g3year{1 to 7} g3month{1 to 7}
rls(order=sspread{1}) g3month / rr3month
# constant g3year{1 to 7} g3month{1 to 7}
*
linreg rr3year / wr3year
# constant g3year{1 to 7} g3month{1 to 7}
linreg rr3month / wr3month
# constant g3year{1 to 7} g3month{1 to 7}
*
ratio(mcorr=%nreg,degrees=30)
# rr3year rr3month
# wr3year wr3month
guillaume
Posts: 7
Joined: Wed Jun 17, 2009 9:21 am

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by guillaume »

Thanks.
I wonder whether we could rearrange the univariate tsaytest procedure available on estima website for the multivariate case.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by TomDoan »

This is a bit better constructed example of the test. I've replaced the data file from the previous one with an Excel spreadsheet. This does (approximately) the example from the Tsay paper on U.S. interest rates. The data set is clearly slightly different if you look at the graphs, so the fact that the results don't quite match shouldn't be of concern. I found a Gauss program which gives exactly the same results as this.

The TSAYTEST procedure was written before the RLS instruction existed, so it's a bit more primitive in how it generates the recursive estimates.

Code: Select all

*
* Replication file for Tsay (1998), "Testing and Modeling Multivariate Threshold
* Models", J. of American Statistical Assn, vol. 93, no. 443, 1188-1202.
*
* U.S. Interest Rates example. Data are similar, but not identical to those used
* in the paper.
*
open data usrates.xls
calendar(m) 1959
data(format=xls,org=columns) 1959:1 1993:2 fcm3 ftb3
set g3year  = log(fcm3/fcm3{1})
set g3month = log(ftb3/ftb3{1})
set spread  = log(ftb3)-log(fcm3)
set sspread = (spread+spread{1}+spread{2})/3
compute sspread(1959:1)=spread(1959:1)
compute sspread(1959:2)=(spread(1959:1)+spread(1959:2))/2
*
spgraph(vfields=3,footer="Figure 3. Time Plots of Growth Series of U.S. Monthly Interest Rates")
graph(vlabel="3-month")
# g3month
graph(vlabel="3-year")
# g3year
graph(vlabel="Spread")
# sspread
spgraph(done)
*
@VARLagSelect(lags=12,crit=aic)
# g3year g3month
*
compute p =7
compute k =2
*
do d=1,7
   dofor m0 = 50 100
      set thresh = sspread{d}
      *
      rls(noprint,order=thresh,condition=m0) g3year / rr3year
      # constant g3year{1 to p} g3month{1 to p}
      rls(noprint,order=thresh,condition=m0) g3month / rr3month
      # constant g3year{1 to p} g3month{1 to p}
      *
      * We need to exclude the conditioning observations, so we generate the
      * series of ranks of the threshold variable over the estimation range.
      *
      order(ranks=rr) thresh %regstart() %regend()
      *
      linreg(noprint,smpl=rr>m0) rr3year / wr3year
      # constant g3year{1 to p} g3month{1 to p}
      linreg(noprint,smpl=rr>m0) rr3month / wr3month
      # constant g3year{1 to p} g3month{1 to p}
      *
      ratio(mcorr=%nreg,degrees=k*%nreg,noprint)
      # rr3year rr3month
      # wr3year wr3month
      disp "D=" d "m0=" m0 @16 "C(d)=" *.## %cdstat @28 "P-value" #.##### %signif
   end dofor m0
end do d
Attachments
usrates.xls
(22.4 KiB) Downloaded 1404 times
guillaume
Posts: 7
Joined: Wed Jun 17, 2009 9:21 am

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by guillaume »

Thank you. It works very well. But is it possible to obtain the threshold level? Does it look like the example file from Walter Enders about TAR model?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by TomDoan »

Yes. You need to do a grid search over possible threshold values. The simplest way to do the calculation is to use the SWEEP instruction with the GROUP option. His model (equation 17) allows for different covariance matrices in the two regimes, so you also include the VAR=HETERO option. Adding this to the previous example does the search for the threshold. Note: I have no idea where he got the value for this from the paper. While the data sets don't match exactly, it's hard to believe a difference like that. I also ran the Icelandic river flow data and got exactly his result, so this is, in fact, the correct procedure.

Code: Select all

set thresh = sspread{1}
set rgrid 1 300 = -.30+(.35/300.0)*(t-1)
set aic   1 300 = 0.0
*
do i=1,300
   compute rtest=rgrid(i)
   sweep(group=thresh<rtest,var=hetero)
   # g3year g3month
   # constant g3year{1 to p} g3month{1 to p}
   compute aic(i)=-2.0*%logl+2.0*%nregsystem
end do i
*
scatter
# rgrid aic
guillaume
Posts: 7
Joined: Wed Jun 17, 2009 9:21 am

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by guillaume »

Thanks a lot, it works very well again. The difference you obtain with your procedure may be due to the delay you take for the threshold: 1 while Tsay takes 4.
I can not get the exact value of the threshold when i apply disp. Rats tells me that display cannot show series.
guillaume
Posts: 7
Joined: Wed Jun 17, 2009 9:21 am

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by guillaume »

Does someone know how to get the exact value of the threshold?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by TomDoan »

This will give you the grid point at which the AIC is minimized:

Code: Select all

ext(noprint) aic 1 300
disp rgrid(%minent)
spollard777
Posts: 35
Joined: Fri Nov 07, 2008 9:01 am

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by spollard777 »

Hello,

I get tsaynltest to run okay. I am wondering about the delay parameter in the univariate case. Is it built into the test procedure. Can one search for it and then use it. Or is a new procedure required to be used?

Stephen Pollard
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by TomDoan »

This thread has branched off in a couple of directions. The Tsay NL test doesn't have a "delay" parameter. Instead, it's a test involving (all) crossproducts and powers of the included lags. As such, it won't be as powerful against specific forms of non-linearity involving threshold effects. The TSAYTEST (rather than the TSAYNLTEST) is designed to test specifically for threshold effects. It takes the threshold variable as an input; for an example of a search for the delay, see the TSAYP194 example in the Tsay textbook replications.
spollard777
Posts: 35
Joined: Fri Nov 07, 2008 9:01 am

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by spollard777 »

Yes, I am interested in the LST test. I ran the tsay1994 program. It is a search for the delay parameter being equal to 1 thru 4 respectively. However, the reported f-tests and p-values are the same for each of the 4 regressions. So how do you select a delay of 5? I assume that it was 5 since that appears as the lag length for both m and LST.

Stephen Pollard
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by TomDoan »

spollard777 wrote:Yes, I am interested in the LST test. I ran the tsay1994 program. It is a search for the delay parameter being equal to 1 thru 4 respectively. However, the reported f-tests and p-values are the same for each of the 4 regressions. So how do you select a delay of 5? I assume that it was 5 since that appears as the lag length for both m and LST.

Stephen Pollard
I'm getting different results for the four delays.

TSAY Arranged Autoregression Test
F( 5 , 168 )= 2.10246 P= 0.06751
TSAY Arranged Autoregression Test
F( 5 , 168 )= 2.31870 P= 0.04557
TSAY Arranged Autoregression Test
F( 5 , 168 )= 3.47011 P= 0.00520
TSAY Arranged Autoregression Test
F( 5 , 168 )= 2.46120 P= 0.03505

You can do a delay of 5 with

set z = dx{5}
@tsaytest(threshold=z) dx
# dx{1 to 5}

or you could just add 5 to the end of the DOFOR list.
spollard777
Posts: 35
Joined: Fri Nov 07, 2008 9:01 am

Re: TsayNLTest - Tsay's test for non-linearities in an autoreg

Unread post by spollard777 »

I discovered the problem. I was running 7.3 (my 8.0 beta expired, waiting for 8.0) and it was pulling the source file from 8.0, which may have a different code, i used the source file from 7.3 and it works just fine.

Thanks

Stephen Pollard
Post Reply