1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
Y=[1.81,1.77,1.73,1.69,1.65,1.62,1.58,1.55,1.51,1.46,1.41,1.35,1.29,1.23,1.18,1.15,1.12,1.09,1.06,1.04];
adf=adftest(Y');
kpss=kpsstest(Y');
Yd1=diff(Y');
adf1=adftest(Yd1);
kpss1=kpsstest(Yd1);
Yd2=diff(Yd1);
adf2=adftest(Yd2);
kpss2=kpsstest(Yd2);
figure
autocorr(Yd2);
figure
parcorr(Yd2);
p=1;
q=1;
Mdl = arima(p, 2, q);
EstMdl=estimate(Mdl,Yd2);
[res,logL] = infer(EstMdl,Yd2);
figure
subplot(2,2,1)
plot(res./sqrt(EstMdl.Variance))
title('Standardized Residuals')
subplot(2,2,2),qqplot(res)
subplot(2,2,3),autocorr(res)
subplot(2,2,4),parcorr(res)
[yF,yMSE]=forecast(EstMdl,1,'y0',Y');
UB=yF+1.96*sqrt(yMSE);
LB=yF-1.96*sqrt(yMSE);
data=Y';step=1;
figure()
plot(data,'Color',[.7,.7,.7]);
hold on
h1 = plot(length(data):length(data)+step,[data(end);LB],'r:','LineWidth',2);
plot(length(data):length(data)+step,[data(end);UB],'r:','LineWidth',2)
h2 = plot(length(data):length(data)+step,[data(end);yF],'k','LineWidth',2);
legend([h1 h2],'95% ÖÃÐÅÇø¼ä','Ô¤²âÖµ',...
'Location','NorthWest')
title('Forecast')
hold off
|