3.5.4. Two simple averaging models for decomposition. x = [xi, . . . , x„] . . . uniform sample vector of the time series x = {xt\tez} e = [ei, . . . , e„] . . . random errors t G {1,2,..., n} We are assuming both models: - additive: Xt = Trt + Szt + Ct + Et (AM) or - multiplicative: Xt = TrtSztCtEt (MM). Let d be the period length of Szt, and n = rad. We introduce a matrix m x d X : X\ ... X]^ ... X d Xd+1 ■ ■ ■ Xd+k ■ ■ ■ X2d lxJ,k\ where xhu = xy_i^d+k (e-g- j =yeari &=month). Let us denote as vec the operator rearranging columns of a matrix downwards into one column vector. Then we can write x = vec(XT). MATLAB: X = reshape(a;, d, m).' The j-row X(j,:) stands for samples from j-th cycle of Szt including Trt, C t and Et. The k-th column X(:,k) gathers samples which are at k-th position within each cycle, again including all components TVt,Ct and Et. Let E = [ehk\ be the matrix of errors defined alike. The seasonal component Szt is fully determined by its values in one cycle s := (si, . . . , Sd) '■= (Szi, . . . , Szd) with mean š si + - + sd d satisfying: T n ,7 A A/T (3.5.2) 0 v AM 1 v 16 MM We are going to find estimates sk fulfilling (3.5.2). 3.5.4.1. The small trend method [MATLAB: szsmtr] Assumptions: Trt + Ct, or TrtCt should be approximately constant within each cycle of Szť- AM: xj,k - Sk - eJtk = Trt + Ct ~ ..«j , . ... v in j-th pe- MM: xJik/(skeJik) = TrtCt riod, t = (j — l)d + k. Algorithm: (1) ŕhj = i X)fc=i Xj,k ■ ■ ■ estimate of rrij for j' = 1 (2) for k = 1, . . . , d we compute: AM: sk = ^Y.J=i{x3,k-m3) MM: sk sk + ej,k Em / ^ , = 1 x],k/m] 1 V-VÍTI It is easy to see that these estimates fulfil (3.5.2 AM: f = iEti(iEľ=iK*-^) 1 V-VÍTl i i MM: i / 1 1 — / ■ i t;------/ Xi k = — ra = 1. To be continued with the steps of 3.5.4.3. 17 3.5.4.2. Moving average method [MATLAB: szma] We introduce vector w = (w-q, . . . , wq) of equal weights for the common moving average filter: w = 1(1,1,..., 1)T for odd d = 2q + l, (2q+l)x w = i(l/2,l,...,l,l/2)T for even d = 2q. -------------------v------------------' (2q+l)x We start with the moving average operation: rat = < —'—i YJqr=-qwr^t+r for g + l