1 / 88

实例建模

实例建模. 例 1 . 太阳黑子数数据 (1770-1987); 例 2. 国际航空公司月旅客数 (Box 和 Jenkins1970) ( 1949.1-1960.12);. 例 1 . 太阳黑子数数据 (1770-1987);. 1. 导入太阳黑子数数据 load sunspot.dat whos Name Size Bytes Class sunspot 288x2 4608 double array

zhen
Download Presentation

实例建模

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 实例建模 例1.太阳黑子数数据(1770-1987); 例2. 国际航空公司月旅客数(Box和Jenkins1970)(1949.1-1960.12);

  2. 例1.太阳黑子数数据(1770-1987); 1.导入太阳黑子数数据 load sunspot.dat whos Name Size Bytes Class sunspot 288x2 4608 double array Grand total is 576 elements using 4608 bytes

  3. year=sunspot(:,1); wolfer=sunspot(:,2); plot(year,wolfer) xlabel('Year') ylabel('Number of sunspot') title('Sunspot Data')

  4. 考察序列的图形,该序列为近似的平稳 序列或含有周期大约为11的季节项。

  5. 2.计算样本自相关函数和偏相关函数 figure autocorr(wolfer,40,2); legend('自相关系数函数'); figure parcorr(wolfer,40); legend('偏相关系数函数');

  6. 可认为该序列的自相关系数函数随时间振荡缓慢而趋向于0;可认为该序列的自相关系数函数随时间振荡缓慢而趋向于0; • 可认为该序列具有周期为11的特征,建议先消去周期性趋势。

  7. 可认为该序列的偏相关系数函数随时间振荡缓慢而趋向于0可认为该序列的偏相关系数函数随时间振荡缓慢而趋向于0

  8. 3. 时间序列的分解(消去季节项) (1)季节项的估计(取每个周期内的数据平均值为各自的季节项估计); • length(wolfer); 288 • wolfer1=[wolfer; zeros(9,1)]; • wolferm=reshape(wolfer1,11,27); • meanm=[mean(wolferm(1:2,1:27)') mean(wolferm(3:11,1:26)')]';

  9. 23.0185 22.2481 26.3692 43.4077 63.7885 82.5231 80.4769 66.7731 53.3192 42.1885 30.6462 等价于 meanm= [mean(wolferm(1,1:27)); mean(wolferm(2,1:27)); mean(wolferm(3,1:26)); mean(wolferm(4,1:26)); mean(wolferm(5,1:26)); mean(wolferm(6,1:26)); mean(wolferm(7,1:26)); mean(wolferm(8,1:26)); mean(wolferm(9,1:26)); mean(wolferm(10,1:26)); mean(wolferm(11,1:26))];

  10. meanm1= meanm*ones(1,27); • seasonal=meanm1(1:288); • plot(year,seasonal); • xlabel('Year') • ylabel('Number of sunspot') • title('太阳黑子数的季节项估计')

  11. (2)消去季节项后数据,其样本均值可近似认为为0;(2)消去季节项后数据,其样本均值可近似认为为0; • wolfer2=wolferm- meanm*ones(1,27); • wolfer3=reshape(wolfer2,1,297); • wolfer0=wolfer3(1:288)'; • plot(year,wolfer0);

  12. (3)计算样本自相关函数和偏相关函数 • figure • autocorr(wolfer0,40,2); • legend('消去季节项后的数据的自相关系数函数'); • figure • parcorr(wolfer0,40); • legend('消去季节项后的数据的偏相关系数函数');

  13. 样本自相关函数和偏相关函数的特征与原 来变化不大,随时间振荡趋向于0,不具 有较明显的截尾性质,建议采用ARMA模 型进行建模。

  14. 4. 建立ARMA(p,q)模型. 对 p=0,1,2,3; q=0,1,2,3; 逐对建立模型,取AIC达到最小的为合适模型 • a=zeros(4,4); • for p=0:3 • for q=0:3 • m=armax(wolfer0,[p,q]); • a(p+1,q+1)=aic(m); • end • end

  15. a = 6.9978 6.1595 5.6854 5.5724 5.8822 5.6434 5.5337 5.5249 5.4796 5.4819 5.4827 5.4920 5.4839 5.4836 5.4002 5.3914

  16. mw= armax(wolfer0,[3 3]); • mw Discrete-time IDPOLY model: A(q)y(t) = C(q)e(t) A(q) = 1 - 2.497 q^-1 + 2.338 q^-2 - 0.8131 q^-3 C(q) = 1 - 1.427 q^-1 + 0.5083 q^-2 + 0.09392 q^-3 Estimated using ARMAX from data set wolfer0 Loss function 210.311 and FPE 219.521 Sampling interval: 1

  17. 模型方程:

  18. 5. 所建模型的白噪声检验 (1)残差计算及正态分布检验法 e=resid(m3,wolfer0);

  19. 图所表示的是残差的自相关函数数据图(The 99% confidence intervals for these values are also computed and shown as a yellow region),没有一个超出其范围,不能否定为白噪声。

  20. (2)白噪声的检验 • rho=autocorr(e,40); • for m=1:15 • sum2=0; • for k=1:m • sum2=sum2+ rho(k+1)* rho(k+1); • end • chipf(m)=288*sum2; • lamda(m)=chi2inv(0.95,m); • end • t=1:15; • plot(t,chipf(t),t,lamda(t)); • legend('chipf','临界值lamda');

  21. (3)递推预测残差图plot(e);

  22. 6. 模型递推预测值与实际观测值比较图 • wolferpredict = predict(mw,wolfer0); • plot(year,wolfer0); • hold on • plot(year,wolferpredict,'r'); • hold off • xlabel('Year') • ylabel('Number of sunspot') • title('model predict number Versus Exact number')

  23. 例2. 国际航空公司从1949.1到1960.12 的月客数

  24. y1=[112 118 132 129 121 135 148 148 136 119 104 118 115 126 141 135 125 149 170 170 158 133 114 140 145 150 178 163 172 178 199 199 184 162 146 166 171 180 193 181 183 218 230 242 209 191 172 194 196 196 236 235 229 243 264 272 237 211 180 201 204 188 235 227 234 264 302 293 259 229 203 229 242 233 267 269 270 315 364 347 312 274 237 278 284 277 317 313 318 374 413 405 355 306 271 306 315 301 356 348 355 422 465 467 404 347 305 336 340 318 362 348 363 435 491 505 404 359 310 337 360 342 406 396 420 472 548 559 463 407 362 405 417 391 419 461 472 535 622 606 508 461 390 432];

  25. 数据图 plot(y1);

  26. 数据图2

  27. plot([0:143],y1); • set(gca,'XTick',[1 25 49 73 97 121]) • set(gca,'XTickLabel',{'Jan 1970' 'Jan1973' ... • 'Jan1976' 'Jan1979' 'Jan1982' 'Jan1985'}); • legend('月旅客数')

  28. 季节模型介绍

  29. 一. 数据变换1. 常用方法,先Box-Cox变换

  30. y2=log(y1); plot(y2);

  31. 从数据图看出,每一年内的数据具有较缓慢的线性趋势性,且每年的固定月份数据具有明显的线性趋势,先做两种差分运算(或线性回归方法等)从数据图看出,每一年内的数据具有较缓慢的线性趋势性,且每年的固定月份数据具有明显的线性趋势,先做两种差分运算(或线性回归方法等)

  32. 2.差分运算 • y3=diff(y2); • y=y3(13:143)-y3(1:131); • plot(y) • title('数据处理后的图');

  33. 可以认为该数据近似为平稳的

  34. 二、数据零均值化,计算样本自相关函数和偏相关函数二、数据零均值化,计算样本自相关函数和偏相关函数 • x=y-mean(y); • figure • autocorr(x,25,2); • legend('自相关系数函数'); • figure • parcorr(x,25); • legend('偏相关系数函数');

  35. 自相关函数、偏相关函数不具有明显的截尾特征,建议采用季节ARMA模型建立模型

More Related