Calculates adaptive autoregressive (AAR) and adaptive autoregressive moving average estimates (AARMA)
 of real-valued data series using Kalman filter algorithm.
 [a,e,REV] = aar(y, mode, MOP, UC, a0, A, W, V); 

 The AAR process is described as following  
       y(k) - a(k,1)*y(t-1) -...- a(k,p)*y(t-p) = e(k);
 The AARMA process is described as following  
       y(k) - a(k,1)*y(t-1) -...- a(k,p)*y(t-p) = e(k) + b(k,1)*e(t-1) + ... + b(k,q)*e(t-q);

 Input:
       y       Signal (AR-Process)
       Mode    is a two-element vector [aMode, vMode], 
               aMode determines 1 (out of 12) methods for updating the co-variance matrix (see also [1])
               vMode determines 1 (out of 7) methods for estimating the innovation variance (see also [1])
               aMode=1, vmode=2 is the RLS algorithm as used in [2]
               aMode=-1, LMS algorithm (signal normalized)
               aMode=-2, LMS algorithm with adaptive normalization  
                                     
       MOP     model order, default [10,0] 
               MOP=[p]         AAR(p) model. p AR parameters
               MOP=[p,q]       AARMA(p,q) model, p AR parameters and q MA coefficients
       UC      Update Coefficient, default 0
       a0      Initial AAR parameters [a(0,1), a(0,2), ..., a(0,p),b(0,1),b(0,2), ..., b(0,q)]
                (row vector with p+q elements, default zeros(1,p) )
       A       Initial Covariance matrix (positive definite pxp-matrix, default eye(p))
	W	system noise (required for aMode==0)
	V	observation noise (required for vMode==0)
      
 Output:
       a       AAR(MA) estimates [a(k,1), a(k,2), ..., a(k,p),b(k,1),b(k,2), ..., b(k,q]
       e       error process (Adaptively filtered process)
       REV     relative error variance MSE/MSY


 Hint:
 The mean square (prediction) error of different variants is useful for determining the free parameters (Mode, MOP, UC) 

 REFERENCE(S): 
 [1] A. Schloegl (2000), The electroencephalogram and the adaptive autoregressive model: theory and applications. 
     ISBN 3-8265-7640-3 Shaker Verlag, Aachen, Germany. 

 More references can be found at 
     http://pub.ist.ac.at/~schloegl/publications/

Package: tsa