急求matlab高手 Estimation of polynomial models (ARMAX, BJ, OE etc) is supported only for single-out 10
%functionPreData=ARIMA(SourceData,step)A=load('data1.txt');SourceData=A;TempData=Sour...
%function PreData = ARIMA(SourceData,step)
A=load('data1.txt');
SourceData=A;
TempData=SourceData;
TempData=detrend(TempData);%去趋势线
TrendData=SourceData-TempData;%趋势函数
%---------------------------------------------------差分,平稳化时间序列---------
[H,PValue,TestStat,CriticalValue] = adftest(TempData)%,[],0.05,'T');
%difftime=0;
SaveDiffData=[];
while ~H
SaveDiffData=[SaveDiffData,TempData(1,1)];
TempData=diff(TempData);%差分,平稳化时间序列
%difftime=difftime+1;%差分次数
[H,PValue,TestStat,CriticalValue] = adftest(TempData)%,[],0.05,'T');%adf检验,判断时间序列是否平稳化
end
%---------------------------------------------------模型定阶或识别--------------
u = iddata(TempData');
test = [];
for p = 0:5 %自回归对应PACF,给定滞后长度上限p和q,一般取为T/10、ln(T)或T^(1/2),这里取T/10=12
for q = 0:5 %移动平均对应ACF
m = armax(u,[p q]);
AIC = aic(m); %armax(p,q),计算AIC
test = [test;p q AIC];
end
end
for k = 1:size(test,1)
if test(k,3) == min(test(:,3)) %选择AIC值最小的模型
p_test = test(k,1);
q_test = test(k,2);
break;
end
end
%---------------------------------------------------1阶预测-----------------
for j=1:step
TempData=[TempData,0];
end
n=iddata(TempData');
m = armax(u,[p_test q_test]); %armax(p,q),[p_test q_test]对应AIC值最小
P1=predict(m,n,step);
PreR=P1.OutputData;
PreR=PreR';
%---------------------------------------------------还原差分-----------------
if size(SaveDiffData,2)~=0
for index=size(SaveDiffData,2):-1:1
PreR=cumsum([SaveDiffData(index),PreR]);
end
end
%---------------------------------------------------预测趋势并返回结果----------------
mp1=polyfit([1:size(TrendData,2)],TrendData,1);
xt=[];
for j=1:step
xt=[xt,size(TrendData,2)+j];
end
TrendResult=polyval(mp1,xt);
PreData=TrendResult+PreR(size(SourceData,2)+1:size(PreR,2));
tempx=[TrendData,TrendResult]+PreR;
plot(tempx,'r'),hold on,plot(SourceData);
在线等啊啊啊啊
??? Error using ==> armax at 65
Estimation of polynomial models (ARMAX, BJ, OE etc) is supported only for single-output data.
Error in ==> ARIMA at 22
m = armax(u,[p q]); 展开
A=load('data1.txt');
SourceData=A;
TempData=SourceData;
TempData=detrend(TempData);%去趋势线
TrendData=SourceData-TempData;%趋势函数
%---------------------------------------------------差分,平稳化时间序列---------
[H,PValue,TestStat,CriticalValue] = adftest(TempData)%,[],0.05,'T');
%difftime=0;
SaveDiffData=[];
while ~H
SaveDiffData=[SaveDiffData,TempData(1,1)];
TempData=diff(TempData);%差分,平稳化时间序列
%difftime=difftime+1;%差分次数
[H,PValue,TestStat,CriticalValue] = adftest(TempData)%,[],0.05,'T');%adf检验,判断时间序列是否平稳化
end
%---------------------------------------------------模型定阶或识别--------------
u = iddata(TempData');
test = [];
for p = 0:5 %自回归对应PACF,给定滞后长度上限p和q,一般取为T/10、ln(T)或T^(1/2),这里取T/10=12
for q = 0:5 %移动平均对应ACF
m = armax(u,[p q]);
AIC = aic(m); %armax(p,q),计算AIC
test = [test;p q AIC];
end
end
for k = 1:size(test,1)
if test(k,3) == min(test(:,3)) %选择AIC值最小的模型
p_test = test(k,1);
q_test = test(k,2);
break;
end
end
%---------------------------------------------------1阶预测-----------------
for j=1:step
TempData=[TempData,0];
end
n=iddata(TempData');
m = armax(u,[p_test q_test]); %armax(p,q),[p_test q_test]对应AIC值最小
P1=predict(m,n,step);
PreR=P1.OutputData;
PreR=PreR';
%---------------------------------------------------还原差分-----------------
if size(SaveDiffData,2)~=0
for index=size(SaveDiffData,2):-1:1
PreR=cumsum([SaveDiffData(index),PreR]);
end
end
%---------------------------------------------------预测趋势并返回结果----------------
mp1=polyfit([1:size(TrendData,2)],TrendData,1);
xt=[];
for j=1:step
xt=[xt,size(TrendData,2)+j];
end
TrendResult=polyval(mp1,xt);
PreData=TrendResult+PreR(size(SourceData,2)+1:size(PreR,2));
tempx=[TrendData,TrendResult]+PreR;
plot(tempx,'r'),hold on,plot(SourceData);
在线等啊啊啊啊
??? Error using ==> armax at 65
Estimation of polynomial models (ARMAX, BJ, OE etc) is supported only for single-output data.
Error in ==> ARIMA at 22
m = armax(u,[p q]); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询