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