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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值