G13BEF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G13BEF 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, G13BEF fits a univariate ARIMA model.

2  Specification


3  Description

3.1  The Multi-input Model

The output series yt, for t=1,2,,n, is assumed to be the sum of (unobserved) components zi,t which are due respectively to the inputs xi,t, for i=1,2,,m.
Thus yt=z1,t++zm,t+nt where nt is the error, or output noise component.
A typical component zt may be either
(a) a simple regression component, zt=ωxt (here xt 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 by
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 is assumed to follow a (possibly seasonal) ARIMA model, i.e., may be represented in terms of an uncorrelated series, at, by the hierarchy of equations
(i) d sD nt = c+wt
(ii) wt = Φ1 wt-s + Φ2 w t-2×s ++ ΦP w t-P×s + et - Θ1 et-s - Θ2 et-2×s -- ΘQ et-Q×s
(iii) et = ϕ1 et-1 + ϕ2 e t-2 ++ ϕp et-p +at - θ1 at-1 - θ2 at-2 -- θq at-q
as outlined in Section 3 in G13AEF.
Note:  the orders p,q appearing in each of the transfer function models and the ARIMA model are not necessarily the same; dsDnt is the result of applying non-seasonal differencing of order d and seasonal differencing of seasonality s and order D to the series nt: the differenced series is then of length N=n-d-s×D; the constant term parameter 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 is a sequence of independent Normal variates having mean 0 and variance σa2. 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,z-1,,z1-p and x0,x-1,,x1-b-q which are in theory necessary to re-create the component series z1,z2,,zn, 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,, you are advised first to correct the input series xt by subtracting from all the terms a suitable constant to make the early values x1,x2,, close to zero. The series mean x- is one possibility, but for a series with strong trend the constant might be simply x1.
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 and b=q=0, it is equivalent to fitting to the data a decaying geometric curve of the form Aδt, for t=1,2,, along with the other inputs, this being the form of the transient. If the output yt 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 δ 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 maxp,b+q, with a corresponding loss of degrees of freedom in the residuals. If you align the input xt with the output by using in its place the shifted series xt-b, then setting 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 routine. The option must then be ‘switched off’ for one or more inputs.

3.2  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 routine 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 as the responses to the input series x1,t,x2,t,xm,t using the equations (a) or (b) above,
(ii) the discrepancy between the output and the sum of these components, as the noise
n t = y t - z 1 , t + z 2 , t + + z m , t ,
(iii) the residual series at from nt 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 and other terms in the equations regenerating at. This is identical to the treatment given in Section 3 in G13AEF, and leads to a criterion which is a sum of squares function S, of the residuals at. It may be shown that the finite algorithm presented there is equivalent to taking the infinite set of past values n0,n-1,n-2,, as (linear) nuisance parameters. The pre-period nuisance parameters for the input series are included in the reduction of df, as is the constant if it is estimated.
The covariance matrix of the vector of model parameter estimates is given by
where 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 is available upon completion of the iterations over the range t=1+d+s×D,,n corresponding to the differenced noise series wt.
Because of the algorithm used for backforecasting, these are only true residuals for t1+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 and nt may optionally be returned in place of the supplied series values, in order to assess the effects of the various inputs on the output.

3.3  Forecasting Information

For the purpose of constructing forecasts of the output series at future time points t=n+1,n+2, using G13BHF, it is not necessary to use the whole set of observations yt and x1,t,x2,t,,xm,t, for t=1,2,,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+1-k for k=1 up to the maximum lag associated with that series in the equations. Note that (i) implicitly includes past values of nt and intermediate differences of nt such as d-1sD.
If later observations of the series become available, it is possible to update the state set (without re-estimating the model) using G13BGF. If time series data is supplied with a previously estimated model, it is possible to construct the state set (and forecasts) using G13BJF.

4  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

5  Parameters

1:     MR(7) – INTEGER arrayInput
On entry: the orders vector p,d,q,P,D,Q,s of the ARIMA model for the output noise component.
p, q, P and Q refer respectively to the number of autoregressive ϕ, moving average θ, seasonal autoregressive Φ and seasonal moving average Θ parameters.
d, D and s refer respectively to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.
  • p, d, q, P, D, Q, s0;
  • p+q+P+Q>0;
  • s1;
  • if s=0, P+D+Q=0;
  • if s>1, P+D+Q>0;
  • d+s×P+Dn;
  • p+d-q+s×P+D-Qn.
2:     NSER – INTEGERInput
On entry: the total number of input and output series. There may be any number of input series (including none), but always one output series.
  • NSER1;
  • if there are no parameters in the model (that is, p=q=P=Q=0 and KFC=0), NSER>1.
3:     MT(4,NSER) – INTEGER arrayInput
On entry: the transfer function model orders b, p and q of each of the input series. The order parameters for input series i are held in column i. Row 1 holds the value bi, row 2 holds the value qi and row 3 holds the value pi. For a simple input, bi=qi=pi=0.
Row 4 holds the value ri, where ri=1 for a simple input, ri=2 for a transfer function input for which no allowance is to be made for pre-observation period effects, and ri=3 for a transfer function input for which pre-observation period effects will be treated by estimation of appropriate nuisance parameters.
When ri=1, any nonzero contents of rows 1, 2, and 3 of column i are ignored.
Constraint: MT4i=1, ​2​ or ​3, for i=1,2,,NSER-1.
4:     PARA(NPARA) – REAL (KIND=nag_wp) arrayInput/Output
On entry: initial values of the multi-input model parameters. These are in order, firstly the ARIMA model parameters: p values of ϕ parameters, q values of θ parameters, P values of Φ parameters and Q values of Θ parameters. These are followed by initial values of the transfer function model parameters ω0,ω1,,ωq1, δ1,δ2,,δp1 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, whether it is fixed or is to be estimated.
On exit: the latest values of the estimates of these parameters.
5:     NPARA – INTEGERInput
On entry: the exact number of ϕ,θ,Φ,Θ, ω,δ and c parameters.
Constraint: NPARA=p+q+P+Q+NSER+pi+qi, the summation being over all the piqi supplied in MT. c must be included, whether fixed or estimated.
6:     KFC – INTEGERInput
On entry: must be set to 0 if the constant c is to remain fixed at its initial value, and 1 if it is to be estimated.
Constraint: KFC=0 or 1.
7:     NXXY – INTEGERInput
On entry: the (common) length of the original, undifferenced input and output time series.
8:     XXY(LDXXY,NSER) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the columns of XXY must contain the NXXY original, undifferenced values of each of the input series and the output series xt in that order.
On exit: if KZEF=0, XXY remains unchanged on exit.
If KZEF0, the columns of XXY hold the corresponding values of the input component series zt in place of xt and the output noise component nt in place of yt, in that order.
9:     LDXXY – INTEGERInput
On entry: the first dimension of the array XXY as declared in the (sub)program from which G13BEF is called.
Constraint: LDXXYNXXY.
10:   KEF – INTEGERInput
On entry: indicates the likelihood option.
Gives least squares.
Gives exact likelihood.
Gives marginal likelihood.
Constraint: KEF=1, 2 or 3.
11:   NIT – INTEGERInput
On entry: the maximum required number of iterations.
No change is made to any of the model parameters in array PARA except that the constant c (if KFC=1) and any ω 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.)
Constraint: NIT0.
12:   KZSP – INTEGERInput
On entry: must be set to 1 if the routine is to use the input values of ZSP in the minimization procedure, and to any other value if the default values of ZSP are to be used.
13:   ZSP(4) – REAL (KIND=nag_wp) arrayInput/Output
On entry: if KZSP=1, then ZSP must contain the four values used to control the strategy of the search procedure.
Contains α, the value used to constrain the magnitude of the search procedure steps.
Contains β, the multiplier which regulates the value of α.
Contains δ, the value of the stationarity and invertibility test tolerance factor.
Contains γ, the value of the convergence criterion.
If KZSP1 before entry, default values of ZSP are supplied by the routine. These are 0.01, 10.0, 1000.0 and max100×machine precision,0.0000001, respectively.
On exit: contains the values, default or otherwise, used by the routine.
Constraint: if KZSP=1, ZSP1>0.0, ZSP2>1.0, ZSP31.0, 0ZSP4<1.0.
14:   ITC – INTEGEROutput
On exit: the number of iterations carried out.
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 ω and for the constant c (if KFC=1). This value of ITC usually indicates a failure in a consequent step of estimating transfer function input pre-observation period nuisance parameters.
Indicates that estimates have been obtained up to this point for the constant c (if KFC=1), for simple input coefficients ω and for the nuisance parameters relating to the backforecasts and to transfer function input pre-observation period effects.
15:   SD(NPARA) – REAL (KIND=nag_wp) arrayOutput
On exit: 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 IFAIL=3, 8 or 10, then the contents of SD will be indeterminate.
16:   CM(LDCM,NPARA) – REAL (KIND=nag_wp) arrayOutput
On exit: 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.
17:   LDCM – INTEGERInput
On entry: the first dimension of the array CM as declared in the (sub)program from which G13BEF is called.
Constraint: LDCMNPARA.
18:   S – REAL (KIND=nag_wp)Output
On exit: the residual sum of squares, S, at the latest set of valid parameter estimates.
19:   D – REAL (KIND=nag_wp)Output
On exit: the objective function, D, at the latest set of valid parameter estimates.
20:   NDF – INTEGEROutput
On exit: the number of degrees of freedom associated with S.
21:   KZEF – INTEGERInput
On entry: must not be set to 0, if the values of the input component series zt and the values of the output noise component nt are to overwrite the contents of XXY on exit, and must be set to 0 if XXY is to remain unchanged.
22:   RES(NXXY) – REAL (KIND=nag_wp) arrayOutput
On exit: 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.
23:   STTF(ISTTF) – REAL (KIND=nag_wp) arrayOutput
On exit: the NSTTF values of the state set array.
24:   ISTTF – INTEGERInput
On entry: the dimension of the array STTF as declared in the (sub)program from which G13BEF is called.
Constraint: ISTTFP×s+d+D×s+q+maxp,Q×s+ncg, where ncg=bi+qi+pi over all input series for which ri>1.
25:   NSTTF – INTEGEROutput
On exit: the number of values in the state set array STTF.
26:   WA(IWA) – REAL (KIND=nag_wp) arrayWorkspace
27:   IWA – INTEGERInput
On entry: the dimension of the array WA as declared in the (sub)program from which G13BEF 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 returned in MWAi and is also printed if KPRIV0.)
Let q=q+Q×s and d=d+D×s where the orders of the output noise model are p, d, q, P, D, Q, s.
Let there be l input series, where l=NSER-1.
mxi = max bi + qi ,pi , if ​ ri=3 , for ​ i=1,2,l mxi = 0 , if ​ ri3 , for ​ i=1,2,l
where the transfer function model orders for input i are given by bi, qi, pi, ri.
Let qx=maxq,mx1,mx2,,mxl.
Let ncd=NPARA+KFC+qx+i=1lmxi and nce=NXXY+d+6×qx.
Finally, let ncf=NSER, and then increment ncf by 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 and p2>0 then ncf is incremented by 2.)
The conditions are:
p>0 q>0 P>0 Q>0 qx>0 KFC>0 p>0 q>0 P>0 Q>0 and ​q>0​ and ​KEF>1. p>0 q>0 P>0 Q>0 and ​KFC>0​ and ​KEF=3. mxi>0 pi>0 p>0 q>0 P>0 Q>0 and ​ri=1​ and ​KEF>3​ separately, for ​i=1,2,,l.
Then IWA2× ncd 2+nce×ncf+4.
28:   MWA(IMWA) – INTEGER arrayWorkspace
29:   IMWA – INTEGERInput
On entry: the dimension of the array MWA as declared in the (sub)program from which G13BEF is called.
Constraint: IMWA16×NSER+7×ncd+3×NPARA+3×KFC+27, where the derivation of ncd is shown under IWA.
If IMWA is too small then the exact minimum needed is returned in IMWA and if KPRIV0 it is also printed.
30:   KPRIV – INTEGERInput
On entry: must not be set to 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 IFAIL=6 or 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 ϕ, THETA for θ, SPHI for Φ, STHETA for Θ, OMEGA/SI for ω in a simple input, OMEGA for ω in a transfer function input, DELTA for δ and CONSTANT for 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 if the print-out of the above information is not required.
31:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if IFAIL0 on exit, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: G13BEF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
On entry,KFC<0,
orNSER=1 and there are no parameters in the model (p=q=P=Q=0 and KFC=0).
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, stored in MT4i1, 2 or 3.
On entry or during execution, one or more sets of δ parameters do not satisfy the stationarity or invertibility test conditions.
On entry,when KZSP=1, ZSP10.0,
On entry, IWA is too small by a considerable margin. No information is supplied about the requisite minimum size.
On entry, IWA is too small, but the requisite minimum size is returned in MWA1, which is printed if KPRIV0.
On entry, IMWA is too small, but the requisite minimum size is returned in MWA1, which is printed if KPRIV0.
This indicates a failure in F04ASF which is used to solve the equations giving the latest estimates of the parameters.
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.
On entry or during execution, one or more sets of the ARIMA (ϕ, θ, Φ or Θ) parameters do not satisfy the stationarity or invertibility test conditions.
On entry, ISTTF is too small. The state set information will not be produced and if KZEF0 array XXY will remain unchanged. All other parameters will be produced correctly.
The routine has failed to converge after NIT iterations. If steady decreases in the objective function, 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.
On entry, ISTTF is too small (see IFAIL=11) and NIT iterations were carried out without the convergence conditions being satisfied (see IFAIL=12).

7  Accuracy

The computation used is believed to be stable.

8  Further Comments

The time taken by G13BEF is approximately proportional to NXXY×ITC×NPARA2.

9  Example

After the full 11 iterations, the following are computed and printed out: the final values of the PARA parameters and their standard errors, the correlation matrix, the residuals for the 36 differenced values, the values of zt and nt, the values of the state set and the number of degrees of freedom.

9.1  Program Text

Program Text (g13befe.f90)

9.2  Program Data

Program Data (g13befe.d)

9.3  Program Results

Program Results (g13befe.r)

G13BEF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012