armaacvf.m

来自「Modeling and Forecasting Electricity Loa」· M 代码 · 共 39 行

M
39
字号
function CV=armaacvf(ar,ma,n);
%ARMAACVF Autocovariance function of an ARMA process.
%   CV=ARMAACVF(AR,MA,N) returns N+1 values of the theoretical 
%   autocovariance function of an ARMA process with autoregressive and 
%   moving average coefficients given by vectors AR=[1,a_1,...,a_p] and 
%   MA=[1,b_1,...,b_q], respectively. 
%
%   Reference(s):
%   [1] P.J.Brockwell, R.A.Davis (1991) 'Time Series: Theory and Methods', 
%   (2nd edn), Springer-Verlag, New York.

%   Written by Adam Misiorek and Rafal Weron (2006.09.16)
%   Copyright (c) 2006 by Rafal Weron

% Define AR and MA orders; in fact p and q are really p+1 and q+1,
% respectively
p = length(ar);
q = length(ma);
pp = max(p,q+1);
ar = [ar zeros(1,pp-p)];

mac = zeros(pp);
vec1 = zeros(pp,1);

% Compute coefficients of an MA(inf) process corresponding to ARMA(ar,ma)
vec2 = mainfcoeff(ar,ma,q)';

% Compute autocovariance
for i = 1:pp
    for j = 1:pp
        mac(i,abs(j-i)+1) = mac(i,abs(j-i)+1)+ar(j);
    end;        
    vec1(i) = ma(i:q)*vec2(1:q-i+1);
end;
CV = mac\vec1;
for i = pp+1:n+1
    CV = [CV;-ar(2:p)*CV(end:-1:end-p+2)];
end;
CV = CV(1:n+1);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?