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

Syntax

C#
public static void g13be(
	int[] mr,
	int nser,
	int[,] mt,
	double[] para,
	int npara,
	int kfc,
	int nxxy,
	double[,] xxy,
	int kef,
	int nit,
	int kzsp,
	double[] zsp,
	out int itc,
	double[] sd,
	double[,] cm,
	out double s,
	out double d,
	out int ndf,
	int kzef,
	double[] res,
	double[] sttf,
	out int nsttf,
	int kpriv,
	out int ifail
)
Visual Basic
Public Shared Sub g13be ( _
	mr As Integer(), _
	nser As Integer, _
	mt As Integer(,), _
	para As Double(), _
	npara As Integer, _
	kfc As Integer, _
	nxxy As Integer, _
	xxy As Double(,), _
	kef As Integer, _
	nit As Integer, _
	kzsp As Integer, _
	zsp As Double(), _
	<OutAttribute> ByRef itc As Integer, _
	sd As Double(), _
	cm As Double(,), _
	<OutAttribute> ByRef s As Double, _
	<OutAttribute> ByRef d As Double, _
	<OutAttribute> ByRef ndf As Integer, _
	kzef As Integer, _
	res As Double(), _
	sttf As Double(), _
	<OutAttribute> ByRef nsttf As Integer, _
	kpriv As Integer, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g13be(
	array<int>^ mr, 
	int nser, 
	array<int,2>^ mt, 
	array<double>^ para, 
	int npara, 
	int kfc, 
	int nxxy, 
	array<double,2>^ xxy, 
	int kef, 
	int nit, 
	int kzsp, 
	array<double>^ zsp, 
	[OutAttribute] int% itc, 
	array<double>^ sd, 
	array<double,2>^ cm, 
	[OutAttribute] double% s, 
	[OutAttribute] double% d, 
	[OutAttribute] int% ndf, 
	int kzef, 
	array<double>^ res, 
	array<double>^ sttf, 
	[OutAttribute] int% nsttf, 
	int kpriv, 
	[OutAttribute] int% ifail
)
F#
static member g13be : 
        mr : int[] * 
        nser : int * 
        mt : int[,] * 
        para : float[] * 
        npara : int * 
        kfc : int * 
        nxxy : int * 
        xxy : float[,] * 
        kef : int * 
        nit : int * 
        kzsp : int * 
        zsp : float[] * 
        itc : int byref * 
        sd : float[] * 
        cm : float[,] * 
        s : float byref * 
        d : float byref * 
        ndf : int byref * 
        kzef : int * 
        res : float[] * 
        sttf : float[] * 
        nsttf : int byref * 
        kpriv : int * 
        ifail : int byref -> unit 

Parameters

mr
Type: array<System..::..Int32>[]()[][]
An array of size [7]
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.
Constraints:
  • 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.
nser
Type: System..::..Int32
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.
Constraints:
  • nser1;
  • if there are no parameters in the model (that is, p=q=P=Q=0 and kfc=0), nser>1.
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 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: mt[3,i-1]=1, ​2​ or ​3, for i=1,2,,nser-1.
para
Type: array<System..::..Double>[]()[][]
An array of size [npara]
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.
npara
Type: System..::..Int32
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.
kfc
Type: System..::..Int32
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.
nxxy
Type: System..::..Int32
On entry: the (common) length of the original, undifferenced input and output time series.
xxy
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, nser]
Note: dim1 must satisfy the constraint: dim1nxxy
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.
kef
Type: System..::..Int32
On entry: indicates the likelihood option.
kef=1
Gives least squares.
kef=2
Gives exact likelihood.
kef=3
Gives marginal likelihood.
Constraint: kef=1, 2 or 3.
nit
Type: System..::..Int32
On entry: the maximum required number of iterations.
nit=0
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.
kzsp
Type: System..::..Int32
On entry: must be set to 1 if the method 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.
zsp
Type: array<System..::..Double>[]()[][]
An array of size [4]
On entry: if kzsp=1, then zsp must contain the four values used to control the strategy of the search procedure.
zsp[0]
Contains α, the value used to constrain the magnitude of the search procedure steps.
zsp[1]
Contains β, the multiplier which regulates the value of α.
zsp[2]
Contains δ, the value of the stationarity and invertibility test tolerance factor.
zsp[3]
Contains γ, the value of the convergence criterion.
If kzsp1 before entry, default values of zsp are supplied by the method. 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 method.
Constraint: if kzsp=1, zsp[0]>0.0, zsp[1]>1.0, zsp[2]1.0, 0zsp[3]<1.0.
itc
Type: System..::..Int32%
On exit: the number of iterations carried out.
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 ω 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.
itc=0
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.
sd
Type: array<System..::..Double>[]()[][]
An array of size [npara]
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=38 or 10, then the contents of sd will be indeterminate.
cm
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, npara]
Note: dim1 must satisfy the constraint: dim1npara
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.
s
Type: System..::..Double%
On exit: the residual sum of squares, S, at the latest set of valid parameter estimates.
d
Type: System..::..Double%
On exit: the objective function, D, at the latest set of valid parameter estimates.
ndf
Type: System..::..Int32%
On exit: the number of degrees of freedom associated with S.
kzef
Type: System..::..Int32
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.
res
Type: array<System..::..Double>[]()[][]
An array of size [nxxy]
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.
sttf
Type: array<System..::..Double>[]()[][]
An array of size [isttf]
On exit: the nsttf values of the state set array.
nsttf
Type: System..::..Int32%
On exit: the number of values in the state set array sttf.
kpriv
Type: System..::..Int32
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.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

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=δ1zt-1+δ2zt-2++δpzt-p+ω0xt-b-ω1xt-b-1--ωqxt-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) dsDnt=c+wt
(ii) wt=Φ1wt-s+Φ2wt-2×s++ΦPwt-P×s+et-Θ1et-s-Θ2et-2×s--ΘQet-Q×s
(iii) et=ϕ1et-1+ϕ2et-2++ϕpet-p+at-θ1at-1-θ2at-2--θqat-q
as outlined in [Description] in g13ae.
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 method. 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 method 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
nt=yt-z1,t+z2,t++zm,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 [Description] in g13ae, 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. There is no loss of degrees of freedom however, because the sum of squares function S may be expressed as including the corresponding set of past residuals; see page 273 of Box and Jenkins (1976), who prove that
S=-nat2.
The function D=S is the first of the three possible criteria, and is quite adequate for moderate to long series with no seasonal parameters. The second is the exact likelihood criterion which considers the past set n0,n-1,n-2 not as simple nuisance parameters, but as unobserved random variables with known distribution. Calculation of the likelihood of the observed set n1,n2,,nn requires theoretical integration over the range of the past set. Fortunately this yields a criterion of the form D=M×S (whose minimization is equivalent to maximizing the exact likelihood of the data), where S is exactly as before, and the multiplier M is a function calculated from the ARIMA model parameters. The value of M is always 1, and M tends to 1 for any fixed parameter set as the sample size n tends to . There is a moderate computational overhead in using this option, but its use avoids appreciable bias in the ARIMA model parameters and yields a better conditioned estimation problem.
The third criterion of marginal likelihood treats the coefficients of the simple inputs in a manner analogous to that given to the past set n0,n-1,n-2,. These coefficients, together with the constant term c used to represent the mean of wt, are in effect treated as random variables with highly dispersed distributions. This leads to the criterion D=M×S again, but with a different value of M which now depends on the simple input series values xt. In the presence of a moderate to large number of simple inputs, the marginal likelihood criterion can counteract bias in the ARIMA model parameters which is caused by estimation of the simple inputs. This is particularly important in relatively short series.
g13be can be used with no input series present, to estimate a univariate ARIMA model for the output alone. The marginal likelihood criterion is then distinct from exact likelihood only if a constant term is being estimated in the model, because this is treated as an implicit simple input.

The Estimation Procedure

This is the minimization of the estimation criterion or objective function D (for deviance). The method uses an extension of the algorithm of Marquardt (1963). The step size in the minimization is inversely related to a parameter α, which is increased or decreased by a factor β at successive iterations, depending on the progress of the minimization. Convergence is deemed to have occurred if the fractional reduction of D in successive iterations is less than a value γ, while α<1.
Certain model parameters (in fact all excluding the ωs) are subject to stability constraints which are checked throughout to within a specified tolerance multiple δ of machine accuracy. Using the least squares criterion, the minimization may halt prematurely when some parameters ‘stick’ at a constraint boundary. This can happen particularly with short seasonal series (with a small number of whole seasons). It will not happen using the exact likelihood criterion, although convergence to a point on the boundary may sometimes be rather slow, because the criterion function may be very flat in such a region. There is also a smaller risk of a premature halt at a constraint boundary when marginal likelihood is used.
A positive, or zero number of iterations can be specified. In either case, the value D of the objective function at iteration zero is presented at the initial parameter values, except for estimation of any pre-period terms for the input series, backforecasts for the noise series, and the coefficients of any simple inputs, and the constant term (unless this is held fixed).
At any later iteration, the value of D is computed after re-estimation of the backforecasts to their optimal values, corresponding to the model parameters presented at that iteration. This is not true for any pre-period terms for the input series which, although they are updated from the previous iteration, may not be precisely optimal for the parameter values presented, unless convergence of those parameters has occurred. However, in the case of marginal likelihood being specified, the coefficients of the simple inputs and the constant term are also re-estimated together with the backforecasts at each iteration, to values which are optimal for the other parameter values presented.

Further Results

The residual variance is taken as erv=Sdf, where df=N-(total number of parameters estimated), is the residual degrees of freedom. 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
erv×H-1
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.

Forecasting Information

For the purpose of constructing forecasts of the output series at future time points t=n+1,n+2, using (G13BHF not in this release), 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 g13bg. If time series data is supplied with a previously estimated model, it is possible to construct the state set (and forecasts) using 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

Error Indicators and Warnings

Note: g13be may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDXXY, LDCM) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry,kfc<0,
orkfc>1,
orkef<1,
orkef>3,
ornit<0,
ornser<1,
ornser=1 and there are no parameters in the model (p=q=P=Q=0 and kfc=0).
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, stored in mt[3,i-1]1, 2 or 3.
ifail=3
On entry or during execution, one or more sets of δ parameters do not satisfy the stationarity or invertibility test conditions.
ifail=4
On entry,when kzsp=1, zsp[0]0.0,
orzsp[1]1.0,
orzsp[2]<1.0,
orzsp[3]<0.0,
orzsp[3]1.0.
ifail=5
On entry, iwa is too small by a considerable margin. No information is supplied about the requisite minimum size.
ifail=6
On entry, iwa is too small, but the requisite minimum size is returned in mwa[0], which is printed if kpriv0.
ifail=7
On entry, imwa is too small, but the requisite minimum size is returned in mwa[0], which is printed if kpriv0.
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.
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
On entry or during execution, one or more sets of the ARIMA (ϕ, θ, Φ or Θ) parameters do not satisfy the stationarity or invertibility test conditions.
ifail=11
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.
ifail=12
The method 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.
ifail=13
On entry, isttf is too small (see ifail=11) and nit iterations were carried out without the convergence conditions being satisfied (see ifail=12).
ifail=-9000
An error occured, see message report.
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

The computation used is believed to be stable.

Parallelism and Performance

None.

Further Comments

The time taken by g13be is approximately proportional to nxxy×itc×npara2.

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.

Example program (C#): g13bee.cs

Example program data: g13bee.d

Example program results: g13bee.r

See Also