nag_tsa_auto_corr (g13abc) computes the sample autocorrelation function of a time series. It also computes the sample mean, the sample variance and a statistic which may be used to test the hypothesis that the true autocorrelation function is zero.
The quantities calculated are:
(a) |
The sample mean
|
(b) |
The sample variance (for )
|
(c) |
The sample autocorrelation coefficients of lags , where is a user-specified maximum lag, and , . |
(d) |
The coefficient of lag is defined as
|
(e) |
See page 496 et seq. of Box and Jenkins (1976) for further details. |
(f) |
A test statistic defined as
which can be used to test the hypothesis that the true autocorrelation function is identically zero. |
If
is large and
is much smaller than
,
stat has a
distribution under the hypothesis of a zero autocorrelation function. Values of
stat in the upper tail of the distribution provide evidence against the hypothesis.
Section 8.2.2 of
Box and Jenkins (1976) provides further details of the use of
stat.
- 1:
x[nx] – const doubleInput
-
On entry: the time series, , for .
- 2:
nx – IntegerInput
On entry: the number of values, , in the time series.
Constraint:
.
- 3:
nk – IntegerInput
On entry: the number of lags, , for which the autocorrelations are required. The lags range from 1 to and do not include zero.
Constraint:
.
- 4:
mean – double *Output
-
On exit: the sample mean of the input time series.
- 5:
var – double *Output
-
On exit: the sample variance of the input time series.
- 6:
r[nk] – doubleOutput
-
On exit: the sample autocorrelation coefficient relating to lag , for .
- 7:
stat – double *Output
-
On exit: the statistic used to test the hypothesis that the true autocorrelation function of the time series is identically zero.
- 8:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
The computations are believed to be stable.
Not applicable.
In the example below, a set of 50 values of sunspot counts is used as input. The first 10 autocorrelations are computed.