NAG FL Interface
g13ahf (uni_arima_forecast_state)
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
Fortran Interface
Subroutine g13ahf ( |
st, nst, mr, par, npar, c, rms, nfv, fva, fsd, wa, nwa, ifail) |
Integer, Intent (In) |
:: |
nst, mr(7), npar, nfv, nwa |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
st(nst), par(npar), c, rms |
Real (Kind=nag_wp), Intent (Out) |
:: |
fva(nfv), fsd(nfv), wa(nwa) |
|
C Header Interface
#include <nag.h>
void |
g13ahf_ (const double st[], const Integer *nst, const Integer mr[], const double par[], const Integer *npar, const double *c, const double *rms, const Integer *nfv, double fva[], double fsd[], double wa[], const Integer *nwa, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g13ahf_ (const double st[], const Integer &nst, const Integer mr[], const double par[], const Integer &npar, const double &c, const double &rms, const Integer &nfv, double fva[], double fsd[], double wa[], const Integer &nwa, Integer &ifail) |
}
|
The routine may be called by the names g13ahf or nagf_tsa_uni_arima_forecast_state.
3
Description
The original time series is
, for
and parameters have been fitted to the model of this time series using
g13aef or
g13aff.
Forecasts of
, for
, are calculated in five stages, as follows:
-
(i)set for , where is the number of differenced values in the series;
-
(ii)calculate the values of , for , and ;
-
(iii)calculate the values of , for , where and for are the first values in the state set, corrected for the constant;
-
(iv)add the constant term to give the differenced series , for ;
-
(v)the differencing operations are reversed to reconstitute , for .
The standard errors of these forecasts are given by , for , where , is the residual variance of , and is the coefficient expressing the dependence of on .
To calculate , for , 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 , and , for .
The resulting quantities corresponding to the sequence are precisely , .
The supplied time series model is used throughout these calculations, with the exception that the constant term is taken to be zero.
4
References
None.
5
Arguments
-
1:
– Real (Kind=nag_wp) array
Input
-
On entry: the state set derived from
g13aef or
g13aff originally, or as modified using earlier calls of
g13agf.
-
2:
– Integer
Input
-
On entry: the number of values in the state set array
st.
Constraint:
. (As returned by
g13aef or
g13aff).
-
3:
– Integer array
Input
-
On entry: the orders vector of the ARIMA model, in the usual notation.
Constraints:
- ;
- ;
- ;
- if , ;
- if , .
-
4:
– Real (Kind=nag_wp) array
Input
-
On entry: the estimates of the
values of the
parameters, the
values of the
parameters, the
values of the
parameters and the
values of the
parameters which specify the model and which were output originally by
g13aef or
g13aff.
-
5:
– Integer
Input
-
On entry: the number of , , and parameters in the model.
Constraint:
.
-
6:
– Real (Kind=nag_wp)
Input
-
On entry:
, the value of the model constant. This will have been output by
g13aef or
g13aff.
-
7:
– Real (Kind=nag_wp)
Input
-
On entry:
, the residual variance associated with the model.
If
g13aff was used to estimate the model,
rms should be set to
, where
s and
ndf were output by
g13aff.
If
g13aef was used to estimate the model,
rms should be set to
, where
s and
were output by
g13aef.
Constraint:
.
-
8:
– Integer
Input
-
On entry: , the required number of forecasts.
Constraint:
.
-
9:
– Real (Kind=nag_wp) array
Output
-
On exit:
nfv forecast values relating to the original undifferenced series.
-
10:
– Real (Kind=nag_wp) array
Output
-
On exit: the standard errors associated with each of the
nfv forecast values in
fva.
-
11:
– Real (Kind=nag_wp) array
Workspace
-
12:
– Integer
Input
-
On entry: the dimension of the array
wa as declared in the (sub)program from which
g13ahf is called.
Constraint:
.
-
13:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or 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:
-
On entry, .
Constraint: .
The orders vector
mr is invalid.
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, and the minimum size .
Constraint: .
-
On entry, .
Constraint: .
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
g13ahf is not threaded in any implementation.
The time taken by g13ahf is approximately proportional to .
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 non-seasonal, and one seasonal with periodicity ).
The model constant is zero.
The state set contains values.
In addition the residual mean-square derived when the model was originally fitted is given.
Twelve forecasts and their associated errors are obtained.
10.1
Program Text
10.2
Program Data
10.3
Program Results