Home > wafo > wdemos > rfcdemo1 > armacov.m

armacov

PURPOSE ^

Computes the covariance function for an AR- or ARMA-model.

SYNOPSIS ^

[r]=armacov(C,A,s2,m)

DESCRIPTION ^

  ARMACOV   Computes the covariance function for an AR- or ARMA-model. 
    The process is governed by the system equation 
      A(q) * x(t) = C(q) * sqrt(s2) * e(t)  
  
  r = armacov(C,A,s2,n) 
  
  r   = Covariance function 
  
  C   = Coefficients in C-polynomials. [1 c_1 ... c_nc] 
  A   = Coefficients in A-polynomials. [1 a_1 ... a_na] 
  s2  = Innovation variance. 
  n+1 = Number of calculated values. 
  
  Example: AR(2)-process. 
    r = armacov(1,[1 1 0.9],1,50); 
    plot(0:50,r) 
  Example: ARMA(4,2)-process. 
    r = armacov([1 0.05 -0.88],[1 -2.06 1.64 -0.98 0.41],4.84e-6,150); 
    plot(0:150,r)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [r]=armacov(C,A,s2,m) 
002  
003 % ARMACOV   Computes the covariance function for an AR- or ARMA-model. 
004 %   The process is governed by the system equation 
005 %     A(q) * x(t) = C(q) * sqrt(s2) * e(t)  
006 % 
007 % r = armacov(C,A,s2,n) 
008 % 
009 % r   = Covariance function 
010 % 
011 % C   = Coefficients in C-polynomials. [1 c_1 ... c_nc] 
012 % A   = Coefficients in A-polynomials. [1 a_1 ... a_na] 
013 % s2  = Innovation variance. 
014 % n+1 = Number of calculated values. 
015 % 
016 % Example: AR(2)-process. 
017 %   r = armacov(1,[1 1 0.9],1,50); 
018 %   plot(0:50,r) 
019 % Example: ARMA(4,2)-process. 
020 %   r = armacov([1 0.05 -0.88],[1 -2.06 1.64 -0.98 0.41],4.84e-6,150); 
021 %   plot(0:150,r) 
022  
023 % Copyright (c) 1997 by Pär Johannesson 
024 % Toolbox: Rainflow Cycles for Switching Processes V.1.0, 2-Oct-1997 
025  
026 p=length(A)-1; 
027 q=length(C)-1; 
028 n=max([p q]); 
029 A1temp=[A zeros(1,n-p)]'; 
030 C1temp=[C zeros(1,n-q)]'; 
031 A2temp=A1temp; 
032 A1=A1temp; 
033 A2=zeros(n+1,1); 
034 for i=2:n+1 
035    A1temp=[0;A1temp]; 
036    A2temp=[A2temp;0]; 
037    A1=[A1 A1temp(1:n+1,1)]; 
038    A2=[A2 A2temp(i:n+i,1)]; 
039 end 
040 A3=A1(1:q+1,1:q+1); 
041 C1=C1temp; 
042 for i=2:q+1 
043    C1temp=[C1temp;0]; 
044    C1=[C1 C1temp(i:n+i,1)]; 
045 end 
046 r=(inv(A1+A2)*C1*inv(A3)*C')'; 
047 if p>0 
048    for i=n+2:m+1 
049       r=[r -r(1,i-1:-1:i-p)*A(1,2:p+1)']; 
050    end 
051 else 
052    r=[r zeros(1,m-length(r)+1)]; 
053 end 
054 r=s2*r(1,1:m+1); 
055  
056  
057

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003