NAG FL Interface
g13adf (uni_​arima_​prelim)

Settings help

FL Name Style:

FL Specification Language:

1 Purpose

g13adf calculates preliminary estimates of the parameters of an autoregressive integrated moving average (ARIMA) model from the autocorrelation function of the appropriately differenced times series.

2 Specification

Fortran Interface
Subroutine g13adf ( mr, r, nk, xv, npar, wa, nwa, par, rv, isf, ifail)
Integer, Intent (In) :: mr(7), nk, npar, nwa
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: isf(4)
Real (Kind=nag_wp), Intent (In) :: r(nk), xv
Real (Kind=nag_wp), Intent (Out) :: wa(nwa), par(npar), rv
C Header Interface
#include <nag.h>
void  g13adf_ (const Integer mr[], const double r[], const Integer *nk, const double *xv, const Integer *npar, double wa[], const Integer *nwa, double par[], double *rv, Integer isf[], Integer *ifail)
The routine may be called by the names g13adf or nagf_tsa_uni_arima_prelim.

3 Description

Preliminary estimates of the p non-seasonal autoregressive parameters ϕ1,ϕ2,,ϕp and the q non-seasonal moving average parameters θ1,θ2,,θq may be obtained from the sample autocorrelations relating to lags 1 to p+q, i.e., r1,,rp+q, of the differenced dsDxt, where xt is assumed to follow a (possibly) seasonal ARIMA model (see Section 3 in g13aef for the specification of an ARIMA model).
Taking r0=1 and r-k=rk, the ϕi, for i=1,2,,p are the solutions to the equations
r q+i-1 ϕ1+ r q+i-2 ϕ2 ++ r q+i-p ϕp = rq+i ,   i=1,2,,p.  
The θj, for j=1,2,,q, are obtained from the solutions to the equations
cj=τ0τj+τ1τj+1++τq+jτq,   j=0,1,,q  
(Cramer Wold-factorization), by setting
θj=-τjτ0 ,  
where cj are the ‘covariances’ modified in a two stage process by the autoregressive parameters.
Stage 1:
dj=rj-ϕ1rj-1--ϕprj-p, j=0,1,,q; dj=0, j=q+1,q+2,,p+q.  
Stage 2:
cj=dj-ϕ1dj+ 1-ϕ2dj+ 2--ϕpdj+p,   j= 0,1,,q.  
The P seasonal autoregressive parameters Φ1,Φ2,,ΦP and the Q seasonal moving average parameters Θ1,Θ2,,ΘQ are estimated in the same way as the non-seasonal parameters, but each rj is replaced in the calculation by rs×j, where s is the seasonal period.
An estimate of the residual variance is obtained by successively reducing the sample variance, first for non-seasonal, and then for seasonal, parameter estimates. If moving average parameters are estimated, the variance is reduced by a multiplying factor of τ02, but otherwise by c0.

4 References

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

5 Arguments

1: mr(7) Integer array Input
On entry: the orders vector (p,d,q,P,D,Q,s) of the ARIMA model whose parameters are to be estimated. 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.
2: r(nk) Real (Kind=nag_wp) array Input
On entry: the autocorrelations (starting at lag 1), which must have been calculated after the time series has been appropriately differenced.
Constraint: -1.0r(i)1.0, for i=1,2,,nk.
3: nk Integer Input
On entry: the maximum lag of the autocorrelations in array r.
Constraint: nkmax(p+q,s×(P+Q)).
4: xv Real (Kind=nag_wp) Input
On entry: the series sample variance, calculated after appropriate differencing has been applied to the series.
Constraint: xv>0.0.
5: npar Integer Input
On entry: the exact number of parameters specified in the model by array mr.
Constraint: npar=p+q+P+Q.
6: wa(nwa) Real (Kind=nag_wp) array Workspace
7: nwa Integer Input
On entry: the amount of workspace available.
Constraint: if mr=(p,d,q,P,D,Q,s) and p=max(p,P) and q=max(q,Q), nwamax(p2+p,4(q+1)).
8: par(npar) Real (Kind=nag_wp) array Output
On exit: the first npar elements of par contain the preliminary estimates of the ARIMA model parameters, in standard order.
9: rv Real (Kind=nag_wp) Output
On exit: an estimate of the residual variance of the preliminarily estimated model.
10: isf(4) Integer array Output
On exit: contains success/failure indicators, one for each of the four types of parameter (autoregressive, moving average, seasonal autoregressive, seasonal moving average).
The indicator has the interpretation:
-0 No parameter of this type is in the model.
-1 Parameters of this type appear in the model and satisfactory preliminary estimates of this type were obtained.
−1 Parameters of this type appear in the model but satisfactory preliminary estimates of this type were not obtainable. The estimates of this type of parameter were set to 0.0 in array par.
11: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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).
Errors or warnings detected by the routine:
The orders vector mr is invalid.
On entry, nk=value.
Constraint: nkmax(p+q,s×(P+Q)).
On entry, r(value)=value.
Constraint: -1.0r(i)1.0, for i=1,2,nk.
On entry, xv=value.
Constraint: xv>0.0.
On entry, npar=value.
Constraint: npar=p+q+P+Q.
On entry, nwa=value and the minimum size required=value.
Constraint: nwamax(p2+p,4(q+1)), where p=max(p,P) and q=max(q,Q).
Satisfactory parameter estimates could not be obtained for all parameter types in the model. Inspect array isf for indicators of the parameter type(s) which could not estimated.
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 performance of the algorithm is conditioned by the roots of the autoregressive and moving average operators. If these are not close to unity in modulus, the errors, e, should satisfy e<100ε where ε is machine precision.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g13adf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13adf 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.

9 Further Comments

The time taken by g13adf is approximately proportional to (p3+q2+P3+Q2).

10 Example

This example reads the sample autocorrelations to lag 40 and the sample variance of the lagged and doubly differenced series of airline passenger totals (Box and Jenkins example series G (see Box and Jenkins (1976))). Preliminary estimates of the parameters of the (0,1,1,0,1,1,12) model are obtained by a call to g13adf.

10.1 Program Text

Program Text (g13adfe.f90)

10.2 Program Data

Program Data (g13adfe.d)

10.3 Program Results

Program Results (g13adfe.r)