NAG FL Interface
g13aef (uni_arima_estim)
1
Purpose
g13aef fits a seasonal autoregressive integrated moving average (ARIMA) model to an observed time series, using a nonlinear least squares procedure incorporating backforecasting. Parameter estimates are obtained, together with appropriate standard errors. The residual series is returned, and information for use in forecasting the time series is produced for use by the routines
g13agf and
g13ahf.
The estimation procedure is iterative, starting with initial parameter values such as may be obtained using
g13adf. It continues until a specified convergence criterion is satisfied, or until a specified number of iterations has been carried out. The progress of the procedure can be monitored by means of a user-supplied routine.
2
Specification
Fortran Interface
Subroutine g13aef ( |
mr, par, npar, c, kfc, x, nx, icount, ex, exr, al, iex, s, g, igh, sd, h, ldh, st, ist, nst, piv, kpiv, nit, itc, zsp, kzsp, isf, wa, iwa, hc, ifail) |
Integer, Intent (In) |
:: |
mr(7), npar, kfc, nx, iex, igh, ldh, ist, kpiv, nit, kzsp, iwa |
Integer, Intent (Inout) |
:: |
ifail |
Integer, Intent (Out) |
:: |
icount(6), nst, itc, isf(4) |
Real (Kind=nag_wp), Intent (In) |
:: |
x(nx) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
par(npar), c, h(ldh,igh), zsp(4), hc(ldh,igh) |
Real (Kind=nag_wp), Intent (Out) |
:: |
ex(iex), exr(iex), al(iex), s, g(igh), sd(igh), st(ist), wa(iwa) |
External |
:: |
piv |
|
C Header Interface
#include <nag.h>
void |
g13aef_ (const Integer mr[], double par[], const Integer *npar, double *c, const Integer *kfc, const double x[], const Integer *nx, Integer icount[], double ex[], double exr[], double al[], const Integer *iex, double *s, double g[], const Integer *igh, double sd[], double h[], const Integer *ldh, double st[], const Integer *ist, Integer *nst, void (NAG_CALL *piv)(const Integer mr[], const double par[], const Integer *npar, const double *c, const Integer *kfc, const Integer icount[], const double *s, const double g[], const double h[], const Integer *ldh, const Integer *igh, const Integer *itc, const double zsp[]), const Integer *kpiv, const Integer *nit, Integer *itc, double zsp[], const Integer *kzsp, Integer isf[], double wa[], const Integer *iwa, double hc[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g13aef_ (const Integer mr[], double par[], const Integer &npar, double &c, const Integer &kfc, const double x[], const Integer &nx, Integer icount[], double ex[], double exr[], double al[], const Integer &iex, double &s, double g[], const Integer &igh, double sd[], double h[], const Integer &ldh, double st[], const Integer &ist, Integer &nst, void (NAG_CALL *piv)(const Integer mr[], const double par[], const Integer &npar, const double &c, const Integer &kfc, const Integer icount[], const double &s, const double g[], const double h[], const Integer &ldh, const Integer &igh, const Integer &itc, const double zsp[]), const Integer &kpiv, const Integer &nit, Integer &itc, double zsp[], const Integer &kzsp, Integer isf[], double wa[], const Integer &iwa, double hc[], Integer &ifail) |
}
|
The routine may be called by the names g13aef or nagf_tsa_uni_arima_estim.
3
Description
The time series
supplied to
g13aef is assumed to follow a seasonal autoregressive integrated moving average (ARIMA) model defined as follows:
where
is the result of applying non-seasonal differencing of order
and seasonal differencing of seasonality
and order
to the series
, as outlined in the description of
g13aaf. The differenced series is then of length
, where
is the generalized order of differencing. The scalar
is the expected value of the differenced series, and the series
follows a zero-mean stationary autoregressive moving average (ARMA) model defined by a pair of recurrence equations. These express
in terms of an uncorrelated series
, via an intermediate series
. The first equation describes the seasonal structure:
The second equation describes the non-seasonal structure. If the model is purely non-seasonal the first equation is redundant and
above is equated with
:
Estimates of the model parameters defined by
and (optionally)
are obtained by minimizing a quadratic form in the vector
.
This is
, where
is the covariance matrix of
, and is a function of the model parameters. This matrix is not explicitly evaluated, since
may be expressed as a ‘sum of squares’ function. When moving average parameters
or
are present, so that the generalized moving average order
is positive, backforecasts
are introduced as nuisance parameters. The ‘sum of squares’ function may then be written as
where
is a combined vector of parameters, consisting of the backforecasts followed by the ARMA model parameters.
The terms correspond to the ARMA model residual series , and is the generalized autoregressive order. The terms are only present if autoregressive parameters are in the model, and serve to correct for transient errors introduced at the start of the autoregression.
The equations defining
and
are precisely:
- ,
for .
- ,
for .
- ,
for
- ,
for .
For all four of these equations, the following conditions hold:
- if
- if
- if
- if
- if
Minimization of
with respect to
uses an extension of the algorithm of
Marquardt (1963).
The first derivatives of
with respect to the parameters are calculated as
where
and
are derivatives of
and
with respect to the
th parameter.
The second derivative of
is approximated by
Successive parameter iterates are obtained by calculating a vector of corrections
by solving the equations
where
is a vector with elements
,
is a matrix with elements
,
is a scalar used to control the search and
is the diagonal matrix of
.
The new parameter values are then .
The scalar controls the step size, to which it is inversely related.
If a step results in new parameter values which give a reduced value of , then is reduced by a factor . If a step results in new parameter values which give an increased value of , or in ARMA model parameters which in any way contravene the stationarity and invertibility conditions, then the new parameters are rejected, is increased by the factor , and the revised equations are solved for a new parameter correction.
This action is repeated until either a reduced value of is obtained, or reaches the limit of , which is used to indicate a failure of the search procedure.
This failure may be due to a badly conditioned sum of squares function or to too strict a convergence criterion. Convergence is deemed to have occurred if the fractional reduction in the residual sum of squares in successive iterations is less than a value , while .
The stationarity and invertibility conditions are tested to within a specified tolerance multiple of machine accuracy. Upon convergence, or completion of the specified maximum number of iterations without convergence, statistical properties of the estimates are derived. In the latter case the sequence of iterates should be checked to ensure that convergence is adequate for practical purposes, otherwise these properties are not reliable.
The estimated residual variance is
where
is the final value of
, and the residual number of degrees of freedom is given by
The covariance matrix of the vector of estimates
is given by
where
is evaluated at the final parameter values.
From this expression are derived the vector of standard deviations, and the correlation matrix for the whole parameter set. These are asymptotic approximations.
The differenced series
(now uncorrected for the constant), intermediate series
and residual series
are all available upon completion of the iterations over the range (extended by backforecasts)
The values
can only properly be interpreted as residuals for
, as the earlier values are corrupted by transients if
.
In consequence of the manner in which differencing is implemented, the residual is the one step ahead forecast error for .
For convenient application in forecasting, the following quantities constitute the ‘state set’, which contains the minimum amount of time series information needed to construct forecasts:
-
(i)the differenced series , for ,
-
(ii)the values required to reconstitute the original series from the differenced series ,
-
(iii)the intermediate series , for
,
-
(iv)the residual series , for .
This state set is available upon completion of the iterations. The routine may be used purely for the construction of this state set, given a previously estimated model and time series
, by requesting zero iterations. Backforecasts are estimated, but the model parameter values are unchanged. If later observations become available and it is desired to update the state set,
g13agf can be used.
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
Arguments
-
1:
– Integer array
Input
-
On entry: the orders vector of the ARIMA model whose parameters are to be estimated. , , and refer respectively to the number of autoregressive (), moving average , seasonal autoregressive () and seasonal moving average () parameters. , and refer respectively to the order of non-seasonal differencing, the order of seasonal differencing and the seasonal period.
Constraints:
- , , , , , , ;
- ;
- ;
- if , ;
- if , ;
- ;
- .
-
2:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: the initial estimates of the values of the parameters, the values of the parameters, the values of the parameters and the values of the parameters, in that order.
On exit: the latest values of the estimates of these parameters.
-
3:
– Integer
Input
-
On entry: the total number of , , and parameters to be estimated.
Constraint:
.
-
4:
– Real (Kind=nag_wp)
Input/Output
-
On entry: if
,
c must contain the expected value,
, of the differenced series.
If
,
c must contain an initial estimate of
.
On exit: if
,
c is unchanged.
If
,
c contains the latest estimate of
.
Therefore, if
c and
kfc are both zero on entry, there is no constant correction.
-
5:
– Integer
Input
-
On entry: must be set to if the constant, , is to be estimated and if it is to be held fixed at its initial value.
Constraint:
or .
-
6:
– Real (Kind=nag_wp) array
Input
-
On entry: the values of the original undifferenced time series.
-
7:
– Integer
Input
-
On entry: , the length of the original undifferenced time series.
-
8:
– Integer array
Output
-
On exit: size of various output arrays.
- Contains , the number of backforecasts.
- Contains , the number of differenced values.
- Contains , the number of values of reconstitution information.
- Contains , the number of values held in each of the series ex, exr and al.
- Contains , the number of degrees of freedom associated with .
- Contains , the number of parameters being estimated.
These values are always computed regardless of the exit value of
ifail.
-
9:
– Real (Kind=nag_wp) array
Output
-
On exit: the extended differenced series which is made up of:
backforecast values of the differenced series.
actual values of the differenced series.
values of reconstitution information.
The total number of these values held in
ex is
.
If the routine exits because of a faulty input parameter, the contents of
ex will be indeterminate.
-
10:
– Real (Kind=nag_wp) array
Output
-
On exit: the values of the model residuals which is made up of:
residuals corresponding to the backforecasts in the differenced series.
residuals corresponding to the actual values in the differenced series.
The remaining values contain zeros.
If the routine exits with
ifail holding a value other than
or
, the contents of
exr will be indeterminate.
-
11:
– Real (Kind=nag_wp) array
Output
-
On exit: the intermediate series which is made up of:
intermediate series values corresponding to the backforecasts in the differenced series.
intermediate series values corresponding to the actual values in the differenced series.
The remaining values contain zeros.
If the routine exits with
, the contents of
al will be indeterminate.
-
12:
– Integer
Input
-
On entry: the dimension of the arrays
ex,
exr and
al as declared in the (sub)program from which
g13aef is called.
Constraint:
, which is equivalent to the exit value of .
-
13:
– Real (Kind=nag_wp)
Output
-
On exit: the residual sum of squares after the latest series of parameter estimates has been incorporated into the model. If the routine exits with a faulty input parameter,
s contains zero.
-
14:
– Real (Kind=nag_wp) array
Output
-
On exit: the latest value of the derivatives of
with respect to each of the parameters being estimated (backforecasts,
par parameters, and where relevant the constant – in that order). The contents of
g will be indeterminate if the routine exits with a faulty input parameter.
-
15:
– Integer
Input
-
On entry: the dimension of the arrays
g and
sd and the second dimension of the arrays
h and
hc as declared in the (sub)program from which
g13aef is called.
Constraint:
which is equivalent to the exit value of .
-
16:
– Real (Kind=nag_wp) array
Output
-
On exit: the standard deviations corresponding to each of the parameters being estimated (backforecasts,
par parameters, and where relevant the constant, in that order).
If the routine exits with
ifail containing a value other than
or
, or if the required number of iterations is zero, the contents of
sd will be indeterminate.
-
17:
– Real (Kind=nag_wp) array
Output
-
On exit: the second derivative of
and correlation coefficients.
-
(a)the latest values of an approximation to the second derivative of with respect to each of the parameters being estimated (backforecasts, par parameters, and where relevant the constant – in that order), and
-
(b)the correlation coefficients relating to each pair of these parameters.
These are held in a matrix defined by the first
rows and the first
columns of
h. (Note that
contains the value of this expression.) The values of
(a) are contained in the upper triangle, and the values of
(b) in the strictly lower triangle.
These correlation coefficients are zero during intermediate printout using
piv, and indeterminate if
ifail contains on exit a value other than
or
.
All the contents of
h are indeterminate if the required number of iterations are zero. The
th row of
h is used internally as workspace.
-
18:
– Integer
Input
-
On entry: the first dimension of the array
h and
Constraint:
, which is equivalent to the exit value of .
-
19:
– Real (Kind=nag_wp) array
Output
-
On exit: the
nst values of the state set array. If the routine exits with
ifail containing a value other than
or
, the contents of
st will be indeterminate.
-
20:
– Integer
Input
-
On entry: the dimension of the array
st as declared in the (sub)program from which
g13aef is called.
Constraint:
.
-
21:
– Integer
Output
-
On exit: the number of values in the state set array
st.
-
22:
– Subroutine, supplied by the NAG Library or the user.
External Procedure
-
piv is used to monitor the progress of the optimization.
The specification of
piv is:
Fortran Interface
Subroutine piv ( |
mr, par, npar, c, kfc, icount, s, g, h, ldh, igh, itc, zsp) |
Integer, Intent (In) |
:: |
mr(7), npar, kfc, icount(6), ldh, igh, itc |
Real (Kind=nag_wp), Intent (In) |
:: |
par(npar), c, s, g(igh), h(ldh,igh), zsp(4) |
|
C Header Interface
void |
piv_ (const Integer mr[], const double par[], const Integer *npar, const double *c, const Integer *kfc, const Integer icount[], const double *s, const double g[], const double h[], const Integer *ldh, const Integer *igh, const Integer *itc, const double zsp[]) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
piv_ (const Integer mr[], const double par[], const Integer &npar, const double &c, const Integer &kfc, const Integer icount[], const double &s, const double g[], const double h[], const Integer &ldh, const Integer &igh, const Integer &itc, const double zsp[]) |
}
|
piv is called on each iteration by
g13aef when the input value of
kpiv is nonzero and is bypassed when it is
.
The routine
g13afz may be used as
piv. It prints the heading
G13AFZ MONITORING OUTPUT - ITERATION n
followed by the parameter values and the residual sum of squares. Output is directed to the advisory channel defined by
x04abf.
-
1:
– Integer array
Input
-
2:
– Real (Kind=nag_wp) array
Input
-
3:
– Integer
Input
-
4:
– Real (Kind=nag_wp)
Input
-
5:
– Integer
Input
-
6:
– Integer array
Input
-
7:
– Real (Kind=nag_wp)
Input
-
8:
– Real (Kind=nag_wp) array
Input
-
9:
– Real (Kind=nag_wp) array
Input
-
10:
– Integer
Input
-
11:
– Integer
Input
-
12:
– Integer
Input
-
13:
– Real (Kind=nag_wp) array
Input
-
On entry: all the arguments are defined as for g13aef itself.
piv must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
g13aef is called. Arguments denoted as
Input must
not be changed by this procedure.
If
a dummy
piv must be supplied.
-
23:
– Integer
Input
-
On entry: must be nonzero if the progress of the optimization is to be monitored using
piv. Otherwise
kpiv must contain
.
-
24:
– Integer
Input
-
On entry: the maximum number of iterations to be performed.
Constraint:
.
-
25:
– Integer
Output
-
On exit: the number of iterations performed.
-
26:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: when
, the first four elements of
zsp must contain the four values used to guide the search procedure. These are as follows.
contains , the value used to constrain the magnitude of the search procedure steps.
contains , the multiplier which regulates the value .
contains , the value of the stationarity and invertibility test tolerance factor.
contains , the value of the convergence criterion.
If
on entry, default values for
zsp are supplied by the routine.
These are , , and respectively.
On exit:
zsp contains the values, default or otherwise, used by the routine.
Constraints:
if
,
- , ;
- , ;
- , ;
- .
-
27:
– Integer
Input
-
On entry: the value
if the routine is to use the input values of
zsp, and any other value if the default values of
zsp are to be used.
-
28:
– Integer array
Output
-
On exit: contains success/failure indicators, one for each of the four types of parameter in the model (autoregressive, moving average, seasonal autoregressive, seasonal moving average), in that order.
Each indicator has the interpretation:
|
On entry parameters of this type have initial estimates which do not satisfy the stationarity or invertibility test conditions. |
|
The search procedure has failed to converge because the latest set of parameter estimates of this type is invalid. |
|
No parameter of this type is in the model. |
|
Valid final estimates for parameters of this type have been obtained. |
-
29:
– Real (Kind=nag_wp) array
Workspace
-
30:
– Integer
Input
-
On entry: the dimension of the array
wa as declared in the (sub)program from which
g13aef is called.
Constraint:
where |
; |
and |
if ; |
|
if , ; |
|
if , , ; |
|
if , , , ; |
|
otherwise. |
-
31:
– Real (Kind=nag_wp) array
Workspace
-
-
32:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if
on exit, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
Note: in some cases g13aef may return useful information.
-
On entry, .
Constraint: or .
On entry, .
Constraint: .
The orders vector
mr is invalid.
-
The model is over-parameterised. The number of parameters in the model is greater than the number of terms in the differenced series, i.e., .
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
-
On entry,
and the minimum size
(the minimum size required is returned in
nst).
Constraint:
.
-
On entry, and the minimum size .
Constraint: .
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
-
A failure in the search procedure has occurred. Some output arguments may contain meaningful values.
-
Failure to invert . Some output arguments may contain meaningful values.
-
Unable to calculate the latest estimates of the backforecasts.
Some output arguments may contain meaningful values.
-
Satisfactory parameter estimates could not be obtained for all parameter types in the model. Inspect array
isf for futher information on the parameter type(s) in error.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
The computations are believed to be stable.
8
Parallelism and Performance
g13aef is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13aef makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
The time taken by g13aef is approximately proportional to .
10
Example
The following program reads observations from a time series relating to the rate of the earth's rotation about its polar axis. Differencing of order is applied, and the number of non-seasonal parameters is , one autoregressive , and two moving average . No seasonal effects are taken into account.
The constant is estimated. Up to iterations are allowed.
The initial estimates of , , and are zero.
10.1
Program Text
10.2
Program Data
10.3
Program Results