NAG FL Interface
g13ccf (multi_spectrum_lag)
1
Purpose
g13ccf calculates the smoothed sample cross spectrum of a bivariate time series using one of four lag windows: rectangular, Bartlett, Tukey or Parzen.
2
Specification
Fortran Interface
Subroutine g13ccf ( |
nxy, mtxy, pxy, iw, mw, ish, ic, nc, cxy, cyx, kc, l, nxyg, xg, yg, ng, ifail) |
Integer, Intent (In) |
:: |
nxy, mtxy, iw, mw, ish, ic, nc, kc, l, nxyg |
Integer, Intent (Inout) |
:: |
ifail |
Integer, Intent (Out) |
:: |
ng |
Real (Kind=nag_wp), Intent (In) |
:: |
pxy |
Real (Kind=nag_wp), Intent (Inout) |
:: |
cxy(nc), cyx(nc), xg(nxyg), yg(nxyg) |
|
C Header Interface
#include <nag.h>
void |
g13ccf_ (const Integer *nxy, const Integer *mtxy, const double *pxy, const Integer *iw, const Integer *mw, const Integer *ish, const Integer *ic, const Integer *nc, double cxy[], double cyx[], const Integer *kc, const Integer *l, const Integer *nxyg, double xg[], double yg[], Integer *ng, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g13ccf_ (const Integer &nxy, const Integer &mtxy, const double &pxy, const Integer &iw, const Integer &mw, const Integer &ish, const Integer &ic, const Integer &nc, double cxy[], double cyx[], const Integer &kc, const Integer &l, const Integer &nxyg, double xg[], double yg[], Integer &ng, Integer &ifail) |
}
|
The routine may be called by the names g13ccf or nagf_tsa_multi_spectrum_lag.
3
Description
The smoothed sample cross spectrum is a complex valued function of frequency
,
, defined by its real part or co-spectrum
and imaginary part or quadrature spectrum
where
, for
, is the smoothing lag window as defined in the description of
g13caf. The alignment shift
is recommended to be chosen as the lag
at which the cross-covariances
peak, so as to minimize bias.
The results are calculated for frequency values
where
denotes the integer part.
The cross-covariances
may be supplied by you, or constructed from supplied series
;
as
this convolution being carried out using the finite Fourier transform.
The supplied series may be mean and trend corrected and tapered before calculation of the cross-covariances, in exactly the manner described in
g13caf for univariate spectrum estimation. The results are corrected for any bias due to tapering.
The bandwidth associated with the estimates is not returned. It will normally already have been calculated in previous calls of
g13caf for estimating the univariate spectra of
and
.
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:
– Integer
Input
-
On entry: , the length of the time series and .
Constraint:
.
-
2:
– Integer
Input
-
On entry: if cross-covariances are to be calculated by the routine (
),
mtxy must specify whether the data is to be initially mean or trend corrected.
- For no correction.
- For mean correction.
- For trend correction.
If cross-covariances are supplied
,
mtxy is not used.
Constraint:
if , , or .
-
3:
– Real (Kind=nag_wp)
Input
-
On entry: if cross-covariances are to be calculated by the routine (
),
pxy must specify the proportion of the data (totalled over both ends) to be initially tapered by the split cosine bell taper. A value of
implies no tapering.
If cross-covariances are supplied
,
pxy is not used.
Constraint:
if , .
-
4:
– Integer
Input
-
On entry: the choice of lag window.
- Rectangular.
- Bartlett.
- Tukey.
- Parzen.
Constraint:
.
-
5:
– Integer
Input
-
On entry: , the ‘cut-off’ point of the lag window, relative to any alignment shift that has been applied. Windowed cross-covariances at lags or less, and at lags or greater are zero.
-
6:
– Integer
Input
-
On entry: , the alignment shift between the and series. If leads , the shift is positive.
Constraint:
.
-
7:
– Integer
Input
-
On entry: indicates whether cross-covariances are to be calculated in the routine or supplied in the call to the routine.
- Cross-covariances are to be calculated.
- Cross-covariances are to be supplied.
-
8:
– Integer
Input
-
On entry: the number of cross-covariances to be calculated in the routine or supplied in the call to the routine.
Constraint:
.
-
9:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: if
,
cxy must contain the
nc cross-covariances between values in the
series and earlier values in time in the
series, for lags from
to
.
If
,
cxy need not be set.
On exit: if
,
cxy will contain the
nc calculated cross-covariances.
If
, the contents of
cxy will be unchanged.
-
10:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: if
,
cyx must contain the
nc cross-covariances between values in the
series and later values in time in the
series, for lags from
to
.
If
,
cyx need not be set.
On exit: if
,
cyx will contain the
nc calculated cross-covariances.
If
, the contents of
cyx will be unchanged.
-
11:
– Integer
Input
-
On entry: if
,
kc must specify the order of the fast Fourier transform (FFT) used to calculate the cross-covariances.
If
, that is if covariances are supplied,
kc is not used.
Constraint:
.
-
12:
– Integer
Input
-
On entry: , the frequency division of the spectral estimates as . Therefore it is also the order of the FFT used to construct the sample spectrum from the cross-covariances.
Constraint:
.
-
13:
– Integer
Input
-
On entry: the dimension of the arrays
xg and
yg as declared in the (sub)program from which
g13ccf is called.
Constraints:
- if , ;
- otherwise .
-
14:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: if the cross-covariances are to be calculated, then
xg must contain the
nxy data points of the
series. If covariances are supplied,
xg need not be set.
On exit: contains the real parts of the
ng complex spectral estimates in elements
to
, and
to
contain
. The
series leads the
series.
-
15:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: if cross-covariances are to be calculated,
yg must contain the
nxy data points of the
series. If covariances are supplied,
yg need not be set.
On exit: contains the imaginary parts of the
ng complex spectral estimates in elements
to
, and
to
contain
. The
series leads the
series.
-
16:
– Integer
Output
-
On exit: the number,
, of complex spectral estimates, whose separate parts are held in
xg and
yg.
-
17:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, , and .
Constraint: if , .
On entry, and .
Constraint: .
On entry, .
Constraint: , , or .
On entry, .
Constraint: if then , or .
On entry, , and .
Constraint: .
On entry, .
Constraint: .
On entry, , and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, , and .
Constraint: if , .
On entry, .
Constraint: if , .
On entry, .
Constraint: if , .
-
On entry, , and .
Constraint: if , .
-
On entry, and .
Constraint: .
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.
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.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
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
g13ccf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13ccf 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.
g13ccf carries out two FFTs of length
kc to calculate the sample cross-covariances and one FFT of length
to calculate the sample spectrum. The timing of
g13ccf is therefore dependent on the choice of these values. The time taken for an FFT of length
is approximately proportional to
(but see
Section 9 in
c06paf for further details).
10
Example
This example reads two time series of length . It then selects mean correction, a 10% tapering proportion, the Parzen smoothing window and a cut-off point of for the lag window. The alignment shift is set to and cross-covariances are chosen to be calculated. The program then calls g13ccf to calculate the cross spectrum and then prints the cross-covariances and cross spectrum.
10.1
Program Text
10.2
Program Data
10.3
Program Results