1、ARIMA模型SAS程序
（1）输入数据，并对其进行差分处理
data gas;
input gasprice@@;
difgasprice=dif(gasprice);
time=intnx('month','01jan2001'd,_n_-1);
format time date.;
cards;
8.84 7.21 6.3 6.08 5.46 4.75 4.1 3.99 3.5 3.18 3.88 3.69 4.05 3.7
3.78 3.64 4.07 3.86 3.8 3.62 3.89 4.18 4.72 4.92 5.65 6.4 8.27 5.96
5.78 6.59 5.69 5.28 5.32 4.93 5.19 5.9 6.72 6.52 5.97 6.06 6.34 6.82
6.41 6.36 5.68 6.03 7.64 7.54 7.06 7.15 7.12 7.71 7.19 6.91 7.4 7.98
10.18 12.06 12.11 11.17 10.85 9.38 8.24 7.93 7.63 6.92 6.78 7.36 7.21
5.62 7.74 8.23 7.36 8.25 8.42 8.14 8.11 7.92 7.51 6.72 6.28 7.06 7.87
8.18 8.29 8.96 9.61 10.03 11.35 12.11 13.06 10.1 9.13 8.1 7.34 7.86 7.5
6.43 5.69 5.05 4.4 4.56 4.68 4.38 3.89 4.82 5.44 5.97 6.93 6.76 6.01 5.12
5.07 5.03 5.49 5.37 4.61 4.74 4.6 5.42
;
（2）对原序列做时序图
proc gplot data=gas;
plot gasprice*time=1;
symbol1 v=circle i=join c=black;
run;
（3）得到原序列的自相关图和偏自相关图
proc arima;
identify var=gasprice；
run;
（4）对差分后的序列做时序图
proc gplot;
plot difgasprice*time;
symbol v=star c=black i=join;
run;
（5）得到差分后序列的自相关图和偏自相关图
proc arima;
identify var=gasprice(1);
run;
（6）得到9个不同模型的估计值、AIC和SBC值、残差检验和系数显著性检验结果
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
estimate q=1 noint;
forecast lead=5 id=1;
run;
estimate p=0 q=0 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;
estimate p=0 q=1 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;
estimate p=0 q=2 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;
estimate p=1 q=0 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;
estimate p=1 q=1 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;
estimate p=1 q=2 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;
estimate p=2 q=0 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;
estimate p=2 q=1 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;
estimate p=2 q=1 noint;
identify var=gasprice(1) nlag=8 minic p=(0:5) q=(0:5);
forecast lead=5 id=1;
run;


2、BP神经网络Matlab程序
（1）导入数据
[p1]=xlsread('Data.xls','sheet1','A1:A111');
[p2]=xlsread('Data.xls','sheet1','B1:B111');
[p3]=xlsread('Data.xls','sheet1','C1:C111');
[p4]=xlsread('Data.xls','sheet1','D1:D111');
[p5]=xlsread('Data.xls','sheet1','E1:E111');
[p6]=xlsread('Data.xls','sheet1','F1:F111');
[p7]=xlsread('Data.xls','sheet1','G1:G111');
[p8]=xlsread('Data.xls','sheet1','H1:H111');
[t]=xlsread('Data.xls','sheet1','I1:I111');
P=[p1,p2,p3,p4,p5,p6,p7,p8];
p=P.';
t=t.';
（2）数据预处理
[pn,minp,maxp,tn,mint,maxt] = premnmx(p,t);
dx = [-1,1;-1,1;-1,1;-1,1;-1,1;-1,1;-1,1;-1,1];
（3）建立神经网络
net = newff(dx,[8,12,1],{'tansig','tansig','purelin'},'traingdx');
net.trainParam.show = 1000;
net.trainParam.epochs = 50000;
net.trainParam.Lr = 0.05;
net.trainParam.goal = 0.01;
net = train(net,pn,tn);
TRAINGDX, Epoch 0/50000, MSE 6.79346/0.01, Gradient 17.8801/1e-006
TRAINGDX, Epoch 1000/50000, MSE 0.0544582/0.01, Gradient 0.0342735/1e-006
TRAINGDX, Epoch 2000/50000, MSE 0.0290392/0.01, Gradient 0.0486378/1e-006
TRAINGDX, Epoch 3000/50000, MSE 0.0161374/0.01, Gradient 0.00791597/1e-006
TRAINGDX, Epoch 4000/50000, MSE 0.0135129/0.01, Gradient 0.00277473/1e-006
TRAINGDX, Epoch 5000/50000, MSE 0.01219/0.01, Gradient 0.0214924/1e-006
TRAINGDX, Epoch 6000/50000, MSE 0.0111435/0.01, Gradient 0.0128621/1e-006
TRAINGDX, Epoch 7000/50000, MSE 0.0100375/0.01, Gradient 0.00261606/1e-006
TRAINGDX, Epoch 7010/50000, MSE 0.00999716/0.01, Gradient 0.00477715/1e-006
TRAINGDX, Performance goal met.
（4）仿真并反归一化
y1=sim(net,pn)
y2=postmnmx(y1,mint,maxt)
y2.'
（5）输出权值和阈值
w1=net.iw{1,1}
theta1=net.b{1}
w2=net.lw{2,1}
theta2=net.b{2}

