NAG FL Interface
g13bbf (multi_​filter_​transf)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g13bbf filters a time series by a transfer function model.

2 Specification

Fortran Interface
Subroutine g13bbf ( y, ny, mr, nmr, par, npar, cy, wa, iwa, b, nb, ifail)
Integer, Intent (In) :: ny, mr(nmr), nmr, npar, iwa, nb
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: y(ny), par(npar), cy
Real (Kind=nag_wp), Intent (Out) :: wa(iwa), b(nb)
C Header Interface
#include <nag.h>
void  g13bbf_ (const double y[], const Integer *ny, const Integer mr[], const Integer *nmr, const double par[], const Integer *npar, const double *cy, double wa[], const Integer *iwa, double b[], const Integer *nb, Integer *ifail)
The routine may be called by the names g13bbf or nagf_tsa_multi_filter_transf.

3 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 g13baf, large transient errors may arise in the early values of bt due to ignorance of yt for t<0, and two possibilities are allowed.
  1. (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.
  2. (ii)The unknown values of yt for t0 are estimated by backforecasting exactly as for g13baf.

4 References

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

5 Arguments

1: y(ny) Real (Kind=nag_wp) array Input
On entry: 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=mr(6)+mr(9)×mr(10). 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: ny Integer Input
On entry: the total number of backforecasts and time series data points in array y.
Constraint: nymax(1+Qy,npar).
3: mr(nmr) Integer array Input
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 (b,q,p) as given in the G13 Chapter Introduction. Note that if the ARIMA model for the time series is supplied then the routine will assume that the first Qy values of the array y are backforecasts.
Constraints:
the filtering model is restricted in the following way:
  • mr(1), ​mr(2), ​mr(3)0.
the ARIMA model for the time series is restricted in the following ways:
  • mr(k)0, for k=4,5,,10;
  • if mr(10)=0, mr(7)+mr(8)+mr(9)=0;
  • if mr(10)0, mr(7)+mr(8)+mr(9)0;
  • mr(10)1.
4: nmr Integer Input
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: nmr=3 or 10.
5: par(npar) Real (Kind=nag_wp) array Input
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.
6: npar Integer Input
On entry: the total number of parameters held in array par.
Constraints:
  • if nmr=3, npar=mr(2)+mr(3)+1;
  • if nmr=10, npar=mr(2)+mr(3)+1+mr(4)+mr(6)+mr(7)+mr(9).
7: cy Real (Kind=nag_wp) Input
On entry: 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.
8: wa(iwa) Real (Kind=nag_wp) array Output
9: iwa Integer Input
These arguments are no longer accessed by g13bbf. Workspace is provided internally by dynamic allocation instead.
10: b(nb) Real (Kind=nag_wp) array Output
On exit: 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 y(t), then the filtered value at time t is held in b(t).
11: nb Integer Input
On entry: the dimension of the array b as declared in the (sub)program from which g13bbf 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, nbny;
  • if nmr=10, nbny+max(mr(1)+mr(2),mr(3)).
12: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, i=value, mr(i)=value.
Constraint: mr(i)0.
On entry, mr(10)=1.
Constraint: mr(10)1.
On entry, mr(7)=value, mr(8)=value and mr(9)=value.
Constraint: mr(7)+mr(8)+mr(9)=0.
On entry, mr(7)=value, mr(8)=value and mr(9)=value.
Constraint: mr(7)+mr(8)+mr(9)0.
On entry, nb=value and the minimum size required=value.
Constraint: if nmr=10 then nbmax(b,p,q), otherwise nbny.
On entry, nmr=value.
Constraint: nmr=3 or 10.
On entry, npar=value.
Constraint: npar must be inconsistent with mr.
ifail=2
A supplied model has invalid parameters.
ifail=3
The supplied time series is too short.
ifail=4
The matrix used to solve for starting values for MA is singular.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

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

8 Parallelism and Performance

g13bbf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13bbf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

If an ARIMA model is supplied, a local workspace array of fixed length is allocated internally by g13bbf. 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 g13bbf 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.

10 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 g13ajf . The backforecasts are inserted at the start of the series and g13bbf is called to perform the filtering.

10.1 Program Text

Program Text (g13bbfe.f90)

10.2 Program Data

Program Data (g13bbfe.d)

10.3 Program Results

Program Results (g13bbfe.r)