|
1、 单位根检验
SAS支持的单位根检验方法包括DF、ADF、PP、KPSS和RW(检验带漂移项的随机游走)。ADF在应用中最为常见,其SAS程序可如下编写:
proc arima data=one;
identify var=y1 stationarity=(adf=(3));
run;
adf=(3)表示滞后阶为3,这可以根据系数显著性的t检验来确定。
SAS给出的结果非常多,因此,如果只想保留ADF检验的内容,则可以对输出结果进行控制。参考程序如下:
ods listing select ;
'identification 1'.'Augmented Dickey-Fuller Unit Root Tests';
proc arima data=one;
identify var=y1 stationarity=(adf=(3));
run;
quit;
2、 协整检验
COINTEG语句格式为:
COINTEG RANK=number < H=(matrix) > < J=(matrix) >
< EXOGENEITY > < NORMALIZE=variable > ;
协整语句能够检验调节向量和长期参数的约束;也可以检验长期参数的弱外生性。协整系统用Johansen and Juselius (1990)and Johansen (1995a, 1995b)提出的ML法估计。
RANK=number指定协整系统的秩,其值大于0小于变量个数。在COINTEG语句中该选项是必须的。< NORMALIZE=variable >指定协整关系中一个变量的系数被标准化为1。为了检验α和β的限制性条件,可以使用H和J矩阵。这里重点介绍H和J矩阵行列数的确定。H=(matrix)选项是协整向量的约束阵。设协整向量矩阵为β,则β=H∮,H为K×s或(k+1)×s,∮为s×r的未知阵。k等于解释变量个数,r<=s<k,r的值由选项RANK=r确定。
MODEL语句格式为:
MODEL dependents < = regressors >
< , dependents < = regressors > . . . >
< / options > ;
Model语句设定内生变量和外生变量。与协整相关的Model语句除一般功能外,还设定单位根检验的方法(DF检验),协整检验的方法(Johansen检验或SW检验),如下面的参考程序:
proc varmax data=one;
model y1-y4 / p=2 lagmax=6 dftest
cointtest=(johansen=(iorder=2))
ecm=(rank=1 normalize=y1);
run;
3、 弱外生性检验
< EXOGENEITY >选项用于变量的弱外生性检验。弱外生性由Engle (1987)所提出,其核心是将外生性基于感兴趣的参数(称为关注参数Interesting Parameters)而定义,Johansen(1991)将弱外生性检验扩展到ECM 之上。一般将关注参数设定为协整向量,若某一调节系数可约束为零,则称对应的应变量为关于协整向量的弱外生变量。
参考程序如下:
proc varmax data=one;
model y1-y4 / p=2;
cointeg rank=1 exogeneity;
run;
4、 格兰杰因果检验
代码:
var y x1 x2....[lag(滞后期数)]
vargranger
参考程序如下:
title 'Bivariate Granger Causality Test';
data gdp;
set sashelp.citiqtr;
keep date gdpq;
run;
data gp;
set sashelp.citimon;
keep date eegp;
run;
proc expand data=gp out=temp from=month to=qtr;
convert eegp / observed=average;
id date;
run;
data combined;
merge gdp temp;
by date;
run;
data causal;
set work.combined;
gdpq_1 = lag(gdpq);
gdpq_2 = lag2(gdpq);
eegp_1 = lag(eegp);
eegp_2 = lag2(eegp);
run;
/** Granger Form **/
* unrestricted model;
proc autoreg data=causal;
model gdpq = gdpq_1 gdpq_2 eegp_1 eegp_2;
output out=out1 r=e1; /* output residuals */
run;
* restricted model;
proc autoreg data=out1;
model gdpq = gdpq_1 gdpq_2;
output out=out2 r=e0; /* output residuals */
run;
ods select Iml._LIT1010
Iml.TEST1_P_VAL1
Iml.TEST2_P_VAL2;
ods html body='exgran01.htm';
* compute test;
proc iml;
start main;
use out1;
read all into e1 var{e1};
close out1;
use out2;
read all into e0 var{e0};
close out2;
p = 2; /* # of lags */
T = nrow(e1); /* # of observations */
sse1 = ssq(e1);
sse0 = ssq(e0);
* F test;
test1 = ((sse0 - sse1)/p)/(sse1/(T - 2*p - 1));
p_val1 = 1 - probf(test1,p,T - 2*p - 1);
* asymtotically equivalent test;
test2 = (T * (sse0 - sse1))/sse1;
p_val2 = 1 - probchi(test2,p);
print "IML Result",, test1 p_val1,,
test2 p_val2;
finish;
run;
quit;
ods html close;
* Plot of the two series;
data trans;
set combined;
keep date gdpq eegp;
obs = _n_;
gdpq = (gdpq - 3600)/1400;
eegp = (eegp - 80)/70;
run;
title1 ' GDP and Gasoline Price';
axis1 label=(angle=90 'Gross Domestic Product')
order=(0 to 1 by .142) minor=none major=none offset=(0,0)
value=('3600' '3800' '4000' '4200' '4400' '4600' '4800' '5000');
axis2 label=(angle=90 'Gasoline Price')
order=(0 to 1 by .142) minor=none major=none offset=(0,0)
value=('80' '90' '100' '110' '120' '130' '140' '150');
axis3 label=('Date');
symbol1 color=red interpol=join value=none;
symbol2 color=blue interpol=join value=none;
proc gplot data=trans;
format date year4.;
plot gdpq*date / cframe=ligr
vaxis=axis1 haxis=axis3;
plot2 eegp*date / cframe=ligr
vaxis=axis2;
run;
quit;
|