你好 请问怎么用matlab确定ARMA模型的阶数,谢谢!

时间序列应经给定,如何用matlab来确定该序列的ARMA模型的阶数p,q呢,还有它的系数,谢谢你

描述问题呢,就要准确,不然会让回答的人无所是从,很多时候心情不好就不会看了,比如,你是用SPSS还是matlab或是SAS或是minitab或是R,时间序列是有季节性?趋势性?等等,你不说清这些,人家也很郁闷啊,如果是matlab,我给你下面的ARMA程序参考,你把那个随机数换成你的,相应的地方改一下,就可以了,SAS也有,没贴了,matlab 10版以上是有时间序列工具箱的,其它的界面操作,自己去学吧。
clc,clear
randn('state',sum(clock)); %初始化随机数发生器
elps=randn(1,10000); %产生 10000个服从标准正态分布的随机数
x(1)=0; %赋初始值
for j=2:10000
x(j)=0.8*x(j-1)+elps(j)-0.4*elps(j-1); %产生样本点
end
for i=0:3
for j=0:3
spec= garchset('R',i,'M',j,'Display','off'); %指定模型的结构
[coeffX,errorsX,LLFX] = garchfit(spec,x); %拟合参数
num=garchcount(coeffX); %计算拟合参数的个数
%compute Akaike and Bayesian Information Criteria
[aic,bic]=aicbic(LLFX,num,10000);
fprintf('R=%d,M=%d,AIC=%f,BIC=%f\n',i,j,aic,bic); %显示计算结果
end
end来自:求助得到的回答
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-06-19
  用matlab确定ARMA模型的阶数,要对差分以后的序列进行拟合和预测,求出最好的阶数。代码如下供参考:
z=[DX;zeros(12,1)];
z=iddata(z);

test=[];
for p=1:12
for q=1:12
m=armax(z(1:200),[p q]);
AIC=aic(m);
test=[test;p q AIC];
end
end
for k=1:size(test,1)
if test(k,3)==min(test(:,3))
p_test=test(k,1);
q_test=test(k,2);
break;
end
end

%拟合
m1=armax(z(1:200),[p_test q_test]);
figure(5);
e = resid(m1,z);
plot(e);
set(gca,'Xlim',[0 ls]);

figure(6);
subplot(2,1,1)
autocorr(e.outputdata)
subplot(2,1,2)
parcorr(e.outputdata)
set(gca,'Xlim',[0 ls]);

%预测过程
pr=predict(m1,z,12);

po=pr.outputdata;
figure(7)
plot(po,'r')
hold on

plot(y,'b');
set(gca,'Xlim',[0 ls]);
第2个回答  2015-07-09
%下面要对差分以后的序列进行拟合和预测,求出最好的阶数
z=[DX;zeros(12,1)];
z=iddata(z);

test=[];
for p=1:12
for q=1:12
m=armax(z(1:200),[p q]);
AIC=aic(m);
test=[test;p q AIC];
end
end
for k=1:size(test,1)
if test(k,3)==min(test(:,3))
p_test=test(k,1);
q_test=test(k,2);
break;
end
end

%拟合
m1=armax(z(1:200),[p_test q_test]);
figure(5);
e = resid(m1,z);
plot(e);
set(gca,'Xlim',[0 ls]);

figure(6);
subplot(2,1,1)
autocorr(e.outputdata)
subplot(2,1,2)
parcorr(e.outputdata)
set(gca,'Xlim',[0 ls]);

%预测过程
pr=predict(m1,z,12);

po=pr.outputdata;
figure(7)
plot(po,'r')
hold on

plot(y,'b');
set(gca,'Xlim',[0 ls]);