NAG Library Routine Document

g13cff (multi_gain_bivar)

1
Purpose

For a bivariate time series, g13cff calculates the gain and phase together with lower and upper bounds from the univariate and bivariate spectra.

2
Specification

Fortran Interface
Subroutine g13cff ( xg, yg, xyrg, xyig, ng, stats, gn, gnlw, gnup, ph, phlw, phup, 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):: gn(ng), gnlw(ng), gnup(ng), ph(ng), phlw(ng), phup(ng)
C Header Interface
#include <nagmk26.h>
void  g13cff_ (const double xg[], const double yg[], const double xyrg[], const double xyig[], const Integer *ng, const double stats[], double gn[], double gnlw[], double gnup[], double ph[], double phlw[], double phup[], Integer *ifail)

3
Description

Estimates of the gain Gω and phase ϕω of the dependency of series y on series x at frequency ω are given by
G^ω= Aω fxxω ϕ^ω=arccos cfω Aω , if ​qfω0 ϕ^ω=2π-arccos cfω Aω , if ​qfω<0.  
The quantities used in these definitions are obtained as in Section 3 in g13cef.
Confidence limits are returned for both gain and phase, but should again be taken as very approximate when the coherency Wω, as calculated by g13cef, is not significant. These are based on the assumption that both G^ω/Gω-1 and ϕ^ω are Normal with variance
1d 1Wω -1 .  
Although the estimate of ϕω is always given in the range 0,2π, no attempt is made to restrict its confidence limits to this range.

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:     xgng – Real (Kind=nag_wp) arrayInput
On entry: the ng univariate spectral estimates, fxxω, for the x series.
2:     ygng – Real (Kind=nag_wp) arrayInput
On entry: the ng univariate spectral estimates, fyyω, for the y series.
3:     xyrgng – Real (Kind=nag_wp) arrayInput
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:     xyigng – Real (Kind=nag_wp) arrayInput
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 – IntegerInput
On entry: the number of spectral estimates in each of the arrays xg, yg, xyrg and xyig. It is also the number of gain and phase estimates.
Constraint: ng1.
6:     stats4 – Real (Kind=nag_wp) arrayInput
On entry: the four associated statistics for the univariate spectral estimates for the x and y series. stats1 contains the degrees of freedom, stats2 and stats3 contain the lower and upper bound multiplying factors respectively and stats4 holds the bandwidth.
Constraint: stats13.0.
7:     gnng – Real (Kind=nag_wp) arrayOutput
On exit: the ng gain estimates, G^ω, at each frequency ω.
8:     gnlwng – Real (Kind=nag_wp) arrayOutput
On exit: the ng lower bounds for the ng gain estimates.
9:     gnupng – Real (Kind=nag_wp) arrayOutput
On exit: the ng upper bounds for the ng gain estimates.
10:   phng – Real (Kind=nag_wp) arrayOutput
On exit: the ng phase estimates, ϕ^ω, at each frequency ω.
11:   phlwng – Real (Kind=nag_wp) arrayOutput
On exit: the ng lower bounds for the ng phase estimates.
12:   phupng – Real (Kind=nag_wp) arrayOutput
On exit: the ng upper bounds for the ng phase estimates.
13:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. 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:
ifail=1
On entry, ng=value.
Constraint: ng1.
On entry, stats1=value.
Constraint: stats13.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 in the formulae for the gain and phase bounds.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.
If more than one failure of 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.

7
Accuracy

All computations are very stable and yield good accuracy.

8
Parallelism and Performance

g13cff is not threaded in any implementation.

9
Further Comments

The time taken by g13cff 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 g13cff to calculate the gain and the phase and their bounds and prints the results.

10.1
Program Text

Program Text (g13cffe.f90)

10.2
Program Data

Program Data (g13cffe.d)

10.3
Program Results

Program Results (g13cffe.r)