NAG FL Interface
g13cgf (multi_​noise_​bivar)

1 Purpose

For a bivariate time series, g13cgf 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

Fortran Interface
Subroutine g13cgf ( xg, yg, xyrg, xyig, ng, stats, l, n, er, erlw, erup, rf, rfse, ifail)
Integer, Intent (In) :: ng, l, n
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) :: er(ng), erlw, erup, rf(l), rfse
C Header Interface
#include <nag.h>
void  g13cgf_ (const double xg[], const double yg[], const double xyrg[], const double xyig[], const Integer *ng, const double stats[], const Integer *l, const Integer *n, double er[], double *erlw, double *erup, double rf[], double *rfse, Integer *ifail)
The routine may be called by the names g13cgf or nagf_tsa_multi_noise_bivar.

3 Description

An estimate of the noise spectrum in the dependence of series y on series x at frequency ω is given by
fyxω=fyyω1-Wω,  
where Wω is the squared coherency described in g13cef and fyyω 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 yt on xt can be assumed to be represented in the time domain by the one sided relationship
yt=v0xt+v1xt-1++nt,  
where the noise nt is independent of xt, then it is the spectrum of this noise which is estimated by fyxω.
Estimates of the impulse response function v0,v1,v2, may also be obtained as
vk=1π0πReexpikωfxyω fxxω ,  
where Re indicates the real part of the expression. For this purpose it is essential that the univariate spectrum for x, fxxω, and the cross spectrum, fxyω, be supplied to this routine for a frequency range
ωl=2πlL ,  0lL/2,  
where denotes the integer part, the integral being approximated by a finite Fourier transform.
An approximate standard error is calculated for the estimates vk. Significant values of vk in the locations described as anticipatory responses in the argument array rf indicate that feedback exists from yt to xt. This will bias the estimates of vk in any causal dependence of yt on xt,xt-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: xgng Real (Kind=nag_wp) array Input
On entry: the ng univariate spectral estimates, fxxω, for the x series.
2: ygng Real (Kind=nag_wp) array Input
On entry: the ng univariate spectral estimates, fyyω, for the y series.
3: xyrgng 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: xyigng 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, xyig. It is also the number of noise spectral estimates.
Constraint: ng1.
6: stats4 Real (Kind=nag_wp) array Input
On entry: the four associated statistics for the univariate spectral estimates for the x and y series. stats1 contains the degree of freedom, stats2 and stats3 contain the lower and upper bound multiplying factors respectively and stats4 contains the bandwidth.
Constraints:
  • stats13.0;
  • 0.0<stats21.0;
  • stats31.0.
7: l Integer Input
On entry: L, the frequency division of the spectral estimates as 2πL . It is also the order of the FFT used to calculate the impulse response function. l must relate to the parameter ng by the relationship.
Constraint: ng=L/2+1.
8: 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 g13ccf or g13cdf which calculated the smoothed sample cross spectrum. n is used in calculating the impulse response function standard error (rfse).
Constraint: n1.
9: erng Real (Kind=nag_wp) array Output
On exit: the ng estimates of the noise spectrum, f^yxω at each frequency.
10: erlw Real (Kind=nag_wp) Output
On exit: the noise spectrum lower limit multiplying factor.
11: erup Real (Kind=nag_wp) Output
On exit: the noise spectrum upper limit multiplying factor.
12: rfl Real (Kind=nag_wp) array Output
On exit: the impulse response function. Causal responses are stored in ascending frequency in rf1 to rfng and anticipatory responses are stored in descending frequency in rfng+1 to rfl.
13: rfse Real (Kind=nag_wp) Output
On exit: the impulse response function standard error.
14: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface 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, because for this routine the values of the output arguments may be useful even if ifail0 on exit, the recommended value is -1. 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: in some cases g13cgf may return useful information.
ifail=1
On entry, n=value.
Constraint: n1.
On entry, ng=value.
Constraint: ng1.
On entry, stats1=value.
Constraint: stats13.0.
On entry, stats2=value.
Constraint: stats2>0.0.
On entry, stats2=value.
Constraint: stats21.0.
On entry, stats3=value.
Constraint: stats31.0.
ifail=2
A bivariate spectral estimate is zero.
For this frequency the noise spectrum is set to zero, and the contribution to the impulse response function and its standard error is set to zero.
ifail=3
A univariate 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.
ifail=4
A univariate 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.
ifail=5
A calculated value of the squared coherency exceeds 1.0.
For this frequency the squared coherency is reset to 1.0 with the consequence that the noise spectrum is zero and the contribution to the impulse response function at this frequency is zero.
ifail=6
On entry, ng=value and l=value.
Constraint: ng=l/2+1.
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.
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

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

g13cgf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13cgf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

The time taken by g13cgf 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 g13cgf 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 (g13cgfe.f90)

10.2 Program Data

Program Data (g13cgfe.d)

10.3 Program Results

Program Results (g13cgfe.r)