NAG Library Routine Document
G13AHF
1 Purpose
G13AHF produces forecasts of a time series, given a time series model which has already been fitted to the time series using
G13AEF or
G13AFF. The original observations are not required, since G13AHF uses as input either the original state set produced by
G13AEF or
G13AFF or the state set updated by a series of new observations using
G13AGF. Standard errors of the forecasts are also provided.
2 Specification
SUBROUTINE G13AHF ( 
ST, NST, MR, PAR, NPAR, C, RMS, NFV, FVA, FSD, WA, NWA, IFAIL) 
INTEGER 
NST, MR(7), NPAR, NFV, NWA, IFAIL 
REAL (KIND=nag_wp) 
ST(NST), PAR(NPAR), C, RMS, FVA(NFV), FSD(NFV), WA(NWA) 

3 Description
The original time series is
${x}_{\mathit{t}}$, for
$\mathit{t}=1,2,\dots ,n$ and parameters have been fitted to the model of this time series using
G13AEF or
G13AFF.
Forecasts of
${x}_{\mathit{t}}$, for
$\mathit{t}=n+1,\dots ,n+L$, are calculated in five stages, as follows:
(i) 
set ${a}_{t}=0$ for $t=N+1,N+2,\dots ,N+L$, where $N=nd\left(D\times s\right)$ is the number of differenced values in the series; 
(ii) 
calculate the values of ${e}_{\mathit{t}}$, for $\mathit{t}=N+1,\dots ,N+L$, and ${e}_{\mathit{t}}={\varphi}_{1}\times {e}_{t1}+\cdots +\phantom{\rule{0ex}{0ex}}{\varphi}_{p}\times {e}_{tp}+{a}_{t}{\theta}_{1}\times {a}_{t1}\cdots {\theta}_{q}\times {a}_{tq}$; 
(iii) 
calculate the values of ${w}_{\mathit{t}}$, for $\mathit{t}=N+1,\dots ,N+L$, where ${w}_{t}={\Phi}_{1}\times {w}_{ts}+\cdots +\phantom{\rule{0ex}{0ex}}{\Phi}_{P}\times {w}_{ts\times P}+{e}_{t}{\Theta}_{1}\times {e}_{ts}\cdots {\Theta}_{Q}\times {e}_{ts\times Q}$ and ${w}_{t}$ for $t\le N$ are the first $s\times P$ values in the state set, corrected for the constant; 
(iv) 
add the constant term $c$ to give the differenced series ${\nabla}^{d}{\nabla}_{s}^{D}{x}_{\mathit{t}}={w}_{\mathit{t}}+c$, for $\mathit{t}=N+1,\dots ,N+L$; 
(v) 
the differencing operations are reversed to reconstitute ${x}_{\mathit{t}}$, for $\mathit{t}=n+1,\dots ,n+L$. 
The standard errors of these forecasts are given by ${s}_{\mathit{t}}={\left[V\times \left({\psi}_{0}^{2}+{\psi}_{1}^{2}+\dots +{\psi}_{\mathit{t}n1}^{2}\right)\right]}^{1/2}$, for $\mathit{t}=n+1,\dots ,n+L$, where ${\psi}_{0}=1$, $V$ is the residual variance of ${a}_{t}$, and ${\psi}_{j}$ is the coefficient expressing the dependence of ${x}_{t}$ on ${a}_{tj}$.
To calculate ${\psi}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,\left(L1\right)$, the following device is used.
A copy of the state set is initialized to zero throughout and the calculations outlined above for the construction of forecasts are carried out with the settings ${a}_{N+1}=1$, and ${a}_{\mathit{t}}=0$, for $\mathit{t}=N+2,\dots ,N+L$.
The resulting quantities corresponding to the sequence ${x}_{N+1},{x}_{N+2},\dots ,{x}_{N+L}$ are precisely $1$, ${\psi}_{1},{\psi}_{2},\dots ,{\psi}_{L1}$.
The supplied time series model is used throughout these calculations, with the exception that the constant term $c$ is taken to be zero.
4 References
None.
5 Parameters
 1: $\mathrm{ST}\left({\mathbf{NST}}\right)$ – REAL (KIND=nag_wp) arrayInput

On entry: the state set derived from
G13AEF or
G13AFF originally, or as modified using earlier calls of
G13AGF.
 2: $\mathrm{NST}$ – INTEGERInput

On entry: the number of values in the state set array
ST.
Constraint:
${\mathbf{NST}}=P\times s+D\times s+d+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,Q\times s\right)$. (As returned by
G13AEF or
G13AFF).
 3: $\mathrm{MR}\left(7\right)$ – INTEGER arrayInput

On entry: the orders vector $\left(p,d,q,P,D,Q,s\right)$ of the ARIMA model, in the usual notation.
Constraints:
 $p,d,q,P,D,Q,s\ge 0$;
 $p+q+P+Q>0$;
 $s\ne 1$;
 if $s=0$, $P+D+Q=0$;
 if $s>1$, $P+D+Q>0$.
 4: $\mathrm{PAR}\left({\mathbf{NPAR}}\right)$ – REAL (KIND=nag_wp) arrayInput

On entry: the estimates of the
$p$ values of the
$\varphi $ parameters, the
$q$ values of the
$\theta $ parameters, the
$P$ values of the
$\Phi $ parameters and the
$Q$ values of the
$\Theta $ parameters which specify the model and which were output originally by
G13AEF or
G13AFF.
 5: $\mathrm{NPAR}$ – INTEGERInput

On entry: the number of $\varphi $, $\theta $, $\Phi $ and $\Theta $ parameters in the model.
Constraint:
${\mathbf{NPAR}}=p+q+P+Q$.
 6: $\mathrm{C}$ – REAL (KIND=nag_wp)Input

On entry:
$c$, the value of the model constant. This will have been output by
G13AEF or
G13AFF.
 7: $\mathrm{RMS}$ – REAL (KIND=nag_wp)Input

On entry:
$V$, the residual variance associated with the model.
If
G13AFF was used to estimate the model,
RMS should be set to
${\mathbf{S}}/{\mathbf{NDF}}$, where
S and
NDF were output by
G13AFF.
If
G13AEF was used to estimate the model,
RMS should be set to
${\mathbf{S}}/{\mathbf{ICOUNT}}\left(5\right)$, where
S and
${\mathbf{ICOUNT}}\left(5\right)$ were output by
G13AEF.
Constraint:
${\mathbf{RMS}}\ge 0.0$.
 8: $\mathrm{NFV}$ – INTEGERInput

On entry: $L$, the required number of forecasts.
Constraint:
${\mathbf{NFV}}>0$.
 9: $\mathrm{FVA}\left({\mathbf{NFV}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit:
NFV forecast values relating to the original undifferenced series.
 10: $\mathrm{FSD}\left({\mathbf{NFV}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: the standard errors associated with each of the
NFV forecast values in
FVA.
 11: $\mathrm{WA}\left({\mathbf{NWA}}\right)$ – REAL (KIND=nag_wp) arrayWorkspace
 12: $\mathrm{NWA}$ – INTEGERInput

On entry: the dimension of the array
WA as declared in the (sub)program from which G13AHF is called.
Constraint:
${\mathbf{NWA}}\ge \left(4\times {\mathbf{NPAR}}+3\times {\mathbf{NST}}\right)$.
 13: $\mathrm{IFAIL}$ – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ 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\text{ or}1$ is recommended. If the output of error messages is undesirable, then the value
$1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
$0$.
When the value $\mathbf{1}\text{ or}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit:
${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${{\mathbf{1}}}$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
 ${\mathbf{IFAIL}}=1$

On entry,  ${\mathbf{NPAR}}\ne p+q+P+Q$, 
or  the orders vector MR is invalid (check the constraints given in Section 5). 
 ${\mathbf{IFAIL}}=2$

On entry,  ${\mathbf{NST}}\ne P\times s+D\times s+d+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(Q\times s,p\right)$. 
 ${\mathbf{IFAIL}}=3$

On entry,  ${\mathbf{NFV}}\le 0$. 
 ${\mathbf{IFAIL}}=4$

On entry,  ${\mathbf{NWA}}<4\times {\mathbf{NPAR}}+3\times {\mathbf{NST}}$. 
 ${\mathbf{IFAIL}}=5$

On entry,  ${\mathbf{RMS}}<0.0$. 
 ${\mathbf{IFAIL}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
 ${\mathbf{IFAIL}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
 ${\mathbf{IFAIL}}=999$
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
The computations are believed to be stable.
8 Parallelism and Performance
Not applicable.
The time taken by G13AHF is approximately proportional to ${\mathbf{NFV}}\times {\mathbf{NPAR}}$.
10 Example
The following program is based on the data derived in the example used to illustrate
G13AGF.
These consist of a set of orders indicating that there are two moving average parameters (one nonseasonal, and one seasonal with periodicity $12$).
The model constant is zero.
The state set contains $26$ values.
In addition the residual meansquare derived when the model was originally fitted is given.
Twelve forecasts and their associated errors are obtained.
10.1 Program Text
Program Text (g13ahfe.f90)
10.2 Program Data
Program Data (g13ahfe.d)
10.3 Program Results
Program Results (g13ahfe.r)