Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_tsa_multi_inputmod_estim (g13be)

Purpose

nag_tsa_multi_inputmod_estim (g13be) fits a multi-input model relating one output series to the input series with a choice of three different estimation criteria: nonlinear least squares, exact likelihood and marginal likelihood. When no input series are present, nag_tsa_multi_inputmod_estim (g13be) fits a univariate ARIMA model.

Syntax

[para, xxy, zsp, itc, sd, cm, s, d, ndf, res, sttf, nsttf, ifail] = g13be(mr, mt, para, xxy, 'nser', nser, 'npara', npara, 'kfc', kfc, 'nxxy', nxxy, 'kef', kef, 'nit', nit, 'zsp', zsp, 'iwa', iwa, 'imwa', imwa, 'kpriv', kpriv)
[para, xxy, zsp, itc, sd, cm, s, d, ndf, res, sttf, nsttf, ifail] = nag_tsa_multi_inputmod_estim(mr, mt, para, xxy, 'nser', nser, 'npara', npara, 'kfc', kfc, 'nxxy', nxxy, 'kef', kef, 'nit', nit, 'zsp', zsp, 'iwa', iwa, 'imwa', imwa, 'kpriv', kpriv)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 22: nxxy has been made optional
Mark 23: isttf, kzef, kzsp have been dropped, iwa, imwa, zsp, kfc, nit, kef, kpriv now optional
.

Description

The Multi-input Model

The output series yt${y}_{\mathit{t}}$, for t = 1,2,,n$\mathit{t}=1,2,\dots ,n$, is assumed to be the sum of (unobserved) components zi,t${z}_{i,t}$ which are due respectively to the inputs xi,t${x}_{\mathit{i},t}$, for i = 1,2,,m$\mathit{i}=1,2,\dots ,m$.
Thus yt = z1,t + + zm,t + nt${y}_{t}={z}_{1,t}+\cdots +{z}_{m,t}+{n}_{t}$ where nt${n}_{t}$ is the error, or output noise component.
A typical component zt${z}_{t}$ may be either
(a) a simple regression component, zt = ωxt${z}_{t}=\omega {x}_{t}$ (here xt${x}_{t}$ is called a simple input), or
(b) a transfer function model component which allows for the effect of lagged values of the variable, related to xt${x}_{t}$ by
 zt = δ1 zt − 1 + δ2 zt − 2 + ⋯ + δp zt − p + ω0 xt − b − ω1 xt − b − 1 − ⋯ − ωq xt − b − q . $zt = δ1 zt-1 + δ2 zt-2 + ⋯ + δp zt-p + ω0 xt-b - ω1 x t-b-1 - ⋯ - ωq x t-b-q .$
The noise nt${n}_{t}$ is assumed to follow a (possibly seasonal) ARIMA model, i.e., may be represented in terms of an uncorrelated series, at${a}_{t}$, by the hierarchy of equations
 (i) ∇d ∇sD nt = c + wt ${\nabla }^{d}{\nabla }_{s}^{D}{n}_{t}=c+{w}_{t}$ (ii) wt = Φ1 wt − s + Φ2 wt − 2 × s + ⋯ + ΦP wt − P × s + et − Θ1 et − s − Θ2 et − 2 × s − ⋯ − ΘQ et − Q × s ${w}_{t}={\Phi }_{1}{w}_{t-s}+{\Phi }_{2}{w}_{t-2×s}+\cdots +{\Phi }_{P}{w}_{t-P×s}+{e}_{t}-{\Theta }_{1}{e}_{t-s}-{\Theta }_{2}{e}_{t-2×s}-\cdots -{\Theta }_{Q}{e}_{t-Q×s}$ (iii) et = φ1 et − 1 + φ2 et − 2 + ⋯ + φp et − p + at − θ1 at − 1 − θ2 at − 2 − ⋯ − θq at − q ${e}_{t}={\varphi }_{1}{e}_{t-1}+{\varphi }_{2}{e}_{t-2}+\cdots +{\varphi }_{p}{e}_{t-p}+{a}_{t}-{\theta }_{1}{a}_{t-1}-{\theta }_{2}{a}_{t-2}-\cdots -{\theta }_{q}{a}_{t-q}$
as outlined in Section [Description] in (g13ae).
Note:  the orders p,q$p,q$ appearing in each of the transfer function models and the ARIMA model are not necessarily the same; dsDnt${\nabla }^{d}{\nabla }_{s}^{D}{n}_{t}$ is the result of applying non-seasonal differencing of order d$d$ and seasonal differencing of seasonality s$s$ and order D$D$ to the series nt${n}_{t}$: the differenced series is then of length N = nds × D$N=n-d-s×D$; the constant term parameter c$c$ may optionally be held fixed at its initial value (usually, but not necessarily zero) rather than being estimated.
For the purpose of defining an estimation criterion it is assumed that the series at${a}_{t}$ is a sequence of independent Normal variates having mean 0$0$ and variance σa2${\sigma }_{a}^{2}$. An allowance has to be made for the effects of unobserved data prior to the observation period. For the noise component an allowance is always made using a form of backforecasting.
For each transfer function input, you have to decide what values are to be assumed for the pre-period terms z0,z1,,z1p${z}_{0},{z}_{-1},\dots ,{z}_{1-p}$ and x0,x1,,x1bq${x}_{0},{x}_{-1},\dots ,{x}_{1-b-q}$ which are in theory necessary to re-create the component series z1,z2,,zn${z}_{1},{z}_{2},\dots ,{z}_{n}$, during the estimation procedure.
The first choice is to assume that all these values are zero. In this case, in order to avoid undesirable transient distortion of the early values z1,z2,${z}_{1},{z}_{2},\dots \text{}$, you are advised first to correct the input series xt${x}_{t}$ by subtracting from all the terms a suitable constant to make the early values x1,x2,${x}_{1},{x}_{2},\dots \text{}$, close to zero. The series mean x$\stackrel{-}{x}$ is one possibility, but for a series with strong trend the constant might be simply x1${x}_{1}$.
The second choice is to treat the unknown pre-period terms as nuisance parameters and estimate them along with the other parameters. This choice should be used with caution. For example, if p = 1$p=1$ and b = q = 0$b=q=0$, it is equivalent to fitting to the data a decaying geometric curve of the form Aδt$A{\delta }^{\mathit{t}}$, for t = 1,2,$\mathit{t}=1,2,\dots$, along with the other inputs, this being the form of the transient. If the output yt${y}_{t}$ contains a strong trend of this form, which is not otherwise represented in the model, it will have a tendency to influence the estimate of δ$\delta$ away from the value appropriate to the transfer function model.
In most applications the first choice should be adequate, with the option possibly being used as a refinement at the end of the modelling process. The number of nuisance parameters is then max (p,b + q)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,b+q\right)$, with a corresponding loss of degrees of freedom in the residuals. If you align the input xt${x}_{t}$ with the output by using in its place the shifted series xtb${x}_{t-b}$, then setting b = 0$b=0$ in the transfer function model, there is some improvement in efficiency. On some occasions when the model contains two or more inputs, each with estimation of pre-period nuisance parameters, these parameters may be co-linear and lead to failure of the function. The option must then be ‘switched off’ for one or more inputs.

The Estimation Criterion

This is a measure of how well a proposed set of parameters in the transfer function and noise ARIMA models matches the data. The estimation function searches for parameter values which minimize this criterion. For a proposed set of parameter values it is derived by calculating
(i) the components z1,t,z2,t,,zm,t${z}_{1,t},{z}_{2,t},\dots ,{z}_{m,t}$ as the responses to the input series x1,t,x2,t,xm,t${x}_{1,t},{x}_{2,t}\dots ,{x}_{m,t}$ using the equations (a) or (b) above,
(ii) the discrepancy between the output and the sum of these components, as the noise
 nt = yt − (z 1 , t + z 2 , t + ⋯ + z m , t ) , $n t = y t - ( z 1 , t + z 2 , t + ⋯ + z m , t ) ,$
(iii) the residual series at${a}_{t}$ from nt${n}_{t}$ by reversing the recursive equations (i), (ii) and (iii) above.
This last step again requires treatment of the effect of unknown pre-period values of nt${n}_{t}$ and other terms in the equations regenerating at${a}_{t}$. This is identical to the treatment given in Section [Description] in (g13ae), and leads to a criterion which is a sum of squares function S$S$, of the residuals at${a}_{t}$. It may be shown that the finite algorithm presented there is equivalent to taking the infinite set of past values n0,n1,n2,${n}_{0},{n}_{-1},{n}_{-2},\dots$, as (linear) nuisance parameters. The pre-period nuisance parameters for the input series are included in the reduction of df$\mathit{df}$, as is the constant if it is estimated.
The covariance matrix of the vector of model parameter estimates is given by
 erv × H − 1 $erv×H-1$
where H$H$ is the linearized least squares matrix taken from the final iteration of the algorithm of Marquardt. From this expression are derived the vector of standard deviations, and the correlation matrix of parameter estimates. These are approximations which are only valid asymptotically, and must be treated with great caution when the parameter estimates are close to their constraint boundaries.
The residual series at${a}_{t}$ is available upon completion of the iterations over the range t = 1 + d + s × D,,n$t=1+d+s×D,\dots ,n$ corresponding to the differenced noise series wt${w}_{t}$.
Because of the algorithm used for backforecasting, these are only true residuals for t1 + q + s × Qps × Pds × D$t\ge 1+q+s×Q-p-s×P-d-s×D$, provided this is positive. Estimation of pre-period terms for the inputs will also tend to reduce the magnitude of the early residuals, sometimes severely.
The model component series z1,t,,zm,t${z}_{1,t},\dots ,{z}_{m,t}$ and nt${n}_{t}$ may optionally be returned in place of the supplied series values, in order to assess the effects of the various inputs on the output.

Forecasting Information

For the purpose of constructing forecasts of the output series at future time points t = n + 1,n + 2,$t=n+1,n+2,\dots \text{}$ using nag_tsa_multi_inputmod_forecast_state (g13bh), it is not necessary to use the whole set of observations yt${y}_{t}$ and x1,t,x2,t,,xm,t${x}_{1,\mathit{t}},{x}_{2,\mathit{t}},\dots ,{x}_{m,\mathit{t}}$, for t = 1,2,,m$\mathit{t}=1,2,\dots ,m$. It is sufficient to retain a limited set of quantities constituting the ‘state set’ as follows: for each series which appears with lagged subscripts in equations (a), (b), (i), (ii) and (iii) above, include the values at times n + 1k$n+1-k$ for k = 1$k=1$ up to the maximum lag associated with that series in the equations. Note that (i) implicitly includes past values of nt${n}_{t}$ and intermediate differences of nt${n}_{t}$ such as d1sD${\nabla }^{d-1}{\nabla }_{s}^{D}$.
If later observations of the series become available, it is possible to update the state set (without re-estimating the model) using nag_tsa_multi_inputmod_update (g13bg). If time series data is supplied with a previously estimated model, it is possible to construct the state set (and forecasts) using nag_tsa_multi_inputmod_forecast (g13bj).

References

Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
Marquardt D W (1963) An algorithm for least squares estimation of nonlinear parameters J. Soc. Indust. Appl. Math. 11 431

Parameters

Compulsory Input Parameters

1:     mr(7$7$) – int64int32nag_int array
The orders vector (p,d,q,P,D,Q,s)$\left(p,d,q,P,D,Q,s\right)$ of the ARIMA model for the output noise component.
p$p$, q$q$, P$P$ and Q$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$, D$D$ and s$s$ refer respectively to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.
Constraints:
• p$p$, d$d$, q$q$, P$P$, D$D$, Q$Q$, s0$s\ge 0$;
• p + q + P + Q > 0$p+q+P+Q>0$;
• s1$s\ne 1$;
• if s = 0$s=0$, P + D + Q = 0$P+D+Q=0$;
• if s > 1$s>1$, P + D + Q > 0$P+D+Q>0$;
• d + s × (P + D)n$d+s×\left(P+D\right)\le n$;
• p + dq + s × (P + DQ)n$p+d-q+s×\left(P+D-Q\right)\le n$.
2:     mt(4$4$,nser) – int64int32nag_int array
The transfer function model orders b$b$, p$p$ and q$q$ of each of the input series. The order parameters for input series i$i$ are held in column i$i$. Row 1$1$ holds the value bi${b}_{i}$, row 2 holds the value qi${q}_{i}$ and row 3 holds the value pi${p}_{i}$. For a simple input, bi = qi = pi = 0${b}_{i}={q}_{i}={p}_{i}=0$.
Row 4 holds the value ri${r}_{i}$, where ri = 1${r}_{i}=1$ for a simple input, ri = 2${r}_{i}=2$ for a transfer function input for which no allowance is to be made for pre-observation period effects, and ri = 3${r}_{i}=3$ for a transfer function input for which pre-observation period effects will be treated by estimation of appropriate nuisance parameters.
When ri = 1${r}_{i}=1$, any nonzero contents of rows 1, 2, and 3 of column i$i$ are ignored.
Constraint: mt(4,i) = 1, ​2​ or ​3${\mathbf{mt}}\left(4,\mathit{i}\right)=1\text{, ​}2\text{​ or ​}3$, for i = 1,2,,nser1$\mathit{i}=1,2,\dots ,{\mathbf{nser}}-1$.
3:     para(npara) – double array
npara, the dimension of the array, must satisfy the constraint npara = p + q + P + Q + nser + (pi + qi)${\mathbf{npara}}=p+q+P+Q+{\mathbf{nser}}+\sum \left({p}_{i}+{q}_{i}\right)$, the summation being over all the piqi${p}_{i}\ne {q}_{i}$ supplied in mt. c$c$ must be included, whether fixed or estimated.
Initial values of the multi-input model parameters. These are in order, firstly the ARIMA model parameters: p$p$ values of φ$\varphi$ parameters, q$q$ values of θ$\theta$ parameters, P$P$ values of Φ$\Phi$ parameters and Q$Q$ values of Θ$\Theta$ parameters. These are followed by initial values of the transfer function model parameters ω0,ω1,,ωq1${\omega }_{0},{\omega }_{1},\dots ,{\omega }_{{q}_{1}}$, δ1,δ2,,δp1${\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 initial value of the constant c$c$, whether it is fixed or is to be estimated.
4:     xxy(ldxxy,nser) – double array
ldxxy, the first dimension of the array, must satisfy the constraint ldxxynxxy$\mathit{ldxxy}\ge {\mathbf{nxxy}}$.
The columns of xxy must contain the nxxy original, undifferenced values of each of the input series and the output series xt${x}_{t}$ in that order.

Optional Input Parameters

1:     nser – int64int32nag_int scalar
Default: The second dimension of the arrays mt, xxy. (An error is raised if these dimensions are not equal.)
The total number of input and output series. There may be any number of input series (including none), but always one output series.
Constraints:
• nser1${\mathbf{nser}}\ge 1$;
• if there are no parameters in the model (that is, p = q = P = Q = 0$p=q=P=Q=0$ and kfc = 0${\mathbf{kfc}}=0$), nser > 1${\mathbf{nser}}>1$.
2:     npara – int64int32nag_int scalar
Default: The dimension of the array para.
The exact number of φ,θ,Φ,Θ$\varphi ,\theta ,\Phi ,\Theta$, ω,δ$\omega ,\delta$ and c$c$ parameters.
Constraint: npara = p + q + P + Q + nser + (pi + qi)${\mathbf{npara}}=p+q+P+Q+{\mathbf{nser}}+\sum \left({p}_{i}+{q}_{i}\right)$, the summation being over all the piqi${p}_{i}\ne {q}_{i}$ supplied in mt. c$c$ must be included, whether fixed or estimated.
3:     kfc – int64int32nag_int scalar
Must be set to 0$0$ if the constant c$c$ is to remain fixed at its initial value, and 1$1$ if it is to be estimated.
Default: 1$1$
Constraint: kfc = 0${\mathbf{kfc}}=0$ or 1$1$.
4:     nxxy – int64int32nag_int scalar
Default: The first dimension of the array xxy.
The (common) length of the original, undifferenced input and output time series.
5:     kef – int64int32nag_int scalar
Indicates the likelihood option.
kef = 1${\mathbf{kef}}=1$
Gives least squares.
kef = 2${\mathbf{kef}}=2$
Gives exact likelihood.
kef = 3${\mathbf{kef}}=3$
Gives marginal likelihood.
Default: 2$2$
Constraint: kef = 1${\mathbf{kef}}=1$, 2$2$ or 3$3$.
6:     nit – int64int32nag_int scalar
The maximum required number of iterations.
nit = 0${\mathbf{nit}}=0$
No change is made to any of the model parameters in array para except that the constant c$c$ (if kfc = 1${\mathbf{kfc}}=1$) and any ω$\omega$ relating to simple input series are estimated. (Apart from these, estimates are always derived for the nuisance parameters relating to any backforecasts and any pre-observation period effects for transfer function inputs.)
Default: 1000$1000$
Constraint: nit0${\mathbf{nit}}\ge 0$.
7:     zsp(4$4$) – double array
If kzsp = 1$\mathit{kzsp}=1$, then zsp must contain the four values used to control the strategy of the search procedure.
zsp(1)${\mathbf{zsp}}\left(1\right)$
Contains α$\alpha$, the value used to constrain the magnitude of the search procedure steps.
zsp(2)${\mathbf{zsp}}\left(2\right)$
Contains β$\beta$, the multiplier which regulates the value of α$\alpha$.
zsp(3)${\mathbf{zsp}}\left(3\right)$
Contains δ$\delta$, the value of the stationarity and invertibility test tolerance factor.
zsp(4)${\mathbf{zsp}}\left(4\right)$
Contains γ$\gamma$, the value of the convergence criterion.
If kzsp1$\mathit{kzsp}\ne 1$ before entry, default values of zsp are supplied by the function. These are 0.01$0.01$, 10.0$10.0$, 1000.0$1000.0$ and max (100 × machine precision,0.0000001), respectively.
Constraint: if kzsp = 1$\mathit{kzsp}=1$, zsp(1) > 0.0${\mathbf{zsp}}\left(1\right)>0.0$, zsp(2) > 1.0${\mathbf{zsp}}\left(2\right)>1.0$, zsp(3)1.0${\mathbf{zsp}}\left(3\right)\ge 1.0$, 0zsp(4) < 1.0$0\le {\mathbf{zsp}}\left(4\right)<1.0$.
8:     iwa – int64int32nag_int scalar
The dimension of the array wa as declared in the (sub)program from which nag_tsa_multi_inputmod_estim (g13be) is called.
It is not practical to outline a method for deriving the exact minimum permissible value of iwa, but the following gives a reasonably good conservative approximation. (It should be noted that if iwa is too small (but not grossly so) then the exact minimum is printed if kpriv0${\mathbf{kpriv}}\ne 0$.)
Let q = q + (Q × s)${q}^{\prime }=q+\left(Q×s\right)$ and d = d + (D × s)${d}^{\prime }=d+\left(D×s\right)$ where the orders of the output noise model are p$p$, d$d$, q$q$, P$P$, D$D$, Q$Q$, s$s$.
Let there be l$l$ input series, where l = nser1$l={\mathbf{nser}}-1$.
Let
 mxi = max ( bi + qi ,pi) , if ​ ri = 3 , for ​ i = 1,2 … ,l mxi = 0 , if ​ ri ≠ 3 , for ​ i = 1,2 … ,l
$mxi = max( bi + qi ,pi) , if ​ ri=3 , for ​ i=1,2…,l mxi = 0 , if ​ ri≠3 , for ​ i=1,2…,l$
where the transfer function model orders for input i$i$ are given by bi${b}_{i}$, qi${q}_{i}$, pi${p}_{i}$, ri${r}_{i}$.
Let qx = max (q,mx1,mx2,,mxl)$qx=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({q}^{\prime },m{x}_{1},m{x}_{2},\dots ,m{x}_{l}\right)$.
Let ncd = npara + kfc + qx + i = 1lmxi$\mathit{ncd}={\mathbf{npara}}+{\mathbf{kfc}}+qx+\sum _{i=1}^{l}m{x}_{i}$ and nce = nxxy + d + 6 × qx$\mathit{nce}={\mathbf{nxxy}}+{d}^{\prime }+6×qx$.
Finally, let ncf = nser$\mathit{ncf}={\mathbf{nser}}$, and then increment ncf$\mathit{ncf}$ by 1$1$ every time any of the following conditions is satisfied. (The last six conditions should be applied separately to each input series, so that, for example, if we have two input series and if p1 > 0${p}_{1}>0$ and p2 > 0${p}_{2}>0$ then ncf$\mathit{ncf}$ is incremented by 2$2$.)
The conditions are:
and ​q > 0​ and ​kef > 1. and ​kfc > 0​ and ​kef = 3. and ​ri = 1​ and ​kef > 3​ separately, for ​i = 1,2, … ,l.
 p > 0 q > 0 P > 0 Q > 0 qx > 0 kfc > 0
 p > 0 q > 0 P > 0 Q > 0 }
 p > 0 q > 0 P > 0 Q > 0 }
 mxi > 0 pi > 0 p > 0 q > 0 P > 0 Q > 0 }
Then iwa2 × (ncd)2 + (nce) × (ncf + 4)${\mathbf{iwa}}\ge 2×{\left(\mathit{ncd}\right)}^{2}+\left(\mathit{nce}\right)×\left(\mathit{ncf}+4\right)$.
Default: 5 × (2 × ncd2 + nce × (ncf + 4))$5×\left(2×{\mathrm{ncd}}^{2}+\mathrm{nce}×\left(\mathrm{ncf}+4\right)\right)$
9:     imwa – int64int32nag_int scalar
The dimension of the array mwa as declared in the (sub)program from which nag_tsa_multi_inputmod_estim (g13be) is called.
Default: 5 × (16 × nser + 7 × ncd + 3 × npara + 3 × kfc + 27)$5×\left(16×{\mathbf{nser}}+7×\mathrm{ncd}+3×{\mathbf{npara}}+3×{\mathbf{kfc}}+27\right)$
Constraint: imwa(16 × nser) + (7 × ncd) + (3 × npara) + (3 × kfc) + 27${\mathbf{imwa}}\ge \left(16×{\mathbf{nser}}\right)+\left(7×\mathit{ncd}\right)+\left(3×{\mathbf{npara}}\right)+\left(3×{\mathbf{kfc}}\right)+27$, where the derivation of ncd$\mathit{ncd}$ is shown under iwa.
If imwa is too small then if kpriv0${\mathbf{kpriv}}\ne 0$ it is printed.
10:   kpriv – int64int32nag_int scalar
Must not be set to 0$0$, if it is required to monitor the course of the optimization or to print out the requisite minimum values of iwa or imwa in the event of an error of the type ${\mathbf{ifail}}={\mathbf{6}}$ or 7${\mathbf{7}}$. The course of the optimization is monitored by printing out at each iteration the iteration count (itc), the residual sum of squares (s), the objective function (d) and a description and value for each of the parameters in the para array. The descriptions are PHI for φ$\varphi$, THETA for θ$\theta$, SPHI for Φ$\Phi$, STHETA for Θ$\Theta$, OMEGA/SI for ω$\omega$ in a simple input, OMEGA for ω$\omega$ in a transfer function input, DELTA for δ$\delta$ and CONSTANT for c$c$. In addition SERIES 1, SERIES 2, etc. indicate the input series relevant to the OMEGA and DELTA parameters.
kpriv must be set to 0$0$ if the print-out of the above information is not required.
Default: 0$0$

Input Parameters Omitted from the MATLAB Interface

ldxxy kzsp ldcm wa mwa

Output Parameters

1:     para(npara) – double array
The latest values of the estimates of these parameters.
2:     xxy(ldxxy,nser) – double array
ldxxynxxy$\mathit{ldxxy}\ge {\mathbf{nxxy}}$.
the columns of xxy hold the corresponding values of the input component series zt${z}_{t}$ in place of xt${x}_{t}$ and the output noise component nt${n}_{t}$ in place of yt${y}_{t}$, in that order.
3:     zsp(4$4$) – double array
Contains the values, default or otherwise, used by the function.
4:     itc – int64int32nag_int scalar
The number of iterations carried out.
itc = -1${\mathbf{itc}}=-1$
Indicates that the only estimates obtained up to this point have been for the nuisance parameters relating to backforecasts, unless the marginal likelihood option is used, in which case estimates have also been obtained for simple input coefficients ω$\omega$ and for the constant c$c$ (if kfc = 1${\mathbf{kfc}}=1$). This value of itc usually indicates a failure in a consequent step of estimating transfer function input pre-observation period nuisance parameters.
itc = 0${\mathbf{itc}}=0$
Indicates that estimates have been obtained up to this point for the constant c$c$ (if kfc = 1${\mathbf{kfc}}=1$), for simple input coefficients ω$\omega$ and for the nuisance parameters relating to the backforecasts and to transfer function input pre-observation period effects.
5:     sd(npara) – double array
The npara values of the standard deviations corresponding to each of the parameters in para. When the constant is fixed its standard deviation is returned as zero. When the values of para are valid, the values of sd are usually also valid. However, if an exit value of ${\mathbf{ifail}}={\mathbf{3}}$, 8${\mathbf{8}}$ or 10${\mathbf{10}}$, then the contents of sd will be indeterminate.
6:     cm(ldcm,npara) – double array
ldcmnpara$\mathit{ldcm}\ge {\mathbf{npara}}$.
The first npara rows and columns of cm contain the correlation coefficients relating to each pair of parameters in para. All coefficients relating to the constant will be zero if the constant is fixed. The contents of cm will be indeterminate under the same conditions as sd.
7:     s – double scalar
The residual sum of squares, S$S$, at the latest set of valid parameter estimates.
8:     d – double scalar
The objective function, D$D$, at the latest set of valid parameter estimates.
9:     ndf – int64int32nag_int scalar
The number of degrees of freedom associated with S$S$.
10:   res(nxxy) – double array
The values of the residuals relating to the differenced values of the output series. The remainder of the first nxxy terms in the array will be zero.
11:   sttf(isttf) – double array
The nsttf values of the state set array.
12:   nsttf – int64int32nag_int scalar
The number of values in the state set array sttf.
13:   ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Note: nag_tsa_multi_inputmod_estim (g13be) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, kfc < 0${\mathbf{kfc}}<0$, or kfc > 1${\mathbf{kfc}}>1$, or ldxxy < nxxy$\mathit{ldxxy}<{\mathbf{nxxy}}$, or ldcm < npara$\mathit{ldcm}<{\mathbf{npara}}$, or kef < 1${\mathbf{kef}}<1$, or kef > 3${\mathbf{kef}}>3$, or nit < 0${\mathbf{nit}}<0$, or nser < 1${\mathbf{nser}}<1$, or nser = 1${\mathbf{nser}}=1$ and there are no parameters in the model (p = q = P = Q = 0$p=q=P=Q=0$ and kfc = 0${\mathbf{kfc}}=0$).
ifail = 2${\mathbf{ifail}}=2$
On entry, there is inconsistency between npara and kfc on the one hand and the orders in arrays mr and mt on the other, or one of the ri${r}_{i}$, stored in mt(4,i)1${\mathbf{mt}}\left(4,i\right)\ne 1$, 2$2$ or 3$3$.
ifail = 3${\mathbf{ifail}}=3$
On entry or during execution, one or more sets of δ$\delta$ parameters do not satisfy the stationarity or invertibility test conditions.
ifail = 4${\mathbf{ifail}}=4$
 On entry, when kzsp = 1$\mathit{kzsp}=1$, zsp(1) ≤ 0.0${\mathbf{zsp}}\left(1\right)\le 0.0$, or zsp(2) ≤ 1.0${\mathbf{zsp}}\left(2\right)\le 1.0$, or zsp(3) < 1.0${\mathbf{zsp}}\left(3\right)<1.0$, or zsp(4) < 0.0${\mathbf{zsp}}\left(4\right)<0.0$, or zsp(4) ≥ 1.0${\mathbf{zsp}}\left(4\right)\ge 1.0$.
ifail = 5${\mathbf{ifail}}=5$
On entry, iwa is too small by a considerable margin. No information is supplied about the requisite minimum size.
ifail = 6${\mathbf{ifail}}=6$
On entry, iwa is too small, but the requisite minimum size is returned in mwa(1)$\mathit{mwa}\left(1\right)$, which is printed if kpriv0${\mathbf{kpriv}}\ne 0$.
ifail = 7${\mathbf{ifail}}=7$
On entry, imwa is too small, but the requisite minimum size is returned in mwa(1)$\mathit{mwa}\left(1\right)$, which is printed if kpriv0${\mathbf{kpriv}}\ne 0$.
ifail = 8${\mathbf{ifail}}=8$
This indicates a failure in nag_linsys_real_posdef_solve_1rhs (f04as) which is used to solve the equations giving the latest estimates of the parameters.
ifail = 9${\mathbf{ifail}}=9$
This indicates a failure in the inversion of the second derivative matrix. This is needed in the calculation of the correlation matrix and the standard deviations of the parameter estimates.
ifail = 10${\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.
ifail = 11${\mathbf{ifail}}=11$
On entry, isttf is too small. The state set information will not be produced and if kzef0$\mathbf{kzef}\ne 0$ array xxy will remain unchanged. All other parameters will be produced correctly.
ifail = 12${\mathbf{ifail}}=12$
The function has failed to converge after nit iterations. If steady decreases in the objective function, D$D$, were monitored up to the point where this exit occurred, then the exit probably occurred because nit was set too small, so the calculations should be restarted from the final point held in para.
ifail = 13${\mathbf{ifail}}=13$
On entry, isttf is too small (see ${\mathbf{ifail}}={\mathbf{11}}$) and nit iterations were carried out without the convergence conditions being satisfied (see ${\mathbf{ifail}}={\mathbf{12}}$).

Accuracy

The computation used is believed to be stable.

The time taken by nag_tsa_multi_inputmod_estim (g13be) is approximately proportional to nxxy × itc × ${\mathbf{nxxy}}×{\mathbf{itc}}×{{\mathbf{npara}}}^{2}$.

Example

```function nag_tsa_multi_inputmod_estim_example
mr = [int64(1);0;0;0;0;1;4];
mt = [int64(1),0; ...
0,0; ...
1,0; ...
3,0];
para = [0;
0;
2;
0.5;
0];
xxy = [8.075, 105;
7.819, 119;
7.366, 119;
8.113, 109;
7.38, 117;
7.134, 135;
7.222, 126;
7.768, 112;
7.386, 116;
6.965, 122;
6.478, 115;
8.105, 115;
8.06, 122;
7.684, 138;
7.58, 135;
7.093, 125;
6.129, 115;
6.026, 108;
6.679, 100;
7.414, 96;
7.112, 107;
7.762, 115;
7.645, 123;
8.639, 122;
7.667, 128;
8.08, 136;
6.678, 140;
6.739, 122;
5.569, 102;
5.049, 103;
5.642, 89;
6.808, 77;
6.636, 89;
8.241, 94;
7.968, 104;
8.044, 108;
7.791, 119;
7.024, 126;
6.102, 119;
6.053, 103];
kef = int64(3);
[paraOut, xxyOut, zspOut, itc, sd, cm, s, d, ndf, res, sttf, nsttf, ifail] = ...
nag_tsa_multi_inputmod_estim(mr, mt, para, xxy, 'kef', kef)
```
```

paraOut =

0.3809
-0.2578
8.9561
0.6596
-75.4355

xxyOut =

180.5668  -75.5668
191.4297  -72.4297
196.3025  -77.3025
195.4597  -86.4597
201.5940  -84.5940
199.0756  -64.0756
195.2111  -69.2111
193.4501  -81.4501
197.1785  -81.1785
196.2167  -74.2167
191.8117  -76.8117
184.5444  -69.5444
194.3221  -72.3221
200.3689  -62.3689
200.9901  -65.9901
200.4685  -75.4685
195.7627  -80.7627
184.0250  -76.0250
175.3598  -75.3598
175.4922  -79.4922
182.1623  -75.1623
183.8574  -68.8574
190.7970  -67.7970
194.3268  -72.3268
205.5576  -77.5576
204.2605  -68.2605
207.1038  -67.1038
196.4229  -74.4229
189.9237  -87.9237
175.1579  -72.1579
160.7606  -71.7606
156.5745  -79.5745
164.2560  -75.2560
167.7826  -73.7826
184.4834  -80.4834
193.0549  -85.0549
199.3897  -80.3897
201.3025  -75.3025
195.6949  -76.6949
183.7384  -80.7384

zspOut =

1.0e+03 *

0.0000
0.0100
1.0000
0.0000

itc =

11

sd =

0.1664
0.1782
0.9481
0.0602
33.5053

cm =

1.0000   -0.1839   -0.1775   -0.0340    0.1394
-0.1839    1.0000    0.0518    0.2547   -0.2860
-0.1775    0.0518    1.0000   -0.3070   -0.2926
-0.0340    0.2547   -0.3070    1.0000   -0.8185
0.1394   -0.2860   -0.2926   -0.8185    1.0000

s =

1.1980e+03

d =

1.2866e+03

ndf =

34

res =

0.3973
3.0856
-2.8185
-9.9406
-5.0615
14.0532
2.6237
-5.8231
-2.1471
-0.2162
-2.5168
7.9165
1.4228
11.9364
5.1168
-5.6717
-5.6814
-1.6372
-1.0188
-2.6235
3.2831
6.8961
5.3954
0.8753
-4.1526
6.2056
4.2078
-2.3868
-11.8034
6.4349
1.3417
-4.9236
4.7989
-0.0743
-6.0234
-6.4273
-2.5270
2.0394
0.2427
-3.1663

sttf =

6.0530
183.7384
-5.7855
-0.1645
0.1800
-3.0977

nsttf =

6

ifail =

0

```
```function g13be_example
mr = [int64(1);0;0;0;0;1;4];
mt = [int64(1),0; ...
0,0; ...
1,0; ...
3,0];
para = [0;
0;
2;
0.5;
0];
xxy = [8.075, 105;
7.819, 119;
7.366, 119;
8.113, 109;
7.38, 117;
7.134, 135;
7.222, 126;
7.768, 112;
7.386, 116;
6.965, 122;
6.478, 115;
8.105, 115;
8.06, 122;
7.684, 138;
7.58, 135;
7.093, 125;
6.129, 115;
6.026, 108;
6.679, 100;
7.414, 96;
7.112, 107;
7.762, 115;
7.645, 123;
8.639, 122;
7.667, 128;
8.08, 136;
6.678, 140;
6.739, 122;
5.569, 102;
5.049, 103;
5.642, 89;
6.808, 77;
6.636, 89;
8.241, 94;
7.968, 104;
8.044, 108;
7.791, 119;
7.024, 126;
6.102, 119;
6.053, 103];
kef = int64(3);
[paraOut, xxyOut, zspOut, itc, sd, cm, s, d, ndf, res, sttf, nsttf, ifail] = ...
g13be(mr, mt, para, xxy, 'kef', kef)
```
```

paraOut =

0.3809
-0.2578
8.9561
0.6596
-75.4355

xxyOut =

180.5668  -75.5668
191.4297  -72.4297
196.3025  -77.3025
195.4597  -86.4597
201.5940  -84.5940
199.0756  -64.0756
195.2111  -69.2111
193.4501  -81.4501
197.1785  -81.1785
196.2167  -74.2167
191.8117  -76.8117
184.5444  -69.5444
194.3221  -72.3221
200.3689  -62.3689
200.9901  -65.9901
200.4685  -75.4685
195.7627  -80.7627
184.0250  -76.0250
175.3598  -75.3598
175.4922  -79.4922
182.1623  -75.1623
183.8574  -68.8574
190.7970  -67.7970
194.3268  -72.3268
205.5576  -77.5576
204.2605  -68.2605
207.1038  -67.1038
196.4229  -74.4229
189.9237  -87.9237
175.1579  -72.1579
160.7606  -71.7606
156.5745  -79.5745
164.2560  -75.2560
167.7826  -73.7826
184.4834  -80.4834
193.0549  -85.0549
199.3897  -80.3897
201.3025  -75.3025
195.6949  -76.6949
183.7384  -80.7384

zspOut =

1.0e+03 *

0.0000
0.0100
1.0000
0.0000

itc =

11

sd =

0.1664
0.1782
0.9481
0.0602
33.5053

cm =

1.0000   -0.1839   -0.1775   -0.0340    0.1394
-0.1839    1.0000    0.0518    0.2547   -0.2860
-0.1775    0.0518    1.0000   -0.3070   -0.2926
-0.0340    0.2547   -0.3070    1.0000   -0.8185
0.1394   -0.2860   -0.2926   -0.8185    1.0000

s =

1.1980e+03

d =

1.2866e+03

ndf =

34

res =

0.3973
3.0856
-2.8185
-9.9406
-5.0615
14.0532
2.6237
-5.8231
-2.1471
-0.2162
-2.5168
7.9165
1.4228
11.9364
5.1168
-5.6717
-5.6814
-1.6372
-1.0188
-2.6235
3.2831
6.8961
5.3954
0.8753
-4.1526
6.2056
4.2078
-2.3868
-11.8034
6.4349
1.3417
-4.9236
4.7989
-0.0743
-6.0234
-6.4273
-2.5270
2.0394
0.2427
-3.1663

sttf =

6.0530
183.7384
-5.7855
-0.1645
0.1800
-3.0977

nsttf =

6

ifail =

0

```