Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_tsa_multi_filter_transf (g13bb)

## 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${y}_{1},{y}_{2},\dots ,{y}_{n}$ a new series b1,b2,,bn${b}_{1},{b}_{2},\dots ,{b}_{n}$ 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. $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${b}_{t}$ due to ignorance of yt${y}_{t}$ for t < 0$t<0$, and two possibilities are allowed.
 (i) The equation (1) is applied from t = 1 + b + q, … ,n$t=1+b+q,\dots ,n$ so all terms in yt${y}_{t}$ on the right-hand side of (1) are known, the unknown set of values bt${b}_{t}$ for t = b + q, … ,b + q + 1 − p$t=b+q,\dots ,b+q+1-p$ being taken as zero. (ii) The unknown values of yt${y}_{t}$ for t ≤ 0$t\le 0$ 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:     y(ny) – double array
ny, the dimension of the array, must satisfy the constraint nymax (1 + Qy,npar)${\mathbf{ny}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1+{Q}_{y}^{\prime },{\mathbf{npar}}\right)$.
The Qy${Q}_{y}^{\prime }$ backforecasts starting with backforecast at time 1Qy$1-{Q}_{y}^{\prime }$ to backforecast at time 0$0$ followed by the time series starting at time 1$1$, where Qy = mr(6) + mr(9) × mr(10)${Q}_{y}^{\prime }={\mathbf{mr}}\left(6\right)+{\mathbf{mr}}\left(9\right)×{\mathbf{mr}}\left(10\right)$. 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:     mr(nmr) – int64int32nag_int array
nmr, the dimension of the array, must satisfy the constraint nmr = 3${\mathbf{nmr}}=3$ or 10$10$.
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)$\left(b,q,p\right)$ 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${Q}_{y}^{\prime }$ values of the array y are backforecasts.
Constraints:
the filtering model is restricted in the following way:
• mr(1), ​mr(2), ​mr(3)0${\mathbf{mr}}\left(1\right)\text{, ​}{\mathbf{mr}}\left(2\right)\text{, ​}{\mathbf{mr}}\left(3\right)\ge 0$.
the ARIMA model for the time series is restricted in the following ways:
• mr(k)0${\mathbf{mr}}\left(\mathit{k}\right)\ge 0$, for k = 4,5,,10$\mathit{k}=4,5,\dots ,10$;
• if mr(10) = 0${\mathbf{mr}}\left(10\right)=0$, mr(7) + mr(8) + mr(9) = 0${\mathbf{mr}}\left(7\right)+{\mathbf{mr}}\left(8\right)+{\mathbf{mr}}\left(9\right)=0$;
• if mr(10)0${\mathbf{mr}}\left(10\right)\ne 0$, mr(7) + mr(8) + mr(9)0${\mathbf{mr}}\left(7\right)+{\mathbf{mr}}\left(8\right)+{\mathbf{mr}}\left(9\right)\ne 0$;
• mr(10)1${\mathbf{mr}}\left(10\right)\ne 1$.
3:     par(npar) – double array
npar, the dimension of the array, must satisfy the constraint
• if nmr = 3${\mathbf{nmr}}=3$, npar = mr(2) + mr(3) + 1${\mathbf{npar}}={\mathbf{mr}}\left(2\right)+{\mathbf{mr}}\left(3\right)+1$;
• if nmr = 10${\mathbf{nmr}}=10$, npar = mr(2) + mr(3) + 1 + mr(4) + mr(6) + mr(7) + mr(9)${\mathbf{npar}}={\mathbf{mr}}\left(2\right)+{\mathbf{mr}}\left(3\right)+1+{\mathbf{mr}}\left(4\right)+{\mathbf{mr}}\left(6\right)+{\mathbf{mr}}\left(7\right)+{\mathbf{mr}}\left(9\right)$.
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${\mathbf{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${\mathbf{nmr}}=3$) then cy is not used.
5:     nb – int64int32nag_int scalar
The dimension of the array b as declared in the (sub)program from which nag_tsa_multi_filter_transf (g13bb) is called.
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${\mathbf{nmr}}=3$, nbny${\mathbf{nb}}\ge {\mathbf{ny}}$;
• if nmr = 10${\mathbf{nmr}}=10$, nbny + max (mr(1) + mr(2),mr(3))${\mathbf{nb}}\ge {\mathbf{ny}}+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{mr}}\left(1\right)+{\mathbf{mr}}\left(2\right),{\mathbf{mr}}\left(3\right)\right)$.

### 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: nymax (1 + Qy,npar)${\mathbf{ny}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1+{Q}_{y}^{\prime },{\mathbf{npar}}\right)$.
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$3$ if no ARIMA model for the time series is supplied but otherwise it takes the value 10$10$. Thus nmr acts as an indicator as to whether backforecasting can be carried out.
Constraint: nmr = 3${\mathbf{nmr}}=3$ or 10$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${\mathbf{nmr}}=3$, npar = mr(2) + mr(3) + 1${\mathbf{npar}}={\mathbf{mr}}\left(2\right)+{\mathbf{mr}}\left(3\right)+1$;
• if nmr = 10${\mathbf{nmr}}=10$, npar = mr(2) + mr(3) + 1 + mr(4) + mr(6) + mr(7) + mr(9)${\mathbf{npar}}={\mathbf{mr}}\left(2\right)+{\mathbf{mr}}\left(3\right)+1+{\mathbf{mr}}\left(4\right)+{\mathbf{mr}}\left(6\right)+{\mathbf{mr}}\left(7\right)+{\mathbf{mr}}\left(9\right)$.

wa iwa

### Output Parameters

1:     b(nb) – double array
The filtered output series. If the ARIMA model for the time series was known, and hence Qy${Q}_{y}^{\prime }$ backforecasts were supplied in y, then b contains Qy${Q}_{y}^{\prime }$ ‘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$t$ is held in y(t)${\mathbf{y}}\left(t\right)$, then the filtered value at time t$t$ is held in b(t)${\mathbf{b}}\left(t\right)$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{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${\mathbf{ifail}}=1$
 On entry, nmr ≠ 3${\mathbf{nmr}}\ne 3$ and nmr ≠ 10${\mathbf{nmr}}\ne 10$, or mr(i) < 0${\mathbf{mr}}\left(\mathit{i}\right)<0$, for i = 1,2, … ,nmr$\mathit{i}=1,2,\dots ,{\mathbf{nmr}}$, or nmr = 10${\mathbf{nmr}}=10$ and mr(10) = 1${\mathbf{mr}}\left(10\right)=1$, or nmr = 10${\mathbf{nmr}}=10$ and mr(10) = 0${\mathbf{mr}}\left(10\right)=0$ and mr(7) + mr(8) + mr(9) ≠ 0${\mathbf{mr}}\left(7\right)+{\mathbf{mr}}\left(8\right)+{\mathbf{mr}}\left(9\right)\ne 0$, or nmr = 10${\mathbf{nmr}}=10$ and mr(10) ≠ 0${\mathbf{mr}}\left(10\right)\ne 0$, and mr(7) + mr(8) + mr(9) = 0${\mathbf{mr}}\left(7\right)+{\mathbf{mr}}\left(8\right)+{\mathbf{mr}}\left(9\right)=0$, or npar is inconsistent with the contents of mr, or wa is too small, or b is too small.
ifail = 2${\mathbf{ifail}}=2$
A supplied model has parameter values which have failed the validity test.
ifail = 3${\mathbf{ifail}}=3$
The supplied time series is too short to carry out the requested filtering successfully.
ifail = 4${\mathbf{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 = 999${\mathbf{ifail}}=-999$
Internal 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.

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$K$ integer elements, where K$K$ is the expression defined in the description of the parameter 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

```function nag_tsa_multi_filter_transf_example
y = [5159.0292275785;
5165.856375167262;
4947.452842185773;
4729.825270337461;
4424.452756333954;
4072.462838586225;
3995.520293450913;
4142.712242307538;
4219.739771621216;
4452.071008250417;
4758.013111420425;
4834.637979606607;
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];
mr = [int64(0);13;12;1;1;0;0;1;1;12];
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;
0.62;
0.82];
cy = 0;
nb = int64(183);
[b, ifail] = nag_tsa_multi_filter_transf(y, mr, par, cy, nb)
```
```

b =

1.0e+03 *

4.5492
4.5509
4.5528
4.5549
4.5574
4.5607
4.5650
4.5711
4.5800
4.5935
4.6143
4.6471
4.6992
4.7822
4.5528
4.5504
4.5257
4.3248
4.2569
4.1697
4.1279
4.1546
4.0113
3.8787
3.7051
3.6191
3.6031
3.4961
3.4226
3.4635
3.3498
3.2621
3.2259
3.2181
3.1036
3.0235
2.9059
2.7585
2.8282
2.9584
2.9262
3.0198
3.0107
3.0828
3.1117
3.2863
3.2793
3.3244
3.4617
3.4683
3.7090
3.8396
4.0044
4.1463
4.2653
4.3446
4.4198
4.6472
4.8026
4.9995
5.4460
5.8610
5.8559
5.3107
5.2025
5.0466
4.8571
4.8123
4.7407
4.6311
4.4475
4.3177
4.0798
3.8337
3.6677
3.7748
3.7099
3.6485
3.6453
3.6198
3.5494
3.4392
3.2503
3.2092
3.0052
2.9124
2.9941
2.9479
3.1037
3.1681
3.2260
3.2241
3.2330
3.1192
2.9925
3.0148
2.7637
2.6713
2.6649
2.7782
2.8238
2.9890
3.0722
3.1321
3.3946
3.7174
4.1805
4.4059
4.6052
4.7330
4.8309
5.0308
5.0790
5.1250
5.2367
5.3927
5.3967
5.3007
5.3121
5.3366
5.3479
5.3312
5.3220
5.4448
5.4687
5.5329
5.5559
5.6034
5.4832
5.4068
5.2505
5.1719
5.2174
5.1623
5.2961
5.2682
5.2049
5.2907
5.5000
5.5523
5.5033
5.4192
5.3356
5.4476
5.4951
5.4751
5.6438
5.7131
5.6551
5.6919
5.9584
5.9590
5.8848
3.7147
5.8778
5.8141
6.0956
6.2107
6.5605
7.0139
7.1748
7.2308
7.7267
7.8800
7.9974
8.4285
8.2641
8.4431
8.6154
8.6446
0
0
0
0
0
0
0
0
0
0
0
0
0

ifail =

0

```
```function g13bb_example
y = [5159.0292275785;
5165.856375167262;
4947.452842185773;
4729.825270337461;
4424.452756333954;
4072.462838586225;
3995.520293450913;
4142.712242307538;
4219.739771621216;
4452.071008250417;
4758.013111420425;
4834.637979606607;
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];
mr = [int64(0);13;12;1;1;0;0;1;1;12];
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;
0.62;
0.82];
cy = 0;
nb = int64(183);
[b, ifail] = g13bb(y, mr, par, cy, nb)
```
```

b =

1.0e+03 *

4.5492
4.5509
4.5528
4.5549
4.5574
4.5607
4.5650
4.5711
4.5800
4.5935
4.6143
4.6471
4.6992
4.7822
4.5528
4.5504
4.5257
4.3248
4.2569
4.1697
4.1279
4.1546
4.0113
3.8787
3.7051
3.6191
3.6031
3.4961
3.4226
3.4635
3.3498
3.2621
3.2259
3.2181
3.1036
3.0235
2.9059
2.7585
2.8282
2.9584
2.9262
3.0198
3.0107
3.0828
3.1117
3.2863
3.2793
3.3244
3.4617
3.4683
3.7090
3.8396
4.0044
4.1463
4.2653
4.3446
4.4198
4.6472
4.8026
4.9995
5.4460
5.8610
5.8559
5.3107
5.2025
5.0466
4.8571
4.8123
4.7407
4.6311
4.4475
4.3177
4.0798
3.8337
3.6677
3.7748
3.7099
3.6485
3.6453
3.6198
3.5494
3.4392
3.2503
3.2092
3.0052
2.9124
2.9941
2.9479
3.1037
3.1681
3.2260
3.2241
3.2330
3.1192
2.9925
3.0148
2.7637
2.6713
2.6649
2.7782
2.8238
2.9890
3.0722
3.1321
3.3946
3.7174
4.1805
4.4059
4.6052
4.7330
4.8309
5.0308
5.0790
5.1250
5.2367
5.3927
5.3967
5.3007
5.3121
5.3366
5.3479
5.3312
5.3220
5.4448
5.4687
5.5329
5.5559
5.6034
5.4832
5.4068
5.2505
5.1719
5.2174
5.1623
5.2961
5.2682
5.2049
5.2907
5.5000
5.5523
5.5033
5.4192
5.3356
5.4476
5.4951
5.4751
5.6438
5.7131
5.6551
5.6919
5.9584
5.9590
5.8848
3.7147
5.8778
5.8141
6.0956
6.2107
6.5605
7.0139
7.1748
7.2308
7.7267
7.8800
7.9974
8.4285
8.2641
8.4431
8.6154
8.6446
0
0
0
0
0
0
0
0
0
0
0
0
0

ifail =

0

```