NAG CL Interface
g13cdc (multi_spectrum_daniell)
1
Purpose
g13cdc calculates the smoothed sample cross spectrum of a bivariate time series using spectral smoothing by the trapezium frequency (Daniell) window.
2
Specification
void |
g13cdc (Integer nxy,
NagMeanOrTrend mt_correction,
double pxy,
Integer mw,
Integer is,
double pw,
Integer l,
Integer kc,
const double x[],
const double y[],
Complex **g,
Integer *ng,
NagError *fail) |
|
The function may be called by the names: g13cdc, nag_tsa_multi_spectrum_daniell or nag_tsa_spectrum_bivar.
3
Description
The supplied time series may be mean and trend corrected and tapered as in the description of
g13cbc 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
g13cbc for univariate frequency window smoothing, the smoothed spectrum is returned at 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
g13cbc, 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
g13cbc 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:
– NagMeanOrTrend
Input
-
On entry: whether the data are to be initially mean or trend corrected. for no correction, for mean correction, for trend correction.
Constraint:
, or .
-
3:
– double
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:
– double
Input
-
On entry: the shape argument,
, 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 .
Constraint:
.
l must be a factor of
kc (see below).
-
8:
– Integer
Input
-
On entry: the order of the fast Fourier transform (FFT) used to calculate the spectral estimates.
kc should be a product of small primes such as
where
is the smallest integer such that
, provided
.
Constraints:
- ;
- kc must be a multiple of l. The largest prime factor of kc must not exceed , and the total number of prime factors of kc, counting repetitions, must not exceed . These two restrictions are imposed by the internal FFT algorithm used.
-
9:
– const double
Input
-
On entry: the
nxy data points of the
series.
-
10:
– const double
Input
-
On entry: the
nxy data points of the
series.
-
11:
– Complex **
Output
-
On exit: the complex vector which contains the
ng cross spectral estimates in elements
to
. The
series leads the
series.
The memory for this vector is allocated internally. If no memory is allocated to
g (e.g., when an input error is detected) then
g will be
NULL on return. If repeated calls to this function are required then
NAG_FREE should be used to free the memory in between calls.
-
12:
– Integer *
Output
-
On exit: the number of spectral estimates,
, whose separate parts are held in
g.
-
13:
– 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,
while
. These arguments must satisfy
kc%
when
.
On entry,
while
. These arguments must satisfy
*
nxy when
.
On entry, while . These arguments must satisfy when .
- NE_2_INT_ARG_GT
-
On entry, while . These arguments must satisfy .
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- NE_BAD_PARAM
-
On entry, argument
mt_correction had an illegal value.
- NE_FACTOR_GT
-
At least one of the prime factors of
kc is greater than
.
- NE_INT_ARG_LT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- 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,
pw must not be greater than 1.0:
.
On entry,
pxy must not be greater than 1.0:
.
- NE_REAL_ARG_LT
-
On entry,
pw must not be less than 0.0:
.
On entry,
pxy must not be less than 0.0:
.
- NE_TOO_MANY_FACTORS
-
kc has more than 20 prime factors.
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
g13cdc is not threaded in any implementation.
g13cdc carries out an FFT of length
kc to calculate the sample cross spectrum. The time taken by the function for this is approximately proportional to
(but see function document
c06pac for further details).
10
Example
The example program reads 2 time series of length . It selects mean correction and a 10% tapering proportion. It selects a frequency width of smoothing window, a window shape argument of and an alignment shift of . It then calls g13cdc to calculate the smoothed sample cross spectrum and prints the results.
10.1
Program Text
10.2
Program Data
10.3
Program Results