NAG FL Interface
g13cef (multi_​spectrum_​bivar)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

For a bivariate time series, g13cef calculates the cross amplitude spectrum and squared coherency, together with lower and upper bounds from the univariate and bivariate (cross) spectra.

2 Specification

Fortran Interface
Subroutine g13cef ( xg, yg, xyrg, xyig, ng, stats, ca, calw, caup, t, sc, sclw, scup, ifail)
Integer, Intent (In) :: ng
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: xg(ng), yg(ng), xyrg(ng), xyig(ng), stats(4)
Real (Kind=nag_wp), Intent (Out) :: ca(ng), calw(ng), caup(ng), t, sc(ng), sclw(ng), scup(ng)
C Header Interface
#include <nag.h>
void  g13cef_ (const double xg[], const double yg[], const double xyrg[], const double xyig[], const Integer *ng, const double stats[], double ca[], double calw[], double caup[], double *t, double sc[], double sclw[], double scup[], Integer *ifail)
The routine may be called by the names g13cef or nagf_tsa_multi_spectrum_bivar.

3 Description

Estimates of the cross amplitude spectrum A(ω) and squared coherency W(ω) are calculated for each frequency ω as
A(ω)=|fxy(ω)|=cf (ω) 2+qf (ω) 2  and W(ω)= |fxy(ω)|2fxx(ω)fyy(ω) ,  
where
The same type and amount of smoothing should be used for these estimates, and this is specified by the degrees of freedom and bandwidth values which are passed from the calls of g13caf or g13cbf.
Upper and lower 95% confidence limits for the cross amplitude are given approximately by
A(ω) [1±(1.96/d)W(ω)−1+1] ,  
except that a negative lower limit is reset to 0.0, in which case the approximation is rather poor. You are, therefore, particularly recommended to compare the coherency estimate W(ω) with the critical value T derived from the upper 5% point of the F-distribution on (2,d-2) degrees of freedom:
T=2F d-2+2F ,  
where d is the degrees of freedom associated with the univariate spectrum estimates. The value of T is returned by the routine.
The hypothesis that the series are unrelated at frequency ω, i.e., that both the true cross amplitude and coherency are zero, may be rejected at the 5% level if W(ω)>T. Tests at two frequencies separated by more than the bandwidth may be taken to be independent.
The confidence limits on A(ω) are strictly appropriate only at frequencies for which the coherency is significant. The same applies to the confidence limits on W(ω) which are however calculated at all frequencies using the approximation that arctanh(W(l)) is Normal with variance 1/d.

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 Arguments

1: xg(ng) Real (Kind=nag_wp) array Input
On entry: the ng univariate spectral estimates, fxx(ω), for the x series.
2: yg(ng) Real (Kind=nag_wp) array Input
On entry: the ng univariate spectral estimates, fyy(ω), for the y series.
3: xyrg(ng) Real (Kind=nag_wp) array Input
On entry: the real parts, cf(ω), of the ng bivariate spectral estimates for the x and y series. The x series leads the y series.
4: xyig(ng) Real (Kind=nag_wp) array Input
On entry: the imaginary parts, qf(ω), of the ng bivariate spectral estimates for the x and y series. The x series leads the y series.
Note:  the two univariate and the bivariate spectra must each have been calculated using the same method of smoothing. For rectangular, Bartlett, Tukey or Parzen smoothing windows, the same cut-off point of lag window and the same frequency division of the spectral estimates must be used. For the trapezium frequency smoothing window, the frequency width and the shape of the window and the frequency division of the spectral estimates must be the same. The spectral estimates and statistics must also be unlogged.
5: ng Integer Input
On entry: the number of spectral estimates in each of the arrays xg, yg, xyrg and xyig. It is also the number of cross amplitude spectral and squared coherency estimates.
Constraint: ng1.
6: stats(4) Real (Kind=nag_wp) array Input
On entry: the four associated statistics for the univariate spectral estimates for the x and y series. stats(1) contains the degrees of freedom, stats(2) and stats(3) contain the lower and upper bound multiplying factors respectively and stats(4) contains the bandwidth.
Constraints:
  • stats(1)3.0;
  • 0.0<stats(2)1.0;
  • stats(3)1.0.
7: ca(ng) Real (Kind=nag_wp) array Output
On exit: the ng cross amplitude spectral estimates A^(ω) at each frequency of ω.
8: calw(ng) Real (Kind=nag_wp) array Output
On exit: the ng lower bounds for the ng cross amplitude spectral estimates.
9: caup(ng) Real (Kind=nag_wp) array Output
On exit: the ng upper bounds for the ng cross amplitude spectral estimates.
10: t Real (Kind=nag_wp) Output
On exit: the critical value for the significance of the squared coherency, T.
11: sc(ng) Real (Kind=nag_wp) array Output
On exit: the ng squared coherency estimates, W^(ω) at each frequency ω.
12: sclw(ng) Real (Kind=nag_wp) array Output
On exit: the ng lower bounds for the ng squared coherency estimates.
13: scup(ng) Real (Kind=nag_wp) array Output
On exit: the ng upper bounds for the ng squared coherency estimates.
14: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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).
Errors or warnings detected by the routine:
Note: if more than one failure of the types 2, 3, 4 and 5 occurs then the failure type which occurred at lowest frequency is returned in ifail. However the actions indicated above are also carried out for failures at higher frequencies.
ifail=1
On entry, ng=value.
Constraint: ng1.
On entry, stats(1)=value.
Constraint: stats(1)3.0.
On entry, stats(2)=value.
Constraint: stats(2)>0.0.
On entry, stats(2)=value.
Constraint: stats(2)1.0.
On entry, stats(3)=value.
Constraint: stats(3)1.0.
ifail=2
A bivariate spectral estimate is zero. For this frequency the cross amplitude spectrum and shared coherency and their bounds are set to zero.
ifail=3
A univariate spectral estimate is negative. For this frequency the cross amplitude spectrum and shared coherency and their bounds are set to zero.
ifail=4
A univariate spectral estimate is zero. For this frequency the cross amplitude spectrum and shared coherency and their bounds are set to zero.
ifail=5
A calculated value of the squared coherency exceeds 1.0. For this frequency the squared coherency is reset to 1.0 and this value for the squared coherency is used in the formulae for the calculation of bounds for both the cross amplitude spectrum and squared coherency. This has the consequence that both squared coherency bounds are 1.0.
ifail=-99
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.
ifail=-399
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

All computations are very stable and yield good accuracy.

8 Parallelism and Performance

g13cef is not threaded in any implementation.

9 Further Comments

The time taken by g13cef is approximately proportional to ng.

10 Example

This example reads the set of univariate spectrum statistics, the two univariate spectra and the cross spectrum at a frequency division of 2π20 for a pair of time series. It calls g13cef to calculate the cross amplitude spectrum and squared coherency and their bounds and prints the results.

10.1 Program Text

Program Text (g13cefe.f90)

10.2 Program Data

Program Data (g13cefe.d)

10.3 Program Results

Program Results (g13cefe.r)