g13ab 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.
Public Shared Sub g13ab ( _ x As Double(), _ nx As Integer, _ nk As Integer, _ <OutAttribute> ByRef xm As Double, _ <OutAttribute> ByRef xv As Double, _ r As Double(), _ <OutAttribute> ByRef stat As Double, _ <OutAttribute> ByRef ifail As Integer _ )
public: static void g13ab( array<double>^ x, int nx, int nk, [OutAttribute] double% xm, [OutAttribute] double% xv, array<double>^ r, [OutAttribute] double% stat, [OutAttribute] int% ifail )
- Type: System..::..Int32On entry: , the number of values in the time series.Constraint: .
- Type: System..::..Int32On entry: , the number of lags for which the autocorrelations are required. The lags range from to and do not include zero.Constraint: .
- Type: System..::..Double%On exit: the sample mean of the input time series.
- Type: System..::..Double%On exit: the sample variance of the input time series.
- Type: array<System..::..Double>()An array of size [nk]On exit: the sample autocorrelation coefficient relating to lag , for .
- Type: System..::..Double%On exit: the statistic used to test the hypothesis that the true autocorrelation function of the time series is identically zero.
The data consists of observations , for from a time series.
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 , .
The coefficient of lag is defined as
See page 496 of Box and Jenkins (1976) for further details.
|(d)||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; g01ec can be used to compute the tail probability.
Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
Errors or warnings detected by the method:
On entry, , or , or .
The computations are believed to be stable.
If , or then the autocorrelations are calculated directly and the time taken by g13ab is approximately proportional to , otherwise the autocorrelations are calculated by utilizing fast fourier transforms (FFTs) and the time taken is approximately proportional to . If FFTs are used then g13ab internally allocates approximately real elements.
In the example below, a set of values of sunspot counts is used as input. The first autocorrelations are computed.