The routine may be called by the names g13ccf or nagf_tsa_multi_spectrum_lag.
3Description
The smoothed sample cross spectrum is a complex valued function of frequency , , defined by its real part or co-spectrum
and imaginary part or quadrature spectrum
where , for , is the smoothing lag window as defined in the description of g13caf. The alignment shift is recommended to be chosen as the lag at which the cross-covariances peak, so as to minimize bias.
The results are calculated for frequency values
where denotes the integer part.
The cross-covariances may be supplied by you, or constructed from supplied series ; as
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 and .
4References
Bloomfield P (1976) Fourier Analysis of Time Series: An Introduction Wiley
Jenkins G M and Watts D G (1968) Spectral Analysis and its Applications Holden–Day
5Arguments
1: – IntegerInput
On entry: , the length of the time series and .
Constraint:
.
2: – IntegerInput
On entry: if cross-covariances are to be calculated by the routine (), mtxy must specify whether the data is to be initially mean or trend corrected.
For no correction.
For mean correction.
For trend correction.
If cross-covariances are supplied , mtxy is not used.
Constraint:
if , , or .
3: – Real (Kind=nag_wp)Input
On entry: if cross-covariances are to be calculated by the routine (), 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 implies no tapering.
If cross-covariances are supplied , pxy is not used.
Constraint:
if , .
4: – IntegerInput
On entry: the choice of lag window.
Rectangular.
Bartlett.
Tukey.
Parzen.
Constraint:
.
5: – IntegerInput
On entry: , the ‘cut-off’ point of the lag window, relative to any alignment shift that has been applied. Windowed cross-covariances at lags or less, and at lags or greater are zero.
Constraints:
;
.
6: – IntegerInput
On entry: , the alignment shift between the and series. If leads , the shift is positive.
Constraint:
.
7: – IntegerInput
On entry: indicates whether cross-covariances are to be calculated in the routine or supplied in the call to the routine.
Cross-covariances are to be calculated.
Cross-covariances are to be supplied.
8: – IntegerInput
On entry: the number of cross-covariances to be calculated in the routine or supplied in the call to the routine.
Constraint:
.
9: – Real (Kind=nag_wp) arrayInput/Output
On entry: if , cxy must contain the nc cross-covariances between values in the series and earlier values in time in the series, for lags from to .
On entry: if , kc must specify the order of the fast Fourier transform (FFT) used to calculate the cross-covariances.
If , that is if covariances are supplied, kc is not used.
Constraint:
.
12: – IntegerInput
On entry: , the frequency division of the spectral estimates as . Therefore, it is also the order of the FFT used to construct the sample spectrum from the cross-covariances.
Constraint:
.
13: – IntegerInput
On entry: the dimension of the arrays xg and yg as declared in the (sub)program from which g13ccf is called.
Constraints:
if , ;
otherwise .
14: – Real (Kind=nag_wp) arrayInput/Output
On entry: if the cross-covariances are to be calculated, then xg must contain the nxy data points of the series. If covariances are supplied, xg need not be set.
On exit: contains the real parts of the ng complex spectral estimates in elements to , and to contain . The series leads the series.
15: – Real (Kind=nag_wp) arrayInput/Output
On entry: if cross-covariances are to be calculated, yg must contain the nxy data points of the series. If covariances are supplied, yg need not be set.
On exit: contains the imaginary parts of the ng complex spectral estimates in elements to , and to contain . The series leads the series.
16: – IntegerOutput
On exit: the number, , of complex spectral estimates, whose separate parts are held in xg and yg.
17: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, , and .
Constraint: if , .
On entry, and .
Constraint: .
On entry, .
Constraint: , , or .
On entry, .
Constraint: if then , or .
On entry, , and .
Constraint: .
On entry, .
Constraint: .
On entry, , and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, , and .
Constraint: if , .
On entry, .
Constraint: if , .
On entry, .
Constraint: if , .
On entry, , and .
Constraint: if , .
On entry, and .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
The FFT is a numerically stable process, and any errors introduced during the computation will normally be insignificant compared with uncertainty in the data.
8Parallelism and Performance
g13ccf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13ccf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
9Further Comments
g13ccf carries out two FFTs of length kc to calculate the sample cross-covariances and one FFT of length 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 is approximately proportional to (but see Section 9 in c06paf for further details).
10Example
This example reads two time series of length . It then selects mean correction, a 10% tapering proportion, the Parzen smoothing window and a cut-off point of for the lag window. The alignment shift is set to and 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.