NAG Library Function Document

nag_tsa_gain_phase_bivar (g13cfc)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

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

2
Specification

#include <nag.h>
#include <nagg13.h>
void  nag_tsa_gain_phase_bivar (const double xg[], const double yg[], const Complex xyg[], Integer ng, const double stats[], double gn[], double gnlw[], double gnup[], double ph[], double phlw[], double phup[], NagError *fail)

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 ω f xx ω ϕ ^ ω = 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 nag_tsa_cross_spectrum_bivar (g13cec).
Confidence limits are returned for both gain and phase, but should again be taken as very approximate when the coherency W ω , as calculated by nag_tsa_gain_phase_bivar (g13cfc), is not significant. These are based on the assumption that both G ^ ω / G ω - 1  and ϕ ^ ω  are Normal with variance
1 d 1 W ω - 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:     xg[ng] const doubleInput
On entry: the ng univariate spectral estimates, f xx ω , for the x  series.
2:     yg[ng] const doubleInput
On entry: the ng univariate spectral estimates, f yy ω , for the y  series.
3:     xyg[ng] const ComplexInput
On entry: f xy ω  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 amount of smoothing. 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.
4:     ng IntegerInput
On entry: the number of spectral estimates in each of the arrays xg, yg and xyg. It is also the number of gain and phase estimates.
Constraint: ng1 .
5:     stats[4] const doubleInput
On entry: the 4 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]  holds the bandwidth.
Constraint: stats[0] 3.0 .
6:     gn[ng] doubleOutput
On exit: the ng gain estimates, G ^ ω , at each frequency ω .
7:     gnlw[ng] doubleOutput
On exit: the ng lower bounds for the ng gain estimates.
8:     gnup[ng] doubleOutput
On exit: the ng upper bounds for the ng gain estimates.
9:     ph[ng] doubleOutput
On exit: the ng phase estimates, ϕ ^ ω , at each frequency ω .
10:   phlw[ng] doubleOutput
On exit: the ng lower bounds for the ng phase estimates.
11:   phup[ng] doubleOutput
On exit: the ng upper bounds for the ng phase estimates.
12:   fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

6
Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BIVAR_SPECTRAL_ESTIM_ZERO
A bivariate spectral estimate is zero.
For this frequency the gain and the phase and their bounds are set to zero.
NE_INT_ARG_LT
On entry, ng=value.
Constraint: ng1.
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.
NE_REAL_ARG_LT
On entry, stats[0]  must not be less than 3.0: stats[0] = value.
NE_SQUARED_FREQ_GT_ONE
A calculated value of the squared coherency exceeds one.
For this frequency the squared coherency is reset to 1.0 in the formulae for the gain and phase bounds.
NE_UNIVAR_SPECTRAL_ESTIM_NEG
A bivariate spectral estimate is negative.
For this frequency the gain and the phase and their bounds are set to zero.
NE_UNIVAR_SPECTRAL_ESTIM_ZERO
A bivariate spectral estimate is zero.
For this frequency the gain and the phase and their bounds are set to zero.

7
Accuracy

All computations are very stable and yield good accuracy.

8
Parallelism and Performance

nag_tsa_gain_phase_bivar (g13cfc) is not threaded in any implementation.

9
Further Comments

The time taken by nag_tsa_gain_phase_bivar (g13cfc) is approximately proportional to ng.

10
Example

The example program reads the set of univariate spectrum statistics, the 2 univariate spectra and the cross spectrum at a frequency division of 2π 20  for a pair of time series. It calls nag_tsa_gain_phase_bivar (g13cfc) to calculate the gain and the phase and their bounds and prints the results.

10.1
Program Text

Program Text (g13cfce.c)

10.2
Program Data

Program Data (g13cfce.d)

10.3
Program Results

Program Results (g13cfce.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017