一部分(观察图形判断是否条件期望平稳)、、
data example;
input price1 price2;
time=intnx ('month','01jul2004'd, _n_-1);
format time date.;
cards;
;
proc gplot data=example;
plot price1*time=1 price2*time=2/overlay;
symbol1 c=black v=star i=join;
symbol2 c=red v=circle i=needle;
run;
二部分(通过自相关系数,偏自相关系数,判断AR,MA,ARMA。大致判断阶数)、、
data example;
input freq@@;
year=intnx('month','01jul2004'd, _n_-1);
format year year4.;
cards;
34 45 54 453 90 24 85 474 488 843 43 573 546
;
proc arima data=example;
identify var=freq nlag=7 ;
run;
另外用identify var=freq nlag=8 minic p=(0:5) q=(0:5);
即用minic语句用BIC准则选择最优模型阶数
确定为ARMA(0,4)即MA(4)
三部分、
参数估计,同时包含了检验统计量BQ
Estimate q=4;
Run;
例子
data example;
input x@@;
time=_n_;
cards;
0.30 -0.45 0.36 0.00 0.17 0.45 2.15
4.42 3.48 2.99 1.74 2.40 0.11 0.96
;
proc gplot data=example;
plot x*time=1;
symbol1 c=red i=join v=star;
run;
proc arima data=example;
identify var=x nlag=8 minic p=(0:5) q=(0:5) ;
run;
estimate p=2 q=1;/*可以用method=ml or uls cls ; 另外如果常数项不显著 用noint 除掉常数项*/
run;
第四部分
序列预测
forecast lead=5 id=time out=results;/*lead 预测期数 id 为指定身份变量 out预测结果存入某数据集*/
run;
第五部分
最后还可以绘制拟合、预测图
Proc gplot data=results;
Plot x*time=1 forecast*time=2 l95*time=3 u95*time=3/overlay;/*说明l95,u95分别为95%的置信上限,下限*/
Symbol1 c=black i=none v=star;
Symbol2 c=red i=join v=none;
Symbo13 c=green i=join v=none l=32;
Run;