nag_tsa_transf_filter (g13bbc) (PDF version)
g13 Chapter Contents
g13 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_tsa_transf_filter (g13bbc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_tsa_transf_filter (g13bbc) filters a time series by a transfer function model.

2  Specification

#include <nag.h>
#include <nagg13.h>
void  nag_tsa_transf_filter (const double y[], Integer ny, Nag_TransfOrder *transfv, Nag_ArimaOrder *arimas, const double par[], Integer npar, double cy, double b[], Integer nb, NagError *fail)

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 nag_tsa_arma_filter (g13bac), 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_arma_filter (g13bac).

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]const doubleInput
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=arimas.q+arimas.bigq×arimas.s. 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:     nyIntegerInput
On entry: the total number of backforecasts and time series data points in array y.
Constraint: nymax1+Qy,npar.
3:     transfvNag_TransfOrder *Input
On entry: the orders of the transfer function model where the triplet (transfv. nag_b, transfv. nag_q, transfv. nag_p) corresponds to the triplet b,q,p as described in Section 2.3.1 in the g13 Chapter Introduction.
Constraints:
  • transfv.nag_b0 ;
  • transfv.nag_q0 ;
  • transfv.nag_p0 .
4:     arimasNag_ArimaOrder *Input
On entry: if available, the orders for the filtering ARIMA model for the time series as a pointer to structure of type Nag_ArimaOrder with the following members:
pInteger
dIntegerInput
qIntegerInput
bigpIntegerInput
bigdIntegerInput
bigqIntegerInput
sIntegerInput
On entry: these seven members of arimas must specify the orders vector p,d,q,P,D,Q,s, respectively, of the ARIMA model for the output noise component.
p, q, P and Q refer, respectively, to the number of autoregressive (ϕ), moving average (θ), seasonal autoregressive (Φ) and seasonal moving average (Θ) parameters.
d, D and s refer, respectively, to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.
If no ARIMA model for the series is to be supplied arimas should be set to a NULL pointer.
Constraints:
  • arimas.p0 ;
  • arimas.d0 ;
  • arimas.q0 ;
  • arimas.bigp0 ;
  • arimas.bigd0 ;
  • arimas.bigq0 ;
  • arimas.s0 ;
  • arimas.s1 ;
  • if arimas.s=0, arimas.bigp+arimas.bigd+arimas.bigq=0 ;
  • if arimas.s0, arimas.bigp+arimas.bigd+arimas.bigq0 .
5:     par[npar]const doubleInput
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:     nparIntegerInput
On entry: the total number of parameters held in array par.
Constraints:
  • if arimas is not NULL, npar=transfv.nag_q+transfv.nag_p+1 ;
  • if arimas is NULL, npar=transfv.nag_q+transfv.nag_p+1+arimas.p+ arimas.q+arimas.bigp+arimas.bigq .
7:     cydoubleInput
On entry: if the ARIMA model is known (i.e., arimas is NULL), cy must specify the constant term of the ARIMA model for the time series. If this model is not known (i.e., arimas is not NULL) then cy is not used.
8:     b[nb]doubleOutput
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-1], then the filtered value at time t is held in b[t-1].
9:     nbIntegerInput
On entry: 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 arimas is not NULL, nbny;
  • if arimas is NULL, nbny+maxtransfv.nag_b+transfv.nag_q,transfv.nag_p.
10:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_ARRAY_SIZE
The array b is too small. Minimum required size: value.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_CONSTRAINT
On entry, arimas=value.
Constraint: arimas.bigd0 .
On entry, arimas=value.
Constraint: arimas.bigp0 .
On entry, arimas=value.
Constraint: arimas.bigq0 .
On entry, arimas=value.
Constraint: arimas.d0 .
On entry, arimas=value.
Constraint: arimas.p0 .
On entry, arimas=value.
Constraint: arimas.q0 .
On entry, arimas=value.
Constraint: arimas.s1 .
On entry, arimas=value.
Constraint: arimas.s0 .
On entry, arimas=value.
Constraint: if arimas.s=0, arimas.bigp+arimas.bigd+arimas.bigq=0 .
On entry, arimas=value.
Constraint: if arimas.s0, arimas.bigp+arimas.bigd+arimas.bigq0 .
On entry, transfv=value.
Constraint: transfv.nag_b0 .
On entry, transfv=value.
Constraint: transfv.nag_p0 .
On entry, transfv=value.
Constraint: transfv.nag_q0 .
NE_INT
On entry, npar is inconsistent with transfv and arimas: npar=value.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_MODEL_PARAMS
A supplied model has invalid parameters.
NE_SINGULAR
The matrix used to solve for starting values for MA is singular.
NE_TIME_SERIES
The supplied time series is too short.

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  Further Comments

If an ARIMA model is supplied, local workspace arrays of fixed lengths are allocated internally by nag_tsa_transf_filter (g13bbc). The total size of these arrays amounts to K Integer elements and K×K+2 double elements, where K=transfv.nag_p+arimas.p+arimas.d+arimas.bigp+arimas.bigd×arimas.s.
The time taken by nag_tsa_transf_filter (g13bbc) 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.

9  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_multi_inp_model_forecast (g13bjc). The backforecasts are inserted at the start of the series and nag_tsa_transf_filter (g13bbc) is called to perform the filtering.

9.1  Program Text

Program Text (g13bbce.c)

9.2  Program Data

Program Data (g13bbce.d)

9.3  Program Results

Program Results (g13bbce.r)


nag_tsa_transf_filter (g13bbc) (PDF version)
g13 Chapter Contents
g13 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012