G13CGF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G13CGF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

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

SUBROUTINE G13CGF ( XG, YG, XYRG, XYIG, NG, STATS, L, N, ER, ERLW, ERUP, RF, RFSE, IFAIL)
INTEGER  NG, L, N, IFAIL
REAL (KIND=nag_wp)  XG(NG), YG(NG), XYRG(NG), XYIG(NG), STATS(4), ER(NG), ERLW, ERUP, RF(L), RFSE

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 parameter 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  Parameters

1:     XG(NG) – REAL (KIND=nag_wp) arrayInput
On entry: the NG univariate spectral estimates, fxxω, for the x series.
2:     YG(NG) – REAL (KIND=nag_wp) arrayInput
On entry: the NG univariate spectral estimates, fyyω, for the y series.
3:     XYRG(NG) – 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:     XYIG(NG) – 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, XYIG. It is also the number of noise spectral estimates.
Constraint: NG1.
6:     STATS(4) – 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 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 – INTEGERInput
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.
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.
8:     N – INTEGERInput
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:     ER(NG) – REAL (KIND=nag_wp) arrayOutput
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:   RF(L) – REAL (KIND=nag_wp) arrayOutput
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 – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameters 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).
Note: G13CGF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
IFAIL=1
On entry,NG<1,
orSTATS1<3.0,
orSTATS20.0,
orSTATS2>1.0,
orSTATS3<1.0,
orN<1.
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,L/2+1NG,
orL has a prime factor exceeding 19,
orL has more than 20 prime factors, counting repetitions.
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  Further Comments

The time taken by G13CGF is approximately proportional to NG.

9  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.

9.1  Program Text

Program Text (g13cgfe.f90)

9.2  Program Data

Program Data (g13cgfe.d)

9.3  Program Results

Program Results (g13cgfe.r)


G13CGF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

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