g13 Chapter Contents
g13 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_tsa_multi_inp_update (g13bgc)

## 1  Purpose

nag_tsa_multi_inp_update (g13bgc) accepts a series of new observations of an output time series and any associated input time series, for which a multi-input model is already fully specified, and updates the ‘state set’ information for use in constructing further forecasts.
The previous specification of the multi-input model will normally have been obtained by using nag_tsa_multi_inp_model_estim (g13bec) to estimate the relevant transfer function and ARIMA parameters. The supplied state set will originally have been produced by nag_tsa_multi_inp_model_estim (g13bec) (or possibly nag_tsa_multi_inp_model_forecast (g13bjc)), but may since have been updated by nag_tsa_multi_inp_update (g13bgc).

## 2  Specification

 #include #include
 void nag_tsa_multi_inp_update (Nag_ArimaOrder *arimav, Integer nser, Nag_TransfOrder *transfv, const double para[], Integer npara, Integer nnv, double xxyn[], Integer tdxxyn, Integer kzef, Nag_G13_Opt *options, NagError *fail)

## 3  Description

The multi-input model is specified in Section 3 in nag_tsa_multi_inp_model_estim (g13bec). The form of these equations required to update the state set is as follows:
 $zt=δ1zt-1+δ2zt-2+⋯+δpzt-p+ω0xt-b-ω1xt-b-1-⋯-ωqxt-b-q$
the transfer models which generate input component values ${z}_{i,t}$ from one or more inputs ${x}_{i,t}$,
 $nt=yt-z1,t-z2,t-⋯-zm,t$
which generates the output noise component from the output ${y}_{t}$ and the input components, and
 $wt =∇d∇sDnt-c et =wt-Φ1wt-s-Φ2wt-2×s-⋯-ΦPwt-P×s+Θ1et-s+Θ2et-2×s+⋯+ΘQet-Q×s at =et-ϕ1et-1-ϕ2et-2-⋯-ϕpet-p+θ1at-1+θ2at-2+⋯+θqat-q$
the ARIMA model for the output noise which generates the residuals ${a}_{t}$.
The state set (as also given in Section 3 in nag_tsa_multi_inp_model_estim (g13bec)) is the collection of terms
 $zn+1-k,xn+1-k,nn+1-k,wn+1-k,en+1-k and an+1-k$
for $k=1$ up to the maximum lag associated with each of these series respectively, in the above model equations. $n$ is the latest time point of the series from which the state set has been generated.
The function accepts further values of the series ${y}_{\mathit{t}}$, ${x}_{1,\mathit{t}},{x}_{2,\mathit{t}},\dots ,{x}_{m,\mathit{t}}$, for $\mathit{t}=n+1,\dots ,n+l$, and applies the above model equations over this time range, to generate new values of the various model components, noise series and residuals. The state set is reconstructed, corresponding to the latest time point $n+l$, the earlier values being discarded.
The set of residuals corresponding to the new observations may be of use in checking that the new observations conform to the previously fitted model. The components of the new observations of the output series which are due to the various inputs, and the noise component, are also optionally returned.
The parameters of the model are not changed in this function.

## 4  References

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

## 5  Arguments

1:     arimavNag_ArimaOrder *
Pointer to structure of type Nag_ArimaOrder with the following members:
pInteger
dIntegerInput
qIntegerInput
bigpIntegerInput
bigdIntegerInput
bigqIntegerInput
sIntegerInput
On entry: these seven members of arimav must specify the orders vector $\left(p,d,q,P,D,Q,s\right)$, respectively, of the ARIMA model for the output noise component.
$p$, $q$, $P$ and $Q$ refer, respectively, to the number of autoregressive ($\varphi$), moving average ($\theta$), seasonal autoregressive ($\Phi$) and seasonal moving average ($\Theta$) parameters.
$d$, $D$ and $s$ refer, respectively, to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.
2:     nserIntegerInput
On entry: the total number of input and output series. There may be any number of input series (including none), but only one output series.
3:     transfvNag_TransfOrder *
Pointer to structure of type Nag_TransfOrder with the following members:
bInteger *Input
qInteger *Input
pInteger *
rInteger *Input
On entry: before use, these member pointers must be allocated memory by calling nag_tsa_transf_orders (g13byc) which allocates ${\mathbf{nseries}}-1$ elements to each pointer. The memory allocated to these pointers must be given the transfer function model orders $b$, $q$ and $p$ of each of the input series. The order arguments for input series $i$ are held in the $i$th element of the allocated memory for each pointer. $\mathbf{b}\left[i-1\right]$ holds the value ${b}_{i}$, $\mathbf{transfv}\mathbf{\to }\mathbf{q}\left[i-1\right]$ holds the value ${q}_{i}$ and $\mathbf{transfv}\mathbf{\to }\mathbf{p}\left[i-1\right]$ holds the value ${p}_{i}$.
For a simple input, ${b}_{i}={q}_{i}={p}_{i}=0$.
$\mathbf{r}\left[i-1\right]$ 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.
When ${r}_{i}=1$, any nonzero contents of the $i$th element of the memory of $\mathbf{b}$, $\mathbf{transfv}\mathbf{\to }\mathbf{q}$ and $\mathbf{transfv}\mathbf{\to }\mathbf{p}$ are ignored.
Constraint: $\mathbf{r}\left[\mathit{i}-1\right]=1$, $2$ or $3$, for $\mathit{i}=1,2,\dots {\mathbf{nseries}}-1$
The memory allocated to the members of transfv must be freed by a call to nag_tsa_trans_free (g13bzc).
4:     para[npara]const doubleInput
On entry: estimates of the multi-input model parameters as returned by nag_tsa_multi_inp_model_estim (g13bec). These are in order, firstly the ARIMA model parameters: $p$ values of $\varphi$ parameters, $q$ values of $\theta$ parameters, $P$ values of $\Phi$ parameters and $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},{\delta }_{2},\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$.
5:     nparaIntegerInput
On entry: the exact number of $\varphi$, $\theta$, $\Phi$, $\Theta$, $\omega$, $\delta$ and $c$ parameters. ($c$ must be included whether its value was previously estimated or was set fixed.)
6:     nnvIntegerInput
On entry: the number of new observation sets being used to update the state set, each observation set consisting of a value of the output series and the associated values of each of the input series at a particular time point.
7:     xxyn[${\mathbf{nnv}}×{\mathbf{tdxxyn}}$]doubleInput/Output
Note: the $\left(i,j\right)$th element of the matrix is stored in ${\mathbf{xxyn}}\left[\left(i-1\right)×{\mathbf{tdxxyn}}+j-1\right]$.
On entry: the nnv new observation sets being used to update the state set. Column $i-1$ contains the values of input series $\mathit{i}$, for $\mathit{i}=1,2,\dots ,{\mathbf{nser}}-1$. Column ${\mathbf{nser}}-1$ contains the values of the output series. Consecutive rows correspond to increasing time sequence.
On exit: if ${\mathbf{kzef}}=0$, xxyn remains unchanged.
If ${\mathbf{kzef}}\ne 0$, the columns of xxyn hold the corresponding values of the input component series ${z}_{t}$ and the output noise component ${n}_{t}$ in that order.
8:     tdxxynIntegerInput
On entry: the stride separating matrix column elements in the array xxyn.
Constraint: ${\mathbf{tdxxyn}}\ge {\mathbf{nser}}$.
9:     kzefIntegerInput
On entry: 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 xxyn on exit, and must be set to $0$ if xxyn is to remain unchanged on exit.
10:   optionsNag_G13_Opt *Input/Output
On entry: a pointer to a structure of type Nag_G13_Opt as returned by nag_tsa_cross_corr (g13bcc) or nag_tsa_multi_inp_model_forecast (g13bjc).
On exit: the structure contains the updated state space information.
11:   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_INT
On entry, ${\mathbf{tdxxyn}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{tdxxyn}}>0$.
NE_INT_2
On entry, ${\mathbf{tdxxyn}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{nser}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{tdxxyn}}\ge {\mathbf{nser}}$.
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_STRUCT_CORRUPT
Values of the members of structures arimav, transfv and options are not compatible.

## 7  Accuracy

The computations are believed to be stable.

## 8  Parallelism and Performance

Not applicable.

The time taken by nag_tsa_multi_inp_update (g13bgc) is approximately proportional to ${\mathbf{nnv}}×{\mathbf{npara}}$.

## 10  Example

This example uses the data described in nag_tsa_multi_inp_model_estim (g13bec) in which $40$ observations of an output time series and a single input series were processed. In this example a model which included seasonal differencing of order $1$ was used. The $10$ values of the state set and the $5$ final values of para then obtained are used as input to this program, together with the values of $4$ new observations and the transfer function orders of the input series. The model used is ${\varphi }_{1}=0.5158$, ${\Theta }_{1}=0.9994$, ${\omega }_{0}=8.6343$, ${\delta }_{1}=0.6726$, $c=-0.3172$.
The following are computed and printed out: the updated state set, the residuals ${a}_{t}$ and the values of the components ${z}_{t}$ and the output noise component ${n}_{t}$ corresponding to the new observations.

### 10.1  Program Text

Program Text (g13bgce.c)

### 10.2  Program Data

Program Data (g13bgce.d)

### 10.3  Program Results

Program Results (g13bgce.r)
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 109, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9743757843971252, "perplexity": 1590.987472669036}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2016-18/segments/1461860123845.65/warc/CC-MAIN-20160428161523-00055-ip-10-239-7-51.ec2.internal.warc.gz"}