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

Syntax

C#
public static void g13ce(
	double[] xg,
	double[] yg,
	double[] xyrg,
	double[] xyig,
	int ng,
	double[] stats,
	double[] ca,
	double[] calw,
	double[] caup,
	out double t,
	double[] sc,
	double[] sclw,
	double[] scup,
	out int ifail
)
Visual Basic
Public Shared Sub g13ce ( _
	xg As Double(), _
	yg As Double(), _
	xyrg As Double(), _
	xyig As Double(), _
	ng As Integer, _
	stats As Double(), _
	ca As Double(), _
	calw As Double(), _
	caup As Double(), _
	<OutAttribute> ByRef t As Double, _
	sc As Double(), _
	sclw As Double(), _
	scup As Double(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g13ce(
	array<double>^ xg, 
	array<double>^ yg, 
	array<double>^ xyrg, 
	array<double>^ xyig, 
	int ng, 
	array<double>^ stats, 
	array<double>^ ca, 
	array<double>^ calw, 
	array<double>^ caup, 
	[OutAttribute] double% t, 
	array<double>^ sc, 
	array<double>^ sclw, 
	array<double>^ scup, 
	[OutAttribute] int% ifail
)
F#
static member g13ce : 
        xg : float[] * 
        yg : float[] * 
        xyrg : float[] * 
        xyig : float[] * 
        ng : int * 
        stats : float[] * 
        ca : float[] * 
        calw : float[] * 
        caup : float[] * 
        t : float byref * 
        sc : float[] * 
        sclw : float[] * 
        scup : float[] * 
        ifail : int byref -> unit 

Parameters

xg
Type: array<System..::..Double>[]()[][]
An array of size [ng]
On entry: the ng univariate spectral estimates, fxxω, for the x series.
yg
Type: array<System..::..Double>[]()[][]
An array of size [ng]
On entry: the ng univariate spectral estimates, fyyω, for the y series.
xyrg
Type: array<System..::..Double>[]()[][]
An array of size [ng]
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.
xyig
Type: array<System..::..Double>[]()[][]
An array of size [ng]
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.
ng
Type: System..::..Int32
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.
stats
Type: array<System..::..Double>[]()[][]
An array of size [4]
On entry: the four associated statistics for the univariate spectral estimates for the x and y series. stats[0] contains the degrees of freedom, stats[1] and stats[2] contain the lower and upper bound multiplying factors respectively and stats[3] contains the bandwidth.
Constraints:
  • stats[0]3.0;
  • 0.0<stats[1]1.0;
  • stats[2]1.0.
ca
Type: array<System..::..Double>[]()[][]
An array of size [ng]
On exit: the ng cross amplitude spectral estimates A^ω at each frequency of ω.
calw
Type: array<System..::..Double>[]()[][]
An array of size [ng]
On exit: the ng lower bounds for the ng cross amplitude spectral estimates.
caup
Type: array<System..::..Double>[]()[][]
An array of size [ng]
On exit: the ng upper bounds for the ng cross amplitude spectral estimates.
t
Type: System..::..Double%
On exit: the critical value for the significance of the squared coherency, T.
sc
Type: array<System..::..Double>[]()[][]
An array of size [ng]
On exit: the ng squared coherency estimates, W^ω at each frequency ω.
sclw
Type: array<System..::..Double>[]()[][]
An array of size [ng]
On exit: the ng lower bounds for the ng squared coherency estimates.
scup
Type: array<System..::..Double>[]()[][]
An array of size [ng]
On exit: the ng upper bounds for the ng squared coherency estimates.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

Estimates of the cross amplitude spectrum Aω and squared coherency Wω are calculated for each frequency ω as
Aω=fxyω=cfω2+qfω2  andWω=fxyω2fxxωfyyω,
where
  • cfω and qfω are the co-spectrum and quadrature spectrum estimates between the series, i.e., the real and imaginary parts of the cross spectrum fxyω as obtained using g13cc or g13cd;
  • fxxω and fyyω are the univariate spectrum estimates for the two series as obtained using g13ca or g13cb.
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 g13ca or g13cb.
Upper and lower 95% confidence limits for the cross amplitude are given approximately by
Aω1±1.96/dWω-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=2Fd-2+2F,
where d is the degrees of freedom associated with the univariate spectrum estimates. The value of T is returned by the method.
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 arctanhWl is Normal with variance 1/d.

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

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry,ng<1,
orstats[0]<3.0,
orstats[1]0.0,
orstats[1]>1.0,
orstats[2]<1.0.
ifail=2
A bivariate spectral estimate is zero. For this frequency the cross amplitude spectrum and squared coherency and their bounds are set to zero.
ifail=3
A univariate spectral estimate is negative. For this frequency the cross amplitude spectrum and squared coherency and their bounds are set to zero.
ifail=4
A univariate spectral estimate is zero. For this frequency the cross amplitude spectrum and squared 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=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value
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.

Accuracy

All computations are very stable and yield good accuracy.

Parallelism and Performance

None.

Further Comments

The time taken by g13ce is approximately proportional to ng.

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 g13ce to calculate the cross amplitude spectrum and squared coherency and their bounds and prints the results.

Example program (C#): g13cee.cs

Example program data: g13cee.d

Example program results: g13cee.r

See Also