其他分享
首页 > 其他分享> > ARIMA时序分析模型

ARIMA时序分析模型

作者:互联网

%AMRIMA模型:根据图书去年各月销量,预测图书未来销量情况
clc;
clear;
close all;
%导入原始数据,获得时间序列数据矩阵
t = 1:28;
t = t';
y = [1019,1502,-24,61,30,1584,173,901,-3,-67,240,5365,-8,0,124,156,2,7,-112,-86,-134,21,112,-506,-63,40,-3,-546];
y = y';
figure
plot(t, y)
grid on
 
%使用差分运算处理,确定ARIMA模型中的自相关系数ACF和偏相关系数PACF 
figure
subplot(2,1,1),autocorr( y );
subplot(2,1,2),parcorr( y );
figure
dy = diff( y );
subplot(2,1,1),autocorr( dy );
subplot(2,1,2),parcorr( dy );
 
%拟合获得ARIMA模型
Mdl = arima(4,2,1);
EstMdl = estimate(Mdl,y);
res = infer(EstMdl,y);

%检验获得的ARIMA模型
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)
 
%通过ARIMA模型预测未来结果,给出误差上下限
[yF,yMSE] = forecast(EstMdl,20,'Y0',y);
UB = yF + 1.96*sqrt(yMSE);
LB = yF - 1.96*sqrt(yMSE);
 
figure
line_old = plot(y,'b','LineWidth',1);
grid on
hold on
line_predt = plot(29:48,yF,'g','LineWidth',1);
line_upLimit = plot(29:48,UB,'r--','LineWidth',1.2);
line_lowLimit = plot(29:48,LB,'r--','LineWidth',1.2);
hold off

 

标签:subplot,plot,figure,res,ARIMA,时序,分析模型,LineWidth
来源: https://blog.csdn.net/Fernandon/article/details/116371120