g13bj produces forecasts of a time series (the output series) which depends on one or more other (input) series via a previously estimated multi-input model for which the state set information is not available. The future values of the input series must be supplied. In contrast with (G13BHF not in this release) the original past values of the input and output series are required. Standard errors of the forecasts are produced. If future values of some of the input series have been obtained as forecasts using ARIMA models for those series, this may be allowed for in the calculation of the standard errors.

# Syntax

C# |
---|

public static void g13bj( int[] mr, int nser, int[,] mt, double[] para, int npara, int kfc, int nev, int nfv, double[,] xxy, int kzef, double[] rmsxy, int[,] mrx, double[,] parx, double[] fva, double[] fsd, double[] sttf, out int nsttf, out int ifail ) |

Visual Basic |
---|

Public Shared Sub g13bj ( _ mr As Integer(), _ nser As Integer, _ mt As Integer(,), _ para As Double(), _ npara As Integer, _ kfc As Integer, _ nev As Integer, _ nfv As Integer, _ xxy As Double(,), _ kzef As Integer, _ rmsxy As Double(), _ mrx As Integer(,), _ parx As Double(,), _ fva As Double(), _ fsd As Double(), _ sttf As Double(), _ <OutAttribute> ByRef nsttf As Integer, _ <OutAttribute> ByRef ifail As Integer _ ) |

Visual C++ |
---|

public: static void g13bj( array<int>^ mr, int nser, array<int,2>^ mt, array<double>^ para, int npara, int kfc, int nev, int nfv, array<double,2>^ xxy, int kzef, array<double>^ rmsxy, array<int,2>^ mrx, array<double,2>^ parx, array<double>^ fva, array<double>^ fsd, array<double>^ sttf, [OutAttribute] int% nsttf, [OutAttribute] int% ifail ) |

F# |
---|

static member g13bj : mr : int[] * nser : int * mt : int[,] * para : float[] * npara : int * kfc : int * nev : int * nfv : int * xxy : float[,] * kzef : int * rmsxy : float[] * mrx : int[,] * parx : float[,] * fva : float[] * fsd : float[] * sttf : float[] * nsttf : int byref * ifail : int byref -> unit |

#### Parameters

- mr
- Type: array<System..::..Int32>[]()[][]An array of size [$7$]
*On entry*: the orders vector $\left(p,d,q,P,D,Q,s\right)$ of the ARIMA model for the output noise component.$p$, $q$, $P$ and $Q$ refer respectively to the number of autoregressive $\left(\varphi \right)$, moving average $\left(\theta \right)$, seasonal autoregressive $\left(\Phi \right)$ and seasonal moving average $\left(\Theta \right)$ parameters.$d$, $D$ and $s$ refer respectively to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.*Constraints*:- $p$, $d$, $q$, $P$, $D$, $Q$, $s\ge 0$;
- $p+q+P+Q>0$;
- $s\ne 1$;
- if $s=0$, $P+D+Q=0$;
- if $s>1$, $P+D+Q>0$;
- $d+s\times \left(P+D\right)\le n$;
- $p+d-q+s\times \left(P+D-Q\right)\le n$.

- nser
- Type: System..::..Int32
*On entry*: the number of input and output series. There may be any number of input series (including none), but only one output series.

- mt
- Type: array<System..::..Int32,2>[,](,)[,][,]An array of size [$4$, nser]
*On entry*: the transfer function model orders $b$, $p$ and $q$ of each of the input series. The data for input series $i$ is held in column $i$. Row 1 holds the value ${b}_{i}$, row 2 holds the value ${q}_{i}$ and row 3 holds the value ${p}_{i}$.For a simple input, ${b}_{i}={q}_{i}={p}_{i}=0$.Row 4 holds the value ${r}_{i}$, where ${r}_{i}=1$ for a simple input, and ${r}_{i}=2\text{ or}3$ for a transfer function input.The choice ${r}_{i}=3$ leads to estimation of the pre-period input effects as nuisance parameters, and ${r}_{i}=2$ suppresses this estimation. This choice may affect the returned forecasts and the state set.When ${r}_{i}=1$, any nonzero contents of rows 1, 2 and 3 of column $i$ are ignored.*Constraint*: ${\mathbf{mt}}[3,\mathit{i}-1]=1$, $2$ or $3$, for $\mathit{i}=1,2,\dots ,{\mathbf{nser}}-1$.

- para
- Type: array<System..::..Double>[]()[][]An array of size [npara]
*On entry*: estimates of the multi-input model parameters. These are in order, firstly the ARIMA model parameters: $p$ values of $\varphi $ parameters, $q$ values of $\theta $ parameters, $P$ values of $\Phi $ parameters, $Q$ values of $\Theta $ parameters.These are followed by the transfer function model parameter values ${\omega}_{0},{\omega}_{1},\dots ,{\omega}_{{q}_{1}}$, ${\delta}_{1},\dots ,{\delta}_{{p}_{1}}$ for the first of any input series and similarly for each subsequent input series. The final component of para is the value of the constant $c$.*On exit*: the parameter values may be updated using an additional iteration in the estimation process.

- npara
- Type: System..::..Int32
*On entry*: the exact number of $\varphi $, $\theta $, $\Phi $, $\Theta $, $\omega $, $\delta $, $c$ parameters, so that ${\mathbf{npara}}=p+q+P+Q+{\mathbf{nser}}+\sum \left(p+q\right)$, the summation being over all the input series. ($c$ must be included whether its value was previously estimated or was set fixed.)

- kfc
- Type: System..::..Int32
*On entry*: must be set to $1$ if the constant was estimated when the model was fitted, and $0$ if it was held at a fixed value. This only affects the degrees of freedom used in calculating the estimated residual variance.*Constraint*: ${\mathbf{kfc}}=0$ or $1$.

- nev
- Type: System..::..Int32
*On entry*: the number of original (undifferenced) values in each of the input and output time series.

- nfv
- Type: System..::..Int32
*On entry*: the number of forecast values of the output series required.*Constraint*: ${\mathbf{nfv}}>0$.

- xxy
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, nser]
**Note:**dim1 must satisfy the constraint: $\mathrm{dim1}\ge \left({\mathbf{nev}}+{\mathbf{nfv}}\right)$*On entry*: the columns of xxy must contain in the first nev places, the past values of each of the input and output series, in that order. In the next nfv places, the columns relating to the input series (i.e., columns $1$ to ${\mathbf{nser}}-1$) contain the future values of the input series which are necessary for construction of the forecasts of the output series $y$.*On exit*: if ${\mathbf{kzef}}=0$ then xxy is unchanged except that the relevant nfv values in the column relating to the output series (column nser) contain the forecast values (fva), but if ${\mathbf{kzef}}\ne 0$ then the columns of xxy contain the corresponding values of the input component series ${z}_{t}$ and the values of the output noise component ${n}_{t}$, in that order.

- kzef
- Type: System..::..Int32
*On entry*: must be set to $0$ if the relevant nfv values of the forecasts (fva) are to be held in the output series column (nser) of xxy (which is otherwise unchanged) on exit, and must not be set to $0$ if the values of the input component series ${z}_{t}$ and the values of the output noise component ${n}_{t}$ are to overwrite the contents of xxy on exit.

- rmsxy
- Type: array<System..::..Double>[]()[][]An array of size [nser]
*On entry*: the first $\left({\mathbf{nser}}-1\right)$ elements of rmsxy must contain the estimated residual variance of the input series ARIMA models. In the case of those inputs for which no ARIMA model is available or its effects are to be excluded in the calculation of forecast standard errors, the corresponding entry of rmsxy should be set to $0$.*On exit*: ${\mathbf{rmsxy}}\left[{\mathbf{nser}}-1\right]$ contains the estimated residual variance of the output noise ARIMA model which is calculated from the supplied series. Otherwise rmsxy is unchanged.

- mrx
- Type: array<System..::..Int32,2>[,](,)[,][,]An array of size [$7$, nser]
*On entry*: the orders array for each of the input series ARIMA models. Thus, column $i$ contains values of $p$, $d$, $q$, $P$, $D$, $Q$, $s$ for input series $i$. In the case of those inputs for which no ARIMA model is available, the corresponding orders should be set to $0$.*On exit*: unchanged, except for column nser which is used as workspace.

- parx
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, nser]
**Note:**dim1 must satisfy the constraint: $\mathrm{dim1}\ge \mathit{nce}$, where $\mathit{nce}$ is the maximum number of parameters in any of the input series ARIMA models. If there are no input series, then $\mathrm{dim1}\ge 1$*On entry*: values of the parameters ($\varphi $, $\theta $, $\Phi $, and $\Theta $) for each of the input series ARIMA models.Thus column $i$ contains ${\mathbf{mrx}}[0,i-1]$ values of $\varphi $, ${\mathbf{mrx}}[2,i-1]$ values of $\theta $, ${\mathbf{mrx}}[3,i-1]$ values of $\Phi $ and ${\mathbf{mrx}}[5,i-1]$ values of $\Theta $, in that order.Values in the columns relating to those input series for which no ARIMA model is available are ignored.

- fva
- Type: array<System..::..Double>[]()[][]An array of size [nfv]

- fsd
- Type: array<System..::..Double>[]()[][]An array of size [nfv]
*On exit*: the standard errors for each of the forecast values.

- sttf
- Type: array<System..::..Double>[]()[][]An array of size [isttf]

- nsttf
- Type: System..::..Int32%
*On exit*: the number of values in the state set array sttf.

- ifail
- Type: System..::..Int32%
*On exit*: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

g13bj has two stages. The first stage is essentially the same as a call to the model estimation method g13be, with zero iterations. In particular, all the parameters remain unchanged in the supplied input series transfer function models and output noise series ARIMA model. The internal nuisance parameters associated with the pre-observation period effects of the input series are estimated where requested, and so are any backforecasts of the output noise series. The output components ${z}_{t}$ and ${n}_{t}$, and residuals ${a}_{t}$ are calculated exactly as in [Description] in g13be, and the state set for forecasting is constituted.

The second stage is essentially the same as a call to the forecasting method (G13BHF not in this release). The same information is required, and the same information is returned.

Use of g13bj should be confined to situations in which the state set for forecasting is unknown. Forecasting from the original data is relatively expensive because it requires recalculation of the state set. g13bj returns the state set for use in producing further forecasts using (G13BHF not in this release), or for updating the state set using g13bg.

# References

Box G E P and Jenkins G M (1976)

*Time Series Analysis: Forecasting and Control*(Revised Edition) Holden–Day# Error Indicators and Warnings

Errors or warnings detected by the method:

Some error messages may refer to parameters that are dropped from this interface
(LDXXY, LDPARX) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.

- ${\mathbf{ifail}}=1$
On entry, ${\mathbf{kfc}}<0$, or ${\mathbf{kfc}}>1$, or ${\mathbf{nfv}}\le 0$.

- ${\mathbf{ifail}}=2$

- ${\mathbf{ifail}}=3$
- On entry or during execution, one or more sets of $\delta $ parameters do not satisfy the stationarity or invertibility test conditions.

- ${\mathbf{ifail}}=4$

- ${\mathbf{ifail}}=5$
- On entry, iwa is too small by a very considerable margin. No information is supplied about the requisite minimum size.

- ${\mathbf{ifail}}=6$
On entry, iwa is too small, but the requisite minimum size is returned in ${\mathbf{mwa}}\left[0\right]$.

- ${\mathbf{ifail}}=7$
On entry, imwa is too small, but the requisite minimum size is returned in ${\mathbf{mwa}}\left[0\right]$.

- ${\mathbf{ifail}}=8$
- This indicates a failure in (F04ASF not in this release) which is used to solve the equations giving the latest estimates of the parameters.

- ${\mathbf{ifail}}=9$
- This indicates a failure in the inversion of the second derivative matrix associated with parameter estimation.

- ${\mathbf{ifail}}=10$
- On entry or during execution, one or more sets of the ARIMA ($\varphi $, $\theta $, $\Phi $ or $\Theta $) parameters do not satisfy the stationarity or invertibility test conditions.

- ${\mathbf{ifail}}=11$
On entry, isttf is too small.

- ${\mathbf{ifail}}=-9000$
- An error occured, see message report.
- ${\mathbf{ifail}}=-6000$
- Invalid Parameters $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-4000$
- Invalid dimension for array $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-8000$
- Negative dimension for array $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-6000$
- Invalid Parameters $\u2329\mathit{\text{value}}\u232a$

# Accuracy

The computations are believed to be stable.

# Parallelism and Performance

None.

# Further Comments

The time taken by g13bj is approximately proportional to the product of the length of each series and the square of the number of parameters in the multi-input model.

# Example

A further $8$ values of the input series are supplied, and it is assumed that the values for the fifth series have themselves been forecast from an ARIMA model with orders $\begin{array}{ccccccc}2& 0& 2& 0& 1& 1& 4\end{array}\text{,}$ in which ${\varphi}_{1}=1.6743$, ${\varphi}_{2}=-0.9505$, ${\theta}_{1}=1.4605$, ${\theta}_{2}=-0.4862$ and ${\Theta}_{1}=0.8993$, and for which the residual mean square is $0.1720$.

The following are computed and printed out: the state set after initial processing of the original $40$ sets of values, the estimated residual variance for the output noise series, the $8$ forecast values and their standard errors, and the values of the components ${z}_{t}$ and the output noise component ${n}_{t}$.

Example program (C#): g13bje.cs