G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG13BDF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G13BDF calculates preliminary estimates of the parameters of a transfer function model.

## 2  Specification

 SUBROUTINE G13BDF ( R0, R, NL, NNA, S, NWDS, WA, IWA, WDS, ISF, IFAIL)
 INTEGER NL, NNA(3), NWDS, IWA, ISF(2), IFAIL REAL (KIND=nag_wp) R0, R(NL), S, WA(IWA), WDS(NWDS)

## 3  Description

G13BDF calculates estimates of parameters ${\delta }_{1},{\delta }_{2},\dots ,{\delta }_{p}$, ${\omega }_{0},{\omega }_{1},\dots ,{\omega }_{q}$ in the transfer function model
 $yt=δ1yt-1+δ2yt-2+⋯+δpyt-p+ω0xt-b-ω1xt-b-1-⋯-ωqxt-b-q$
given cross-correlations between the series ${x}_{t}$ and lagged values of ${y}_{t}$:
 $rxyl, l=0,1,…,L$
and the ratio of standard deviations ${s}_{y}/{s}_{x}$, as supplied by G13BCF.
It is assumed that the series ${x}_{t}$ used to calculate the cross-correlations is a sample from a time series with true autocorrelations of zero. Otherwise the cross-correlations between the series ${b}_{t}$ and ${a}_{t}$, as defined in the description of G13BAF, should be used in place of those between ${y}_{t}$ and ${x}_{t}$.
The estimates are obtained by solving for ${\delta }_{1},{\delta }_{2},\dots ,{\delta }_{p}$ the equations
 $rxyb+q+j=δ1rxyb+q+j-1+⋯+δprxyb+q+j-p, j=1,2,…,p$
then calculating
 $ωi = ± sy / sx rxy b+i - δ1 rxy b+i- 1 - ⋯ - δp rxy b+i-p , i= 0,1,…,q$
where the ‘$+$’ is used for ${\omega }_{0}$ and ‘$-$’ for ${\omega }_{i}$, $i>0$.
Any value of ${r}_{xy}\left(l\right)$ arising in these equations for $l is taken as zero. The parameters ${\delta }_{1},{\delta }_{2},\dots ,{\delta }_{p}$ are checked as to whether they satisfy the stability criterion.
Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day

## 5  Parameters

1:     R0 – REAL (KIND=nag_wp)Input
On entry: the cross-correlation between the two series at lag $0$, ${r}_{xy}\left(0\right)$.
Constraint: $-1.0\le {\mathbf{R0}}\le 1.0$.
2:     R(NL) – REAL (KIND=nag_wp) arrayInput
On entry: the cross-correlations between the two series at lags $1$ to $L$, ${r}_{xy}\left(\mathit{l}\right)$, for $\mathit{l}=1,2,\dots ,L$.
Constraint: $-1.0\le {\mathbf{R}}\left(\mathit{i}\right)\le 1.0$, for $\mathit{i}=1,2,\dots ,{\mathbf{NL}}$.
3:     NL – INTEGERInput
On entry: $L$, the number of lagged cross-correlations in the array R.
Constraint: ${\mathbf{NL}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NNA}}\left(1\right)+{\mathbf{NNA}}\left(2\right)+{\mathbf{NNA}}\left(3\right),1\right)$.
4:     NNA($3$) – INTEGER arrayInput
On entry: the transfer function model orders in the standard form $b,q,p$ (i.e., delay time, number of moving-average MA-like followed by number of autoregressive AR-like parameters).
Constraint: ${\mathbf{NNA}}\left(\mathit{i}\right)\ge 0$, for $\mathit{i}=1,2,3$.
5:     S – REAL (KIND=nag_wp)Input
On entry: the ratio of the standard deviation of the $y$ series to that of the $x$ series, ${s}_{y}/{s}_{x}$.
Constraint: ${\mathbf{S}}>0.0$.
6:     NWDS – INTEGERInput
On entry: the exact number of parameters in the transfer function model.
Constraint: ${\mathbf{NWDS}}={\mathbf{NNA}}\left(2\right)+{\mathbf{NNA}}\left(3\right)+1$.
7:     WA(IWA) – REAL (KIND=nag_wp) arrayWorkspace
8:     IWA – INTEGERInput
On entry: the dimension of the array WA as declared in the (sub)program from which G13BDF is called.
Constraint: ${\mathbf{IWA}}\ge {\mathbf{NNA}}\left(3\right)×\left({\mathbf{NNA}}\left(3\right)+1\right)$.
9:     WDS(NWDS) – REAL (KIND=nag_wp) arrayOutput
On exit: the preliminary estimates of the parameters of the transfer function model in the order of $q+1$ MA-like parameters followed by the $p$ AR-like parameters. If the estimation of either type of parameter fails then these parameters are set to $0.0$.
10:   ISF($2$) – INTEGER arrayOutput
On exit: indicators of the success of the estimation of MA-like and AR-like parameters respectively. A value $0$ indicates that there are no parameters of that type to be estimated. A value of $1$ or $-1$ indicates that there are parameters of that type in the model and the estimation of that type has been successful or unsuccessful respectively. Note that there is always at least one MA-like parameter in the model.
11:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{NNA}}\left(\mathit{i}\right)<0$, for $\mathit{i}=1,2,3$, or ${\mathbf{NL}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{NNA}}\left(1\right)+{\mathbf{NNA}}\left(2\right)+{\mathbf{NNA}}\left(3\right),1\right)$, or ${\mathbf{R0}}<-1.0$ or ${\mathbf{R0}}>1.0$, or ${\mathbf{R}}\left(i\right)<-1.0$ or ${\mathbf{R}}\left(i\right)>1.0$, for some $i=1,2,\dots ,{\mathbf{NL}}$, or ${\mathbf{S}}\le 0.0$, or ${\mathbf{NWDS}}\ne {\mathbf{NNA}}\left(2\right)+{\mathbf{NNA}}\left(3\right)+1$, or ${\mathbf{IWA}}<{\mathbf{NNA}}\left(3\right)×\left({\mathbf{NNA}}\left(3\right)+1\right)$.
${\mathbf{IFAIL}}=-999$
Internal memory allocation failed.

## 7  Accuracy

Equations used in the computations may become unstable, in which case results are reset to zero with array ISF values set accordingly.

If ${\mathbf{NNA}}\left(3\right)>0$,a local workspace array of fixed length is allocated internally by G13BDF. The total size of this array amounts to ${\mathbf{NNA}}\left(3\right)$ integer elements and ${\mathbf{NNA}}\left(3\right)×\left({\mathbf{NNA}}\left(3\right)+1\right)$ real elements.
The time taken by G13BDF is roughly proportional to ${{\mathbf{NWDS}}}^{3}$.

## 9  Example

This example reads the cross-correlations between two series at lags $0$ to $6$. It then reads a $\left(3,2,1\right)$ transfer function model and calculates and prints the preliminary estimates of the parameters of the model.

### 9.1  Program Text

Program Text (g13bdfe.f90)

### 9.2  Program Data

Program Data (g13bdfe.d)

### 9.3  Program Results

Program Results (g13bdfe.r)