资源简介
MATLAB程序,附有数据和详细计算过程,自回归模型到分析过程
代码片段和文件信息
clear;
%--------------------------------油价序列零均值化后的数据如下----------------------------------------%:
P=[ 19.5900 14.9100 15.7400 15.4000 13.0600 19.0700 15.2800 15.8200 12.7700 12.0500...
11.6900 13.8500 13.8500 10.0700 9.1700 10.7900 13.4400 21.1700 18.6400 13.2100...
15.5400 21.9400 23.1100 18.6400 14.9400 16.9000 15.4600 11.1500 13.1300 12.4800...
12.9500 12.5900 10.5800 10.5800 12.3900 15.5300 13.0600 10.2200 16.3300 19.7200...
21.3100 18.8400 24.8400 15.6700 15.5700 12.7300 13.5600 15.5400 17.2200 12.1400...
11.0700 12.0200 11.5500 6.9200 10.3300 8.3800 12.1100 11.4600 12.7500 13.3200...
13.0000 11.9000 11.7900 12.5500 11.8400 11.2500 11.1500 10.9900 11.7000 14.0100...
17.5100 17.2700 16.9000 15.7900 15.4500 6.2400 16.7100 16.7700 16.6400 17.8000...
16.8700 16.1300 15.7600 15.6600 15.5400 15.3000 15.0500 14.6900 14.3900 14.1800...
13.70 13.66 13.27 13.56 13.14 14.19 ];
F=[ 19.5900 14.9100 15.7400 15.4000 13.0600 19.0700 15.2800 15.8200 12.7700 12.0500...
11.6900 13.8500 13.8500 10.0700 9.1700 10.7900 13.4400 21.1700 18.6400 13.2100...
15.5400 21.9400 23.1100 18.6400 14.9400 16.9000 15.4600 11.1500 13.1300 12.4800...
12.9500 12.5900 10.5800 10.5800 12.3900 15.5300 13.0600 10.2200 16.3300 19.7200...
21.3100 18.8400 24.8400 15.6700 15.5700 12.7300 13.5600 15.5400 17.2200 12.1400...
11.0700 12.0200 11.5500 6.9200 10.3300 8.3800 12.1100 11.4600 12.7500 13.3200...
13.0000 11.9000 11.7900 12.5500 11.8400 11.2500 11.1500 10.9900 11.7000 14.0100...
17.5100 17.2700 16.9000 15.7900 15.4500 6.2400 16.7100 16.7700 16.6400 17.8000...
16.8700 16.1300 15.7600 15.6600 15.5400 15.3000 15.0500 14.6900 14.3900 14.180];
%----------------------由于时间序列有不平稳趋势,进行两次差分运算,消除趋势性----------------------%
for i=2:96
Yt(i)=P(i)-P(i-1);
end
for i=3:96
L(i)=Yt(i)-Yt(i-1);
end
figure;
L=L(3:96);
Y=L(1:88);
plot(P);
title(‘原数据序列图‘);
hold on;
pause
plot(Y‘r‘);
title(‘两次差分后的序列图和原数对比图‘);
pause
%--------------------------------------对数据标准化处理----------------------------------------------%
Ux=sum(Y)/88 % 求序列均值
yt=Y-Ux;
b=0;
for i=1:88
b=yt(i)^2/88+b;
end
v=sqrt(b) % 求序列方差
Y=(Y-Ux)/v; % 标准化处理公式
f=F(1:88);
t=1:88;
figure;
plot(tftY‘r‘)
title(‘原始数据和标准化处理后对比图‘);
xlabel(‘时间t‘)ylabel(‘油价y‘);
legend(‘原始数据 F ‘‘标准化后数据Y ‘);
pause
%--------------------------------------对数据标准化处理----------------------------------------------%
%------------------------检验预处理后的数据
评论
共有 条评论