hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_tsa_multi_filter_transf (g13bb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_tsa_multi_filter_transf (g13bb) filters a time series by a transfer function model.

Syntax

[b, ifail] = g13bb(y, mr, par, cy, nb, 'ny', ny, 'nmr', nmr, 'npar', npar)
[b, ifail] = nag_tsa_multi_filter_transf(y, mr, par, cy, nb, 'ny', ny, 'nmr', nmr, 'npar', npar)

Description

From a given series y1,y2,,yn a new series b1,b2,,bn is calculated using a supplied (filtering) transfer function model according to the equation
bt=δ1bt-1+δ2bt-2++δpbt-p+ω0yt-b-ω1yt-b-1--ωqyt-b-q. (1)
As in the use of nag_tsa_multi_filter_arima (g13ba), large transient errors may arise in the early values of bt due to ignorance of yt for t<0, and two possibilities are allowed.
(i) The equation (1) is applied from t=1+b+q,,n so all terms in yt on the right-hand side of (1) are known, the unknown set of values bt for t=b+q,,b+q+1-p being taken as zero.
(ii) The unknown values of yt for t0 are estimated by backforecasting exactly as for nag_tsa_multi_filter_arima (g13ba).

References

Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day

Parameters

Compulsory Input Parameters

1:     yny – double array
The Qy backforecasts starting with backforecast at time 1-Qy to backforecast at time 0 followed by the time series starting at time 1, where Qy=mr6+mr9×mr10. If there are no backforecasts either because the ARIMA model for the time series is not known or because it is known but has no moving average terms, then the time series starts at the beginning of y.
2:     mrnmr int64int32nag_int array
The orders vector for the filtering transfer function model followed by the orders vector for the ARIMA model for the time series if the latter is known. The transfer function model orders appear in the standard form b,q,p as given in the G13 Chapter Introduction. Note that if the ARIMA model for the time series is supplied then the function will assume that the first Qy values of the array y are backforecasts.
Constraints:
the filtering model is restricted in the following way:
  • mr1, ​mr2, ​mr30.
the ARIMA model for the time series is restricted in the following ways:
  • mrk0, for k=4,5,,10;
  • if mr10=0, mr7+mr8+mr9=0;
  • if mr100, mr7+mr8+mr90;
  • mr101.
3:     parnpar – double array
The parameters of the filtering transfer function model followed by the parameters of the ARIMA model for the time series. In the transfer function model the parameters are in the standard order of MA-like followed by AR-like operator parameters. In the ARIMA model the parameters are in the standard order of non-seasonal AR and MA followed by seasonal AR and MA.
4:     cy – double scalar
If the ARIMA model is known (i.e., nmr=10), cy must specify the constant term of the ARIMA model for the time series. If this model is not known (i.e., nmr=3) then cy is not used.
5:     nb int64int32nag_int scalar
The dimension of the array b.
In addition to holding the returned filtered series, b is also used as an intermediate work array if the ARIMA model for the time series is known.
Constraints:
  • if nmr=3, nbny;
  • if nmr=10, nbny+maxmr1+mr2,mr3.

Optional Input Parameters

1:     ny int64int32nag_int scalar
Default: the dimension of the array y.
The total number of backforecasts and time series data points in array y.
Constraint: nymax1+Qy,npar.
2:     nmr int64int32nag_int scalar
Default: the dimension of the array mr.
The number of values supplied in the array mr. It takes the value 3 if no ARIMA model for the time series is supplied but otherwise it takes the value 10. Thus nmr acts as an indicator as to whether backforecasting can be carried out.
Constraint: nmr=3 or 10.
3:     npar int64int32nag_int scalar
Default: the dimension of the array par.
The total number of parameters held in array par.
Constraints:
  • if nmr=3, npar=mr2+mr3+1;
  • if nmr=10, npar=mr2+mr3+1+mr4+mr6+mr7+mr9.

Output Parameters

1:     bnb – double array
The filtered output series. If the ARIMA model for the time series was known, and hence Qy backforecasts were supplied in y, then b contains Qy ‘filtered’ backforecasts followed by the filtered series. Otherwise, the filtered series begins at the start of b just as the original series began at the start of y. In either case, if the value of the series at time t is held in yt, then the filtered value at time t is held in bt.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,nmr3 and nmr10,
ormri<0, for i=1,2,,nmr,
ornmr=10 and mr10=1,
ornmr=10 and mr10=0 and mr7+mr8+mr90,
ornmr=10 and mr100, and mr7+mr8+mr9=0,
ornpar is inconsistent with the contents of mr,
orwa is too small,
orb is too small.
   ifail=2
A supplied model has parameter values which have failed the validity test.
   ifail=3
The supplied time series is too short to carry out the requested filtering successfully.
   ifail=4
This only occurs when an ARIMA model for the time series has been supplied. The matrix which is used to solve for the starting values for MA filtering is singular.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Accuracy and stability are high except when the AR-like parameters are close to the invertibility boundary. All calculations are performed in basic precision except for one inner product type calculation which on machines of low precision is performed in additional precision.

Further Comments

If an ARIMA model is supplied, a local workspace array of fixed length is allocated internally by nag_tsa_multi_filter_transf (g13bb). The total size of this array amounts to K integer elements, where K is the expression defined in the description of the argument wa.
The time taken by nag_tsa_multi_filter_transf (g13bb) is roughly proportional to the product of the length of the series and number of parameters in the filtering model with appreciable increase if an ARIMA model is supplied for the time series.

Example

This example reads a time series of length 296. It reads one univariate ARIMA 1,1,0,0,1,1,12 model for the series and the 0,13,12 filtering transfer function model. 12 initial backforecasts are required and these are calculated by a call to nag_tsa_uni_arima_forcecast (g13aj) . The backforecasts are inserted at the start of the series and nag_tsa_multi_filter_transf (g13bb) is called to perform the filtering.
function g13bb_example


fprintf('g13bb example results\n\n');

% orders
mrx  = [int64(1);1;0;0;1;1;12];
nbf = mrx(3) + mrx(6)*mrx(7);

% Data
nx  = 158;
ny  = nx + nbf;
y   = zeros(ny,1);
y(nbf+1:ny) = ...
    [
     5312; 5402; 4960; 4717; 4383; 3828; 3665; 3718; 3744; 3994;
     4150; 4064; 4324; 4256; 3986; 3670; 3292; 2952; 2765; 2813;
     2850; 3085; 3256; 3213; 3514; 3386; 3205; 3124; 2804; 2536;
     2445; 2649; 2761; 3183; 3456; 3529; 4067; 4079; 4082; 4029;
     3887; 3684; 3707; 3923; 4068; 4557; 4975; 5197; 6054; 6471;
     6277; 5529; 5059; 4539; 4236; 4305; 4299; 4478; 4561; 4470;
     4712; 4512; 4129; 3942; 3572; 3149; 3026; 3141; 3145; 3322;
     3384; 3373; 3630; 3555; 3413; 3127; 2966; 2685; 2642; 2789;
     2867; 3032; 3125; 3176; 3359; 3265; 3053; 2915; 2690; 2518;
     2523; 2737; 3074; 3671; 4355; 4648; 5232; 5349; 5228; 5172;
     4932; 4637; 4642; 4930; 5033; 5223; 5482; 5560; 5960; 5929;
     5697; 5583; 5316; 5039; 4972; 5169; 5138; 5316; 5409; 5375;
     5803; 5736; 5643; 5416; 5059; 4810; 4937; 5166; 5187; 5348;
     5483; 5626; 6077; 6033; 5996; 5860; 5499; 5210; 5421; 5609;
     5586; 3663; 5829; 6005; 6693; 6792; 6966; 7227; 7089; 6823;
     7286; 7621; 7758; 8000; 8393; 8592; 9186; 9175];

% parameter estimates
parx = [0.62;  0.82];
cx   = 0;

% Get back forecasts
x(nx:-1:1) = y(nbf+1:nbf+nx);

cx  = 0;
kfc = int64(1);
ist = mrx(4) + mrx(7) + mrx(2) + mrx(5) + mrx(3) + max(mrx(1),mrx(6)*mrx(7));
ifv = int64(nbf);

% Apply ARIMA model
[rms, st, nst, fva, fsd, isf, ifail] = ...
  g13aj( ...
         mrx, parx, cx, kfc, x, ist, ifv, ifv);

% Put back forecasts at start of y
y(1:nbf) = fva(nbf:-1:1);

% Add filter model orders and params to start
mr  = [int64(0); 13; 12; mrx];
par = [ 1.0131;  0.0806; -0.015;  -0.015;  -0.015;
       -0.015;  -0.015;  -0.015;  -0.015;  -0.015;
       -0.015;  -0.015;   0.9981; -0.0956;  0;
        0;       0;       0;       0;       0;   
        0;       0;       0;       0;       0;
        0.82;    parx];
cy  = cx;
nb = int64(ny+13);

[b, ifail] = g13bb( ... 
                    y, mr, par, cy, nb);

% Display results
fprintf('                 Original        Filtered\n');
fprintf('Backforecasts    y-series         series\n');
ival = double([-nbf:-1]');
fprintf('%8d%17.1f%15.1f\n', [ival y(1:nbf) b(1:nbf)]');
fprintf('\n%16s%16s%16s%16s\n','Filtered','Filtered','Filtered','Filtered');
fprintf('%15s%16s%16s%16s\n',  'series',  'series',  'series',  'series');
ivar = double([1:nx]');
result = [ivar b(nbf+1:ny)];
for j = 1:4:nx
  fprintf('%7d%9.1f', result(j:min(j+3,nx),:)');
  fprintf('\n');
end


g13bb example results

                 Original        Filtered
Backforecasts    y-series         series
     -12           5159.0         4549.2
     -11           5165.9         4550.9
     -10           4947.5         4552.8
      -9           4729.8         4554.9
      -8           4424.5         4557.4
      -7           4072.5         4560.7
      -6           3995.5         4565.0
      -5           4142.7         4571.1
      -4           4219.7         4580.0
      -3           4452.1         4593.5
      -2           4758.0         4614.3
      -1           4834.6         4647.1

        Filtered        Filtered        Filtered        Filtered
         series          series          series          series
      1   4699.2      2   4782.2      3   4552.8      4   4550.4
      5   4525.7      6   4324.8      7   4256.9      8   4169.7
      9   4127.9     10   4154.6     11   4011.3     12   3878.7
     13   3705.1     14   3619.1     15   3603.1     16   3496.1
     17   3422.6     18   3463.5     19   3349.8     20   3262.1
     21   3225.9     22   3218.1     23   3103.6     24   3023.5
     25   2905.9     26   2758.5     27   2828.2     28   2958.4
     29   2926.2     30   3019.8     31   3010.7     32   3082.8
     33   3111.7     34   3286.3     35   3279.3     36   3324.4
     37   3461.7     38   3468.3     39   3709.0     40   3839.6
     41   4004.4     42   4146.3     43   4265.3     44   4344.6
     45   4419.8     46   4647.2     47   4802.6     48   4999.5
     49   5446.0     50   5861.0     51   5855.9     52   5310.7
     53   5202.5     54   5046.6     55   4857.1     56   4812.3
     57   4740.7     58   4631.1     59   4447.5     60   4317.7
     61   4079.8     62   3833.7     63   3667.7     64   3774.8
     65   3709.9     66   3648.5     67   3645.3     68   3619.8
     69   3549.4     70   3439.2     71   3250.3     72   3209.2
     73   3005.2     74   2912.4     75   2994.1     76   2947.9
     77   3103.7     78   3168.1     79   3226.0     80   3224.1
     81   3233.0     82   3119.2     83   2992.5     84   3014.8
     85   2763.7     86   2671.3     87   2664.9     88   2778.2
     89   2823.8     90   2989.0     91   3072.2     92   3132.1
     93   3394.6     94   3717.4     95   4180.5     96   4405.9
     97   4605.2     98   4733.0     99   4830.9    100   5030.8
    101   5079.0    102   5125.0    103   5236.7    104   5392.7
    105   5396.7    106   5300.7    107   5312.1    108   5336.6
    109   5347.9    110   5331.2    111   5322.0    112   5444.8
    113   5468.7    114   5532.9    115   5555.9    116   5603.4
    117   5483.2    118   5406.8    119   5250.5    120   5171.9
    121   5217.4    122   5162.3    123   5296.1    124   5268.2
    125   5204.9    126   5290.7    127   5500.0    128   5552.3
    129   5503.3    130   5419.2    131   5335.6    132   5447.6
    133   5495.1    134   5475.1    135   5643.8    136   5713.1
    137   5655.1    138   5691.9    139   5958.4    140   5959.0
    141   5884.8    142   3714.7    143   5877.8    144   5814.1
    145   6095.6    146   6210.7    147   6560.5    148   7013.9
    149   7174.8    150   7230.8    151   7726.7    152   7880.0
    153   7997.4    154   8428.5    155   8264.1    156   8443.1
    157   8615.4    158   8644.6

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015