g13 Chapter Contents
g13 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_tsa_transf_prelim_fit (g13bdc)

## 1  Purpose

nag_tsa_transf_prelim_fit (g13bdc) calculates preliminary estimates of the parameters of a transfer function model.

## 2  Specification

 #include #include
 void nag_tsa_transf_prelim_fit (double r0, const double r[], Integer nl, Nag_TransfOrder *transfv, double s, double wds[], Integer isf[], NagError *fail)

## 3  Description

nag_tsa_transf_prelim_fit (g13bdc) 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 nag_tsa_cross_corr (g13bcc).
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 nag_tsa_arma_filter (g13bac), 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.

## 4  References

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

## 5  Arguments

1:     r0doubleInput
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]const doubleInput
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}=0,1,\dots ,{\mathbf{nl}}-1$.
3:     nlIntegerInput
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{transfv}}\mathbf{.}\mathbf{nag_b}+{\mathbf{transfv}}\mathbf{.}\mathbf{nag_q}+{\mathbf{transfv}}\mathbf{.}\mathbf{nag_p},1\right)$.
4:     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 $\left(b,q,p\right)$ as described in Section 2.3.1 in the g13 Chapter Introduction.
Constraints:
• ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_b}\ge 0$;
• ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_q}\ge 0$;
• ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_p}\ge 0$.
5:     sdoubleInput
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:     wds[$\mathit{dim}$]doubleOutput
Note: the dimension, dim, of the array wds must be at least $\left({\mathbf{transfv}}\mathbf{.}\mathbf{nag_q}+{\mathbf{transfv}}\mathbf{.}\mathbf{nag_p}+1\right)$.
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 arguments are set to $0.0$.
7:     isf[$2$]IntegerOutput
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.
8:     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.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_CONSTRAINT
On entry, ${\mathbf{transfv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_b}\ge 0$.
On entry, ${\mathbf{transfv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_p}\ge 0$.
On entry, ${\mathbf{transfv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_q}\ge 0$.
NE_INT_4
On entry, ${\mathbf{nl}}=〈\mathit{\text{value}}〉$, ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_b}=〈\mathit{\text{value}}〉$, ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_q}=〈\mathit{\text{value}}〉$ and ${\mathbf{transfv}}\mathbf{.}\mathbf{nag_p}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nl}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{transfv}}\mathbf{.}\mathbf{nag_b}+{\mathbf{transfv}}\mathbf{.}\mathbf{nag_q}+{\mathbf{transfv}}\mathbf{.}\mathbf{nag_p},1\right)$.
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_REAL
On entry, r0 lies outside $\left[-1.0,1.0\right]$: ${\mathbf{r0}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{s}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{s}}>0.0$.
NE_REAL_ARRAY_ELEM_CONS
On entry, ${\mathbf{r}}\left[i-1\right]$ lies outside $\left[-1.0,1.0\right]$: $i=〈\mathit{\text{value}}〉$ and ${\mathbf{r}}\left[i-1\right]=〈\mathit{\text{value}}〉$.

## 7  Accuracy

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

The time taken by nag_tsa_transf_prelim_fit (g13bdc) is roughly proportional to ${\left({\mathbf{transfv}}\mathbf{.}\mathbf{nag_q}+{\mathbf{transfv}}\mathbf{.}\mathbf{nag_p}+1\right)}^{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 (g13bdce.c)

### 9.2  Program Data

Program Data (g13bdce.d)

### 9.3  Program Results

Program Results (g13bdce.r)