对于较高的自回归参数,标准的kpss存在过度的检验水平。我们需要利用异方差与自回归一致协方差估计量来估计自回归过程的长期方差,在有限样本下,窗宽选择过大,长期方差过度估计,检验统计量变得非常小,从而检验功效变得很小;选择过小和较大的自回归参数,长期方差会低估,检验统计量变得非常大,有较大的检验水平。Bart Hobijn(1998)利用Newey and West,1994年的方法,即依数据自动选择窗宽的方法,调整了标准kpss的不足。
有兴趣的
读者可以读读这篇文章。
下面的gauss 程序,考虑了两种核函数,也是各种非参估计中非常重要的两种:Quadratic spectral kernel、Bartlett kernel ,特别是两种核函数在gauss中的设置,而且这些都可以应用到其他的情况,特别是有非参估计的问题。程序有点长。
new; cls;
let data=
80 10236000
78 10351000
71 9371000
73 9126000
70 8230000
71 12111000
72 5364000
76 6222000
76 3952000
78 3859000
80 4798000
80 5133000
77 4240000
69 13687000
69 5248000
68 4058000
67 5253000
66 8963000
67 6457000
70 8882000
69 4134000
68 3736000
69 3887000
69 2095000
68 1980000
63 7433000
63 5487000
63 3996000
58 10858000
60 12095000
57 7251000
53 17632000
55 42481000
65 16051000
64 9145000
62 11264000
64 4799000
64 6888000
66 7093000
69 6598000
70 6280000
69 5372000
65 7381000
64 2792000
63 4258000
60 3074000
62 4427000
60 3767000
61 3041000
60 10240000
;
data=reshape(data,rows(data)/2,2);
y=data[.,1];
kerntype = 1;
lagtype = {1,2};
{x0} = wtest( y ,1 ,kerntype ,lagtype );
print x0;
/*** KPSSTest.SRC:
** Wtest Generalized KPSS test.
** Bartlett Bartlett spectral window
** QS Quadratic Spectral window
** Lagsel Newey and West (1994) automatic lag selection procedure.
** NB Bandwidth choice for Lagsel using Bartlett.
** NQS Bandwidth choice for Lagsel using Quadratic Spectral.
** MB Bandwidth choice for Bartlett without lagsel.
** MQS Bandwidth choice for Quadratic Spectral without lagsel.
** Autocov Calculates autocovariances.
*/
/*** Procedure wtest:
** Format:
** w = Wtest( y , h , kerntype , lagtype );
** Input:
** y (Tx1)-vector, containing time series of which stationarity is tested.
** h scalar, null hypothesis:
** = 0 zero mean stationarity
** = 1 level stationarity
** = 2 trend stationarity
** kerntype scalar, kernel used:
** = 0 Bartlett kernel
** = 1 Quadratic Spectral kernel
** lagtype (2x1)-matrix: lag selection procedure.
** lagtype[1] = 0 no automatic lag selection (m=n)
** = 1 automatic lag selection
** lagtype[2] scalar/integer, bandwidth. (n)
***/
proc(1) = wtest( y , h , kerntype , lagtype );
local t , w , sigma2 , e , x , b , m , kern , acov ;
if (kerntype/=0) and (kerntype/=1);
errorlog("wrong kernel choice");
end;
endif;
T = rows(y);
/* Calculating residuals from auxiliary regressions */
if ( h == 0 );
e = y;
elseif ( h == 1 );
x = ones(t,1);
b = y/x;
e = y-x*b;
elseif ( h == 2 );
x = ones(t,1)~seqa(1,1,t);
b = y/x;
e = y-x*b;
else;
errorlog("wrong null hypothesis: h");
end;
endif;
/* Estimating autocovariances */
acov = autocov(e);
/* Calculating kernel */
if ( lagtype[1] == 0 );
m = lagtype[2];
elseif ( lagtype[1] == 1 );
m = lagsel( kerntype,acov,lagtype[2]);
else;
errorlog("lag selection variable: lagtype");
end;
endif;
if (kerntype == 0);
kern = bartlett( T , m );
elseif ( kerntype == 1 );
kern = qs( T , m );
else;
errorlog("wrong kernel selection: kerntype");
end;
endif;
/* Estimating periodogram at frequency zero */
m = 2.*ones(t,1);
m[1] = 1;
sigma2 = m'*(acov.*kern);
/* Calculating test statistic */
w = sumc(cumsumc(e)^2)./(T^2.*sigma2);
retp(w);
endp;
/*Procedure Bartlett:
** Purpose:Calculates Bartlett kernel.
** Format:kern = Bartlett( T , m )
** Input:
** T scalar, sample size.
** m scalar, bandwidth.
** Output:
** kern (Tx1)-vector, kernel weights for the estimated autocovariances for the estimation of
the smoothed periodogram.
** Note:
** k(m,j) = ( 1 - (j/(m+1)) ) for j <= m
** = 0 otherwise */
proc(1) = bartlett(T,m);
local j , kern;
j = seqa(0,1,T);
kern = ( 1 - j./(m+1));
kern = kern.*(kern.>0);
retp(kern);
endp;