NAG Library Routine Document
G13CDF
1 Purpose
G13CDF calculates the smoothed sample cross spectrum of a bivariate time series using spectral smoothing by the trapezium frequency (Daniell) window.
2 Specification
SUBROUTINE G13CDF ( |
NXY, MTXY, PXY, MW, ISH, PW, L, KC, XG, YG, NG, IFAIL) |
INTEGER |
NXY, MTXY, MW, ISH, L, KC, NG, IFAIL |
REAL (KIND=nag_wp) |
PXY, PW, XG(KC), YG(KC) |
|
3 Description
The supplied time series may be mean and trend corrected and tapered as in the description of
G13CBF before calculation of the unsmoothed sample cross-spectrum
for frequency values
,
.
A correction is made for bias due to any tapering.
As in the description of
G13CBF for univariate frequency window smoothing, the smoothed spectrum is returned as a subset of these frequencies,
where [ ] denotes the integer part.
Its real part or co-spectrum
, and imaginary part or quadrature spectrum
are defined by
where the weights
are similar to the weights
defined for
G13CBF, but allow for an implicit alignment shift
between the series:
It is recommended that
is chosen as the lag
at which the cross-covariances
peak, so as to minimize bias.
If no smoothing is required, the integer , which determines the frequency window width , should be set to .
The bandwidth of the estimates will normally have been calculated in a previous call of
G13CBF for estimating the univariate spectra of
and
.
4 References
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
5 Parameters
- 1: NXY – INTEGERInput
On entry: , the length of the time series and .
Constraint:
.
- 2: MTXY – INTEGERInput
On entry: whether the data is to be initially mean or trend corrected.
- For no correction.
- For mean correction.
- For trend correction.
Constraint:
.
- 3: PXY – REAL (KIND=nag_wp)Input
On entry: 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.
Constraint:
.
- 4: MW – INTEGERInput
On entry:
, the frequency width of the smoothing window as
.
A value of implies that no smoothing is to be carried out.
Constraint:
.
- 5: ISH – INTEGERInput
On entry: , the alignment shift between the and series. If leads , the shift is positive.
Constraint:
.
- 6: PW – REAL (KIND=nag_wp)Input
On entry:
, the shape parameter of the trapezium frequency window.
A value of gives a triangular window, and a value of a rectangular window.
If
(i.e., no smoothing is carried out) then
PW is not used.
Constraint:
if , .
- 7: L – INTEGERInput
On entry: , the frequency division of smoothed cross spectral estimates as .
Constraints:
- ;
- L must be a factor of KC.
- 8: KC – INTEGERInput
On entry: the dimension of the arrays
XG and
YG as declared in the (sub)program from which G13CDF is called. The order of the fast Fourier transform ( FFT) used to calculate the spectral estimates.
KC should be a product of small primes such as
where
is the smallest integer such that
, provided
.
Constraints:
- ;
- KC must be a multiple of L. The largest prime factor of KC must not exceed , and the total number of prime factors of KC, counting repetitions, must not exceed . These two restrictions are imposed by the internal FFT algorithm used.
- 9: XG(KC) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the
NXY data points of the
series.
On exit: the real parts of the
NG cross spectral estimates in elements
to
, and
to
contain
. The
series leads the
series.
- 10: YG(KC) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the
NXY data points of the
series.
On exit: the imaginary parts of the
NG cross spectral estimates in elements
to
, and
to
contain
. The
series leads the
series.
- 11: NG – INTEGEROutput
On exit: the number of spectral estimates,
, whose separate parts are held in
XG and
YG.
- 12: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value 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).
6 Error 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, | , |
or | , |
or | , |
or | , |
or | , |
or | , |
or | , |
or | and , |
or | and , |
or | , |
or | . |
On entry, | , |
or | KC is not a multiple of L, |
or | KC has a prime factor exceeding , |
or | KC has more than prime factors, counting repetitions. |
This indicates that a serious error has occurred. Check all array subscripts in calls to G13CDF. Seek expert help.
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.
G13CDF carries out an FFT of length
KC to calculate the sample cross spectrum. The time taken by the routine for this is approximately proportional to
(but see routine document
C06PAF for further details).
9 Example
This example reads two time series of length . It selects mean correction and a 10% tapering proportion. It selects a frequency width of smoothing window, a window shape parameter of and an alignment shift of . It then calls G13CDF to calculate the smoothed sample cross spectrum and prints the results.
9.1 Program Text
Program Text (g13cdfe.f90)
9.2 Program Data
Program Data (g13cdfe.d)
9.3 Program Results
Program Results (g13cdfe.r)