﻿ g13bb Method
g13bb filters a time series by a transfer function model.

# Syntax

C#
```public static void g13bb(
double[] y,
int ny,
int[] mr,
int nmr,
double[] par,
double cy,
double[] b,
out int ifail
)```
Visual Basic
```Public Shared Sub g13bb ( _
y As Double(), _
ny As Integer, _
mr As Integer(), _
nmr As Integer, _
par As Double(), _
cy As Double, _
b As Double(), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g13bb(
array<double>^ y,
int ny,
array<int>^ mr,
int nmr,
array<double>^ par,
double cy,
array<double>^ b,
[OutAttribute] int% ifail
)```
F#
```static member g13bb :
y : float[] *
ny : int *
mr : int[] *
nmr : int *
par : float[] *
cy : float *
b : float[] *
ifail : int byref -> unit
```

#### Parameters

y
Type: array<System..::..Double>[]()[][]
An array of size [ny]
On entry: the ${Q}_{y}^{\prime }$ backforecasts starting with backforecast at time $1-{Q}_{y}^{\prime }$ to backforecast at time $0$ followed by the time series starting at time $1$, where ${Q}_{y}^{\prime }={\mathbf{mr}}\left[5\right]+{\mathbf{mr}}\left[8\right]×{\mathbf{mr}}\left[9\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.
ny
Type: System..::..Int32
On entry: the total number of backforecasts and time series data points in array y.
Constraint: ${\mathbf{ny}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1+{Q}_{y}^{\prime },\mathbf{_npar}\right)$.
mr
Type: array<System..::..Int32>[]()[][]
An array of size [nmr]
On entry: 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 $\left(b,q,p\right)$ as given in the G13 class. Note that if the ARIMA model for the time series is supplied then the method will assume that the first ${Q}_{y}^{\prime }$ values of the array y are backforecasts.
Constraints:
the filtering model is restricted in the following way:
• ${\mathbf{mr}}\left[0\right]\text{, ​}{\mathbf{mr}}\left[1\right]\text{, ​}{\mathbf{mr}}\left[2\right]\ge 0$.
the ARIMA model for the time series is restricted in the following ways:
• ${\mathbf{mr}}\left[\mathit{k}\right]\ge 0$, for $\mathit{k}=3,4,\dots ,9$;
• if ${\mathbf{mr}}\left[9\right]=0$, ${\mathbf{mr}}\left[6\right]+{\mathbf{mr}}\left[7\right]+{\mathbf{mr}}\left[8\right]=0$;
• if ${\mathbf{mr}}\left[9\right]\ne 0$, ${\mathbf{mr}}\left[6\right]+{\mathbf{mr}}\left[7\right]+{\mathbf{mr}}\left[8\right]\ne 0$;
• ${\mathbf{mr}}\left[9\right]\ne 1$.
nmr
Type: System..::..Int32
On entry: 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: ${\mathbf{nmr}}=3$ or $10$.
par
Type: array<System..::..Double>[]()[][]
An array of size [dim1]
Note: dim1 must satisfy the constraint:
• if ${\mathbf{nmr}}=3$, $\mathbf{_npar}=\mathbf{_transfv}.\text{nag_q}+\mathbf{_transfv}.\text{nag_p}+1$;
• if ${\mathbf{nmr}}=10$, $\mathbf{_npar}=\mathbf{_transfv}.\text{nag_q}+\mathbf{_transfv}.\text{nag_p}+1+\mathbf{_arimas}.\text{p}+\phantom{\rule{0ex}{0ex}}\mathbf{_arimas}.\text{q}+\mathbf{_arimas}.\text{bigp}+\mathbf{_arimas}.\text{bigq}$.
• if ${\mathbf{nmr}}=3$, $\mathbf{_npar}={\mathbf{mr}}\left[1\right]+{\mathbf{mr}}\left[2\right]+1$;
• if ${\mathbf{nmr}}=10$, $\mathbf{_npar}={\mathbf{mr}}\left[1\right]+{\mathbf{mr}}\left[2\right]+1+{\mathbf{mr}}\left[3\right]+{\mathbf{mr}}\left[5\right]+{\mathbf{mr}}\left[6\right]+{\mathbf{mr}}\left[8\right]$.
On entry: 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.
cy
Type: System..::..Double
On entry: if the ARIMA model is known (i.e., ${\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., ${\mathbf{nmr}}=3$) then cy is not used.
b
Type: array<System..::..Double>[]()[][]
An array of size [nb]
On exit: the filtered output series. If the ARIMA model for the time series was known, and hence ${Q}_{y}^{\prime }$ backforecasts were supplied in y, then b contains ${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$ is held in ${\mathbf{y}}\left[t-1\right]$, then the filtered value at time $t$ is held in ${\mathbf{b}}\left[t-1\right]$.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

From a given series ${y}_{1},{y}_{2},\dots ,{y}_{n}$ a new series ${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.$ (1)
As in the use of g13ba, large transient errors may arise in the early values of ${b}_{t}$ due to ignorance of ${y}_{t}$ for $t<0$, and two possibilities are allowed.
 (i) The equation (1) is applied from $t=1+b+q,\dots ,n$ so all terms in ${y}_{t}$ on the right-hand side of (1) are known, the unknown set of values ${b}_{t}$ for $t=b+q,\dots ,b+q+1-p$ being taken as zero. (ii) The unknown values of ${y}_{t}$ for $t\le 0$ are estimated by backforecasting exactly as for g13ba.

# References

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

# Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (NPAR) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{nmr}}\ne 3$ and ${\mathbf{nmr}}\ne 10$, or ${\mathbf{mr}}\left[\mathit{i}-1\right]<0$, for $\mathit{i}=1,2,\dots ,{\mathbf{nmr}}$, or ${\mathbf{nmr}}=10$ and ${\mathbf{mr}}\left[9\right]=1$, or ${\mathbf{nmr}}=10$ and ${\mathbf{mr}}\left[9\right]=0$ and ${\mathbf{mr}}\left[6\right]+{\mathbf{mr}}\left[7\right]+{\mathbf{mr}}\left[8\right]\ne 0$, or ${\mathbf{nmr}}=10$ and ${\mathbf{mr}}\left[9\right]\ne 0$, and ${\mathbf{mr}}\left[6\right]+{\mathbf{mr}}\left[7\right]+{\mathbf{mr}}\left[8\right]=0$, or wa is too small, or b is too small.
${\mathbf{ifail}}=2$
A supplied model has parameter values which have failed the validity test.
${\mathbf{ifail}}=3$
The supplied time series is too short to carry out the requested filtering successfully.
${\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.
${\mathbf{ifail}}=-999$
Internal memory allocation failed.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

# 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.

# Parallelism and Performance

None.

The time taken by 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 $\left(1,1,0,0,1,1,12\right)$ model for the series and the $\left(0,13,12\right)$ filtering transfer function model. $12$ initial backforecasts are required and these are calculated by a call to g13aj . The backforecasts are inserted at the start of the series and g13bb is called to perform the filtering.

Example program (C#): g13bbe.cs

Example program data: g13bbe.d

Example program results: g13bbe.r