%% Clear screen and storage
clc
clear
%% Import data
x=importdata('power6.txt')
numObs=length(x)
%% Draw ACF and PACF
figure(1)
subplot(1,2,1)
autocorr(x)
subplot(1,2,2)
parcorr(x)
%% Model identification
for i=0:3
for j=0:3
k=i+1
kk=j+1
spec=garchset('R',i,'M',j,'Display','off')%指定模型的结构
[coeffX,errorsX,LLFX]=garchfit(spec,x) %拟合参数
numParam=garchcount(coeffX) %计算拟合参数的个数
%compute Akaike and Bayesian Information Criteria
[aic(k,kk),bic(k,kk)]=aicbic(LLFX,numParam,numObs)
end
end
[p,q]=find(aic==min(min(aic)))
p=p-1
q=q-1
%% Model estimation
spec=garchset('R',p,'M',q,'Display','off')%指定模型的结构
[coeffX,errorsX,LLFX]=garchfit(spec,x) %拟合参数
%% Forcasting
[sigma_Forecast,x_Forecast] = garchpred(coeffX,x,24)
figure(2)
plot(1:length(x),x,'.-')
hold on
plot(length(x)+1:length([xx_Forecast]),x_Forecast,'r.-')
xcorr计算的互相关函数的选项参数:= xcorr(X,Y,'选项')
选项= baised,互相关函数偏估计的计算BR />选项=无偏,无偏估计计算的互相关函数
选项= COEFF计算的归一化互相关函数,数介于-1到1之间的相互关系
选项= none时,是默认的。
所以,如果你要计算的交叉相关系数可以用来“COEFF的参数。