g13bc calculates cross-correlations between two time series.
Public Shared Sub g13bc ( _ x As Double(), _ y As Double(), _ nxy As Integer, _ nl As Integer, _ <OutAttribute> ByRef s As Double, _ <OutAttribute> ByRef r0 As Double, _ r As Double(), _ <OutAttribute> ByRef stat As Double, _ <OutAttribute> ByRef ifail As Integer _ )
public: static void g13bc( array<double>^ x, array<double>^ y, int nxy, int nl, [OutAttribute] double% s, [OutAttribute] double% r0, array<double>^ r, [OutAttribute] double% stat, [OutAttribute] int% ifail )
- Type: System..::..Int32On entry: , the length of the time series.Constraint: .
- Type: System..::..Int32On entry: , the maximum lag for calculating cross-correlations.Constraint: .
- Type: System..::..Double%On exit: the ratio of the standard deviation of the series to the standard deviation of the series, .
- Type: System..::..Double%On exit: the cross-correlation between the and series at lag zero.
- Type: array<System..::..Double>()An array of size [nl]On exit: contains the cross-correlations between the and series at lags , , for .
- Type: System..::..Double%On exit: the statistic for testing for absence of cross-correlation.
Given two series and the method calculates the cross-correlations between and lagged values of :
and similarly for .
The ratio of standard deviations is also returned, and a portmanteau statistic is calculated:
Provided is large, much less than , and both are samples of series whose true autocorrelation functions are zero, then, under the null hypothesis that the true cross-correlations between the series are zero, stat has a -distribution with degrees of freedom. Values of stat in the upper tail of this distribution provide evidence against the null hypothesis.
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 .
- One or both of the and series have zero variance and hence cross-correlations cannot be calculated.
All computations are believed to be stable.
If , or then the autocorrelations are calculated directly and the time taken by g13bc 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 g13bc internally allocates approximately real elements.
This example reads two time series of length . It calculates and prints the cross-correlations up to lag for the first series leading the second series and then for the second series leading the first series.