# NAG FL Interfaceg13bdf (multi_​transf_​prelim)

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine g13bdf ( r0, r, nl, nna, s, nwds, wa, iwa, wds, isf,
 Integer, Intent (In) :: nl, nna(3), nwds, iwa Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: isf(2) Real (Kind=nag_wp), Intent (In) :: r0, r(nl), s Real (Kind=nag_wp), Intent (Out) :: wa(iwa), wds(nwds)
C Header Interface
#include <nag.h>
 void g13bdf_ (const double *r0, const double r[], const Integer *nl, const Integer nna[], const double *s, const Integer *nwds, double wa[], const Integer *iwa, double wds[], Integer isf[], Integer *ifail)
The routine may be called by the names g13bdf or nagf_tsa_multi_transf_prelim.

## 3Description

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

## 5Arguments

1: $\mathbf{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: $\mathbf{r}\left({\mathbf{nl}}\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{nl}$Integer Input
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: $\mathbf{nna}\left(3\right)$Integer array Input
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: $\mathbf{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: $\mathbf{nwds}$Integer Input
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: $\mathbf{wa}\left({\mathbf{iwa}}\right)$Real (Kind=nag_wp) array Output
8: $\mathbf{iwa}$Integer Input
These arguments are no longer accessed by g13bdf. Workspace is provided internally by dynamic allocation instead.
9: $\mathbf{wds}\left({\mathbf{nwds}}\right)$Real (Kind=nag_wp) array Output
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$.
10: $\mathbf{isf}\left(2\right)$Integer array Output
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: $\mathbf{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 $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, $i=〈\mathit{\text{value}}〉$ and ${\mathbf{nna}}\left(i\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nna}}\left(i\right)\ge 0$.
On entry, $i=〈\mathit{\text{value}}〉$ and ${\mathbf{r}}\left(i\right)=〈\mathit{\text{value}}〉$.
Constraint: $-1.0\le {\mathbf{r}}\left(\mathit{i}\right)\le 1.0$.
On entry, ${\mathbf{nl}}=〈\mathit{\text{value}}〉$, ${\mathbf{nna}}\left(1\right)=〈\mathit{\text{value}}〉$, ${\mathbf{nna}}\left(2\right)=〈\mathit{\text{value}}〉$ and ${\mathbf{nna}}\left(3\right)=〈\mathit{\text{value}}〉$.
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)$.
On entry, ${\mathbf{nwds}}=〈\mathit{\text{value}}〉$, ${\mathbf{nna}}\left(2\right)=〈\mathit{\text{value}}〉$ and ${\mathbf{nna}}\left(3\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nwds}}={\mathbf{nna}}\left(2\right)+{\mathbf{nna}}\left(3\right)+1$.
On entry, ${\mathbf{r0}}=〈\mathit{\text{value}}〉$.
Constraint: $-1.0\le {\mathbf{r0}}\le 1.0$.
On entry, ${\mathbf{s}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{s}}>0.0$.
${\mathbf{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.
${\mathbf{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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

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

## 8Parallelism and Performance

g13bdf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13bdf 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.

## 9Further Comments

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

## 10Example

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.

### 10.1Program Text

Program Text (g13bdfe.f90)

### 10.2Program Data

Program Data (g13bdfe.d)

### 10.3Program Results

Program Results (g13bdfe.r)
{"ft_lang_label":"__label__en","ft_lang_prob":0.7566204,"math_prob":0.99952173,"size":6459,"snap":"2021-21-2021-25","text_gpt3_token_len":1585,"char_repetition_ratio":0.13323006,"word_repetition_ratio":0.09015639,"special_character_ratio":0.24276204,"punctuation_ratio":0.1592775,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9998047,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-20T00:34:18Z\",\"WARC-Record-ID\":\"<urn:uuid:b2a732d8-270c-4ec1-a8c5-7ce46f126e43>\",\"Content-Length\":\"45949\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a0c65fdf-b056-4b83-bc38-6f6738763535>\",\"WARC-Concurrent-To\":\"<urn:uuid:9a05294d-2662-4955-94bc-b578ce67e4c2>\",\"WARC-IP-Address\":\"78.129.168.4\",\"WARC-Target-URI\":\"https://www.nag.com/numeric/nl/nagdoc_27cpp/flhtml/g13/g13bdf.html\",\"WARC-Payload-Digest\":\"sha1:KXWI6J7CAGFT32EL3AMCJHA4RCRL5NFU\",\"WARC-Block-Digest\":\"sha1:MCXH25DF6JPRE7DVPHG55E5EBZCGBLZV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623487653461.74_warc_CC-MAIN-20210619233720-20210620023720-00230.warc.gz\"}"}