The function may be called by the names: g13ccc, nag_tsa_multi_spectrum_lag or nag_tsa_spectrum_bivar_cov.
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 g13cac. 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 g13cac 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 g13cac 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: – NagMeanOrTrendInput
On entry: if cross-covariances are to be calculated by the function (), mtxy_correction 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_correction should be set to
Constraint:
if , , or .
3: – doubleInput
On entry: if cross-covariances are to be calculated by the function (), 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 function or supplied in the call to the function.
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 function or supplied in the call to the function.
Constraint:
.
9: – doubleInput/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: – doubleInput/Output
Note: the dimension, dim, of the array xg
must be at least
, when ;
, otherwise.
On entry: if the cross-covariances are to be calculated () xg must contain the nxy data points of the series. If covariances are supplied () xg may contain any values.
On exit: contains the real parts of the ng complex spectral estimates in elements to , and to contain . The series leads the series.
14: – doubleInput/Output
Note: the dimension, dim, of the array yg
must be at least
, when ;
, otherwise.
On entry: if the cross-covariances are to be calculated () yg must contain the nxy data points of the series. If covariances are supplied () yg may contain any values.
On exit: contains the imaginary parts of the ng complex spectral estimates in elements to , and to contain . The series leads the series.
15: – ComplexOutput
On exit: the complex vector that contains the ng cross spectral estimates in elements to . The series leads the series.
16: – Integer *Output
On exit: the number, , of complex spectral estimates.
17: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument had an illegal value.
NE_INT
On entry, .
Constraint: , , or .
On entry, .
Constraint: if then , or .
On entry, .
Constraint: .
On entry, .
Constraint: .
NE_INT_2
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
NE_INT_3
On entry, , and .
Constraint: if , .
On entry, , and .
Constraint: .
On entry, , and .
Constraint: .
NE_INT_REAL
On entry, .
Constraint: if , .
On entry, .
Constraint: if , .
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL 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
Background information to multithreading can be found in the Multithreading documentation.
g13ccc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13ccc 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
9Further Comments
g13ccc 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 g13ccc 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 c06pac 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 g13ccc to calculate the cross spectrum and then prints the cross-covariances and cross spectrum.