3 Description

The smoothed sample cross spectrum is a complex valued function of frequency ω, fxyω=cfω+iqfω, defined by its real part or co-spectrum

cfω=12π∑k=-M+1M-1wkCxyk+Scosωk

and imaginary part or quadrature spectrum

qfω=12π∑k=-M+1M-1wkCxyk+Ssinωk

where wk=w-k, for k=0,1,…,M-1, is the smoothing lag window as defined in the description of G13CAF. The alignment shift S is recommended to be chosen as the lag k at which the cross-covariances cxyk peak, so as to minimize bias.

The results are calculated for frequency values

ωj=2πjL, j=0,1,…,L/2,

where denotes the integer part.

The cross-covariances cxyk may be supplied by you, or constructed from supplied series x1,x2,…,xn; y1,y2,…,yn as

cxyk=∑t=1n-kxtyt+kn, k≥0

cxyk=∑t=1-knxtyt+kn=cyx-k, k<0

this convolution being carried out using the finite Fourier transform.

The supplied series may be mean and trend corrected and tapered before calculation of the cross-covariances, in exactly the manner described in G13CAF for univariate spectrum estimation. The results are corrected for any bias due to tapering.

The bandwidth associated with the estimates is not returned. It will normally already have been calculated in previous calls of G13CAF for estimating the univariate spectra of yt and xt.

On entry: if cross-covariances are to be calculated by the routine (IC=0), PXY must specify the proportion of the data (totalled over both ends) to be initially tapered by the split cosine bell taper. A value of 0.0 implies no tapering.

On entry: if IC=0, KC must specify the order of the fast Fourier transform (FFT) used to calculate the cross-covariances. KC should be a product of small primes such as 2m where m is the smallest integer such that 2m≥n+NC.

Constraint:
KC≥NXY+NC. The largest prime factor of KC must not exceed 19, and the total number of prime factors of KC, counting repetitions, must not exceed 20. These two restrictions are imposed by the internal FFT algorithm used.

12: L – INTEGERInput

On entry: L, the frequency division of the spectral estimates as 2πL. Therefore it is also the order of the FFT used to construct the sample spectrum from the cross-covariances. L should be a product of small primes such as 2m where m is the smallest integer such that 2m≥2M-1.

Constraint:
L≥2×MW-1. The largest prime factor of L must not exceed 19, and the total number of prime factors of L, counting repetitions, must not exceed 20. These two restrictions are imposed by the internal FFT algorithm used.

13: NXYG – INTEGERInput

On entry: the dimension of the arrays XG and YG as declared in the (sub)program from which G13CCF is called.

On entry: if cross-covariances are to be calculated, YG must contain the NXY data points of the y series. If covariances are supplied, YG need not be set.

On exit: contains the imaginary parts of the NG complex spectral estimates in elements YG1 to YGNG, and YGNG+1 to YGNXYG contain 0.0. The y series leads the x series.

16: NG – INTEGEROutput

On exit: the number, L/2+1, of complex spectral estimates, whose separate parts are held in XG and YG.

17: IFAIL – INTEGERInput/Output

On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.

For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.

On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).

7 Accuracy

The FFT is a numerically stable process, and any errors introduced during the computation will normally be insignificant compared with uncertainty in the data.

8 Further Comments

G13CCF carries out two FFTs of length KC to calculate the sample cross-covariances and one FFT of length L to calculate the sample spectrum. The timing of G13CCF is therefore dependent on the choice of these values. The time taken for an FFT of length n is approximately proportional to nlog⁡n (but see Section 8 in C06PAF for further details).

9 Example

This example reads two time series of length 296. It then selects mean correction, a 10% tapering proportion, the Parzen smoothing window and a cut-off point of 35 for the lag window. The alignment shift is set to 3 and 50 cross-covariances are chosen to be calculated. The program then calls G13CCF to calculate the cross spectrum and then prints the cross-covariances and cross spectrum.