NAG FL Interface
g13cdf (multi_spectrum_daniell)
1
Purpose
g13cdf calculates the smoothed sample cross spectrum of a bivariate time series using spectral smoothing by the trapezium frequency (Daniell) window.
2
Specification
Fortran Interface
Subroutine g13cdf ( |
nxy, mtxy, pxy, mw, ish, pw, l, kc, xg, yg, ng, ifail) |
Integer, Intent (In) |
:: |
nxy, mtxy, mw, ish, l, kc |
Integer, Intent (Inout) |
:: |
ifail |
Integer, Intent (Out) |
:: |
ng |
Real (Kind=nag_wp), Intent (In) |
:: |
pxy, pw |
Real (Kind=nag_wp), Intent (Inout) |
:: |
xg(kc), yg(kc) |
|
C Header Interface
#include <nag.h>
void |
g13cdf_ (const Integer *nxy, const Integer *mtxy, const double *pxy, const Integer *mw, const Integer *ish, const double *pw, const Integer *l, const Integer *kc, double xg[], double yg[], Integer *ng, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g13cdf_ (const Integer &nxy, const Integer &mtxy, const double &pxy, const Integer &mw, const Integer &ish, const double &pw, const Integer &l, const Integer &kc, double xg[], double yg[], Integer &ng, Integer &ifail) |
}
|
The routine may be called by the names g13cdf or nagf_tsa_multi_spectrum_daniell.
3
Description
The supplied time series may be mean and trend corrected and tapered as in the description of
g13cbf before calculation of the unsmoothed sample cross-spectrum
for frequency values
,
.
A correction is made for bias due to any tapering.
As in the description of
g13cbf for univariate frequency window smoothing, the smoothed spectrum is returned as a subset of these frequencies,
where [ ] denotes the integer part.
Its real part or co-spectrum
, and imaginary part or quadrature spectrum
are defined by
where the weights
are similar to the weights
defined for
g13cbf, but allow for an implicit alignment shift
between the series:
It is recommended that
is chosen as the lag
at which the cross-covariances
peak, so as to minimize bias.
If no smoothing is required, the integer , which determines the frequency window width , should be set to .
The bandwidth of the estimates will normally have been calculated in a previous call of
g13cbf 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: whether the data is to be initially mean or trend corrected.
- For no correction.
- For mean correction.
- For trend correction.
Constraint:
.
-
3:
– Real (Kind=nag_wp)
Input
-
On entry: 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.
Constraint:
.
-
4:
– Integer
Input
-
On entry:
, the frequency width of the smoothing window as
.
A value of implies that no smoothing is to be carried out.
Constraint:
.
-
5:
– Integer
Input
-
On entry: , the alignment shift between the and series. If leads , the shift is positive.
Constraint:
.
-
6:
– Real (Kind=nag_wp)
Input
-
On entry:
, the shape parameter of the trapezium frequency window.
A value of gives a triangular window, and a value of a rectangular window.
If
(i.e., no smoothing is carried out) then
pw is not used.
Constraint:
if , .
-
7:
– Integer
Input
-
On entry: , the frequency division of smoothed cross spectral estimates as .
Constraints:
- ;
- l must be a factor of kc.
-
8:
– Integer
Input
-
On entry: the order of the fast Fourier transform (FFT) used to calculate the spectral estimates.
Constraints:
- ;
- kc must be a multiple of l.
-
9:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: the
nxy data points of the
series.
On exit: the real parts of the
ng cross spectral estimates in elements
to
, and
to
contain
. The
series leads the
series.
-
10:
– Real (Kind=nag_wp) array
Input/Output
-
On entry: the
nxy data points of the
series.
On exit: the imaginary parts of the
ng cross spectral estimates in elements
to
, and
to
contain
. The
series leads the
series.
-
11:
– Integer
Output
-
On exit: the number of spectral estimates,
, whose separate parts are held in
xg and
yg.
-
12:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or 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: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, , and .
Constraint: if , .
On entry, , and .
Constraint: if , .
On entry, .
Constraint: .
On entry, .
Constraint: .
-
On entry,
and
.
Constraint:
kc must be a multiple of
l.
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
g13cdf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g13cdf 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.
g13cdf carries out an FFT of length
kc to calculate the sample cross spectrum. The time taken by the routine for this is approximately proportional to
(but see routine document
c06paf for further details).
10
Example
This example reads two time series of length . It selects mean correction and a 10% tapering proportion. It selects a frequency width of smoothing window, a window shape parameter of and an alignment shift of . It then calls g13cdf to calculate the smoothed sample cross spectrum and prints the results.
10.1
Program Text
10.2
Program Data
10.3
Program Results