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.
Syntax
C# |
---|
public static void g13ab( double[] x, int nx, int nk, out double xm, out double xv, double[] r, out double stat, out int ifail ) |
Visual Basic |
---|
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 _ ) |
Visual C++ |
---|
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 ) |
F# |
---|
static member g13ab : x : float[] * nx : int * nk : int * xm : float byref * xv : float byref * r : float[] * stat : float byref * ifail : int byref -> unit |
Parameters
- x
- Type: array<System..::..Double>[]()[][]An array of size [nx]On entry: the time series, , for .
- nx
- Type: System..::..Int32On entry: , the number of values in the time series.Constraint: .
- nk
- 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: .
- xm
- Type: System..::..Double%On exit: the sample mean of the input time series.
- xv
- Type: System..::..Double%On exit: the sample variance of the input time series.
- r
- Type: array<System..::..Double>[]()[][]An array of size [nk]On exit: the sample autocorrelation coefficient relating to lag , for .
- stat
- Type: System..::..Double%On exit: the statistic used to test the hypothesis that the true autocorrelation function of the time series is identically zero.
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
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
|
||
(d) | A test statistic defined as
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.
Section 8.2.2 of Box and Jenkins (1976) provides further details of the use of stat. |
References
Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
Error Indicators and Warnings
Errors or warnings detected by the method:
On entry, , or , or .
Accuracy
The computations are believed to be stable.
Parallelism and Performance
None.
Further Comments
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.
Example
In the example below, a set of values of sunspot counts is used as input. The first autocorrelations are computed.
Example program (C#): g13abe.cs