NAG CL Interface
g13cgc (multi_​noise_​bivar)

Settings help

CL Name Style:


1 Purpose

For a bivariate time series, g13cgc calculates the noise spectrum together with multiplying factors for the bounds and the impulse response function and its standard error, from the univariate and bivariate spectra.

2 Specification

#include <nag.h>
void  g13cgc (const double xg[], const double yg[], const Complex xyg[], Integer ng, const double stats[], Integer l, Integer n, double er[], double *erlw, double *erup, double rf[], double *rfse, NagError *fail)
The function may be called by the names: g13cgc, nag_tsa_multi_noise_bivar or nag_tsa_noise_spectrum_bivar.

3 Description

An estimate of the noise spectrum in the dependence of series y on series x at frequency ω is given by
f yx (ω) = f yy (ω) (1-W(ω))  
where W (ω) is the squared coherency described in G13GEF and f yy (ω) is the univariate spectrum estimate for series y . Confidence limits on the true spectrum are obtained using multipliers as described for G13CAF, but based on (d-2) degrees of freedom.
If the dependence of y t on x t can be assumed to be represented in the time domain by the one sided relationship
y t = v 0 x t + v 1 x t-1 + + n t  
where the noise n t is independent of x t , then it is the spectrum of this noise which is estimated by f yx (ω) .
Estimates of the impulse response function v 0 , v 1 , v 2 , may also be obtained as
v k = 1 π 0 π Re( exp(ikω) f xy (ω) f xx (ω) )  
where Re indicates the real part of the expression. For this purpose it is essential that the univariate spectrum for x , f xx (ω) ,and the cross spectrum, f xy (ω) be supplied to this function for a frequency range
ω l = [ 2πl L ] , 0 l [L/2] ,  
where [] denotes the integer part, the integral being approximated by a finite Fourier transform.
An approximate standard error is calculated for the estimates v k . Significant values of v k in the locations described as anticipatory responses in the argument array rf, indicate that feedback exists from y t to x t . This will bias the estimates of v k in any causal dependence of y t on x t , x t-1 , .

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 double Input
On entry: the ng univariate spectral estimates, f xx (ω) , for the x series.
2: yg[ng] const double Input
On entry: the ng univariate spectral estimates, f yy (ω) , for the y series.
3: xyg[ng] const Complex Input
On entry: f xy (ω) , of the ng bivariate spectral estimates for the x and y series. The x series leads the y series.
Note: the two univariate and 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 Integer Input
On entry: the number of spectral estimates in each of the arrays xg, yg and xyg. It is also the number of noise spectral estimates.
Constraint: ng1 .
5: stats[4] const double Input
On entry: the 4 associated statistics for the univariate spectral estimates for the x and y series. stats[0] contains the degree 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 .
6: l Integer Input
On entry: the frequency division, L , of the spectral estimates as 2 π / L , as input to g13cbc and g13cdc.
Constraints:
  • ng = [l/2] + 1 ;
  • The largest prime factor of l must not exceed 19, and the total number of prime factors of l, counting repetitions, must not exceed 20. These two restrictions are imposed by the internal FFT algorithm used.
7: n Integer Input
On entry: the number of points in each of the time series x and y . n should have the same value as nxy in the call of g13ccc or g13cdc which calculated the smoothed sample cross spectrum. n is used in calculating the impulse response function standard error (rfse).
Constraint: n1 .
8: er[ng] double Output
On exit: the ng estimates of the noise spectrum, f ^ yx (ω) at each frequency.
9: erlw double * Output
On exit: the noise spectrum lower limit multiplying factor.
10: erup double * Output
On exit: the noise spectrum upper limit multiplying factor.
11: rf[l] double Output
On exit: the impulse response function. Causal responses are stored in ascending frequency in rf[0] to rf[ng-1] and anticipatory responses are stored in descending frequency in rf[ng] to rf[l] .
12: rfse double * Output
On exit: the impulse response function standard error.
13: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_2_INT_ARG_CONS
On entry, l=value while ng=value . These arguments must satisfy ng = [l/2] + 1 when ng>0 .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BIVAR_SPECTRAL_ESTIM_ZERO
A bivariate spectral estimate is zero.
For this frequency the noise spectrum is set to zero, and the contributions to the impulse response function and its standard error are set to zero.
NE_FACTOR_GT
At least one of the prime factors of l is greater than 19.
NE_INT_ARG_LT
On entry, n=value.
Constraint: n1.
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_GT
On entry, stats[1] must not be greater than 1.0: stats[1] = value.
NE_REAL_ARG_LE
On entry, stats[1] must not be less than or equal to 0.0: stats[1] = value.
NE_REAL_ARG_LT
On entry, stats[0] must not be less than 3.0: stats[0] = value.
On entry, stats[2] must not be less than 1.0: stats[2] = value.
NE_SQUARED_FREQ_GT_ONE
A calculated value of the squared coherency exceeds one.
For this frequency the squared coherency is reset to one with the result that the noise spectrum is zero and the contribution to the impulse response function at this frequency is zero.
NE_TOO_MANY_FACTORS
l has more than 20 prime factors.
NE_UNIVAR_SPECTRAL_ESTIM_NEG
A bivariate spectral estimate is negative.
For this frequency the noise spectrum is set to zero, and the contributions to the impulse response function and its standard error are set to zero.
NE_UNIVAR_SPECTRAL_ESTIM_ZERO
A bivariate spectral estimate is zero.
For this frequency the noise spectrum is set to zero, and the contributions to the impulse response function and its standard error are set to zero.

7 Accuracy

The computation of the noise is stable and yields good 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.

8 Parallelism and Performance

g13cgc is not threaded in any implementation.

9 Further Comments

The time taken by g13cgc 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 g13cgc to calculate the noise spectrum and its confidence limits multiplying factors, the impulse response function and its standard error. It then prints the results.

10.1 Program Text

Program Text (g13cgce.c)

10.2 Program Data

Program Data (g13cgce.d)

10.3 Program Results

Program Results (g13cgce.r)