PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_tsa_uni_arima_estim_easy (g13af)
Purpose
nag_tsa_uni_arima_estim_easy (g13af) is an easy-to-use version of
nag_tsa_uni_arima_estim (g13ae). It 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 in
nag_tsa_uni_arima_update (g13ag) and
nag_tsa_uni_arima_forecast_state (g13ah).
The estimation procedure is iterative, starting with initial parameter values such as may be obtained using
nag_tsa_uni_arima_prelim (g13ad). It continues until a specified convergence criterion is satisfied or until a specified number of iterations have been carried out. The progress of the iteration can be monitored by means of an optional printing facility.
Syntax
[
par,
c,
s,
ndf,
sd,
cm,
st,
nst,
itc,
isf,
res,
nres,
ifail] = g13af(
mr,
par,
c,
x, 'npar',
npar, 'kfc',
kfc, 'nx',
nx, 'kpiv',
kpiv, 'nit',
nit, 'ires',
ires)
[
par,
c,
s,
ndf,
sd,
cm,
st,
nst,
itc,
isf,
res,
nres,
ifail] = nag_tsa_uni_arima_estim_easy(
mr,
par,
c,
x, 'npar',
npar, 'kfc',
kfc, 'nx',
nx, 'kpiv',
kpiv, 'nit',
nit, 'ires',
ires)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: |
ires, nit, kpiv and kfc were made optional; npcc was removed from the interface |
Description
The time series
supplied to the function 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
nag_tsa_uni_diff (g13aa). 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
.
The minimization process is iterative, iterations being performed until convergence is achieved (see
Description in
nag_tsa_uni_arima_estim (g13ae) for full details), or until the user-specified maximum number of iterations are completed.
The final values of the residual sum of squares and the parameter estimates are used to obtain asymptotic approximations to the standard deviations of the parameters, and the correlation matrix for the parameters. The ‘state set’ array of information required by forecasting is also returned.
Note: if the maximum number of iterations are performed without convergence, these quantities may not be reliable. In this case, the sequence of iterates should be checked, using the optional monitoring function, to verify that convergence is adequate for practical purposes.
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
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int array
-
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:
– double array
-
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.
- 3:
– double scalar
-
If
,
c must contain the expected value,
, of the differenced series.
If
,
c must contain an initial estimate of
.
Therefore, if
c and
kfc are both zero on entry, there is no constant correction.
- 4:
– double array
-
The values of the original undifferenced time series.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
par.
The total number of , , and parameters to be estimated.
Constraint:
.
- 2:
– int64int32nag_int scalar
Default:
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 .
- 3:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
, the length of the original undifferenced time series.
- 4:
– int64int32nag_int scalar
Default:
Must be nonzero if the progress of the optimization is to be monitored using the built-in printing facility. Otherwise
kpiv must contain zero. If selected, monitoring output will be sent to the current advisory message unit defined by
nag_file_set_unit_advisory (x04ab). For each iteration, the heading
G13AFZ MONITORING OUTPUT - ITERATION n
followed by the argument values, and residual sum of squares, are printed.
- 5:
– int64int32nag_int scalar
Default:
The maximum number of iterations to be performed.
Constraint:
.
- 6:
– int64int32nag_int scalar
Default:
The dimension of the array
res.
Constraint:
,
where and .
Output Parameters
- 1:
– double array
-
Contains the latest values of the estimates of these parameters.
- 2:
– double scalar
-
If
,
c is unchanged.
If
,
c contains the latest estimate of
.
- 3:
– double scalar
-
The residual sum of squares after the latest series of parameter estimates has been incorporated into the model. If the function exits with a faulty input argument,
s contains zero.
- 4:
– int64int32nag_int scalar
-
The number of degrees of freedom associated with
s,
.
- 5:
– double array
-
.
The standard deviations corresponding to the parameters in the model (
autoregressive,
moving average,
seasonal autoregressive,
seasonal moving average and
, if estimated, in that order). If the function 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.
- 6:
– double array
-
.
The correlation coefficients associated with each pair of the
nppc parameters. These are held in the first
nppc rows and the first
nppc columns of
cm. These correlation coefficients are indeterminate if
ifail contains on exit a value other than
or
, or if the required number of iterations is zero.
- 7:
– double array
-
The value of the state set in its first
nst elements. If the function exits with
ifail containing a value other than
or
, the contents of
st will be indeterminate.
- 8:
– int64int32nag_int scalar
-
The size of the state set.
.
- 9:
– int64int32nag_int scalar
-
The number of iterations performed.
- 10:
– int64int32nag_int array
-
The first four elements of
isf contain 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. |
- 11:
– double array
-
The first
nres elements of
res contain the model residuals derived from the differenced series. If the function exits with
ifail holding a value other than
or
, these elements of
res will be indeterminate. The rest of the array
res is used as workspace.
- 12:
– int64int32nag_int scalar
-
The number of model residuals returned in
res.
- 13:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Note: nag_tsa_uni_arima_estim_easy (g13af) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
On entry, | , |
or | the orders vector mr is invalid (check the constraints in Arguments), |
or | or , |
or | . |
-
-
On entry, , i.e., the number of terms in the differenced series is not greater than the number of parameters in the model. The model is over-parameterised.
-
-
-
-
On entry, the required size of the state set array
st is greater than
nx. This occurs only for very unusual models with long seasonal periods or large numbers of parameters. First check that the orders vector
mr has been set up as intended. If it has, change to
nag_tsa_uni_arima_estim (g13ae) with
st dimensioned at least (
nst), where
nst is the value returned by
nag_tsa_uni_arima_estim_easy (g13af), or computed using the formula in
Arguments of this document.
-
-
On entry, the workspace array
res is too small. Check the value of
ires against the constraints in
Arguments.
-
-
- W
-
The search procedure in the algorithm has failed. This may be due to a badly conditioned sum of squares function, or the default convergence criterion may be too strict. Use
nag_tsa_uni_arima_estim (g13ae) with a less strict convergence criterion.
Some output arguments may contain meaningful values; see
Arguments for details.
- W
-
The inversion of the Hessian matrix in the calculation of the covariance matrix of the parameter estimates has failed.
Some output arguments may contain meaningful values; see
Arguments for details.
- W
-
This indicates a failure when solving the equations giving the latest estimates of the backforecasts.
Some output arguments may contain meaningful values; see
Arguments for details.
- W
-
Satisfactory parameter estimates could not be obtained for all parameter types in the model. Inspect array
isf for further information on the parameter type(s) in error.
-
-
An internal error has arisen in partitioning
res for use by
nag_tsa_uni_arima_estim (g13ae). This error should not occur; report it to NAG via your site representative.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The computations are believed to be stable.
Further Comments
The time taken by nag_tsa_uni_arima_estim_easy (g13af) is approximately proportional to .
Example
This example 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.
Some intermediate monitoring output from nag_tsa_uni_arima_estim_sample_piv (g13afz) has been omitted.
Open in the MATLAB editor:
g13af_example
function g13af_example
fprintf('g13af example results\n\n');
x = [-217; -177; -166; -136; -110; -95; -64; -37; -14; -25;
-51; -62; -73; -88; -113; -120; -83; -33; -19; 21;
17; 44; 44; 78; 88; 122; 126; 114; 85; 64];
mr = [int64(1);1;2;0;0;0;0];
par = [0; 0; 0];
c = 0;
[par, c, s, ndf, sd, cm, st, nst, itc, isf, res, nres, ifail] = ...
g13af( ...
mr, par, c, x);
fprintf('Convergence was achieved after %4d cycles\n\n', itc);
fprintf('Final values of par array and the constant c are as follows\n');
fprintf('%10.4f', [par; c]);
fprintf('\n\nResidual sum of squares is %10.3f with %4d %s\n\n', ...
s, ndf, 'degrees of freedom');
fprintf('The corresponding SD array holds\n')
fprintf('%10.4f', sd);
fprintf('\n\n');
[ifail] = x04ca( ...
'General', ' ', cm, ...
'The correlation matrix is as follows');
fprintf('\nThe residuals consist of %4d values\n', nres);
for j = 1:5:nres
fprintf('%11.4f', res(j:min(j+4,nres)));
fprintf('\n');
end
fprintf('\nThe state set consists of %4d values\n', nst);
fprintf('%11.3f', st(1:nst));
fprintf('\n');
g13af example results
Convergence was achieved after 25 cycles
Final values of par array and the constant c are as follows
-0.0543 -0.5548 -0.6734 9.9848
Residual sum of squares is 9397.220 with 25 degrees of freedom
The corresponding SD array holds
0.3457 0.2636 0.1665 7.4170
The correlation matrix is as follows
1 2 3 4
1 1.0000 0.8072 0.3548 -0.0404
2 0.8072 1.0000 0.4681 -0.0491
3 0.3548 0.4681 1.0000 -0.0376
4 -0.0404 -0.0491 -0.0376 1.0000
The residuals consist of 29 values
19.6275 -5.3093 9.7983 15.2412 -9.1693
16.1107 15.3929 -5.4500 -27.6205 -18.1306
5.7202 -13.0881 -22.7151 -14.9256 4.6930
33.5406 19.7138 -27.3360 32.1231 -11.7681
1.1524 -1.7756 23.6821 -10.6238 13.9619
-5.2727 -28.7868 -20.6573 -2.2555
The state set consists of 4 values
64.000 -30.985 -20.657 -2.256
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015