The function may be called by the names: g13cbc, nag_tsa_uni_spectrum_daniell or nag_tsa_spectrum_univar.
The supplied time series may be mean or trend corrected (by least squares), and tapered, the tapering factors being those of the split cosine bell:
where and is the tapering proportion.
The unsmoothed sample spectrum
is then calculated for frequency values
where [ ] denotes the integer part.
The smoothed spectrum is returned as a subset of these frequencies for which is a multiple of a chosen value , i.e.,
where . You will normally fix first, then choose so that is sufficiently large to provide an adequate representation for the unsmoothed spectrum, i.e., . It is possible to take , i.e., .
The smoothing is defined by a trapezium window whose shape is supplied by the function
the proportion being supplied by you.
The width of the window is fixed as by supplying . A set of averaging weights are constructed:
where is a normalizing constant, and the smoothed spectrum obtained is
If no smoothing is required should be set to , in which case the values returned are . Otherwise, in order that the smoothing approximates well to an integration, it is essential that , and preferable, but not essential, that be a multiple of . A choice of would normally be required to supply an adequate description of the smoothed spectrum. Typical choices of and should be adequate for usual smoothing situations when .
The sampling distribution of is approximately that of a scaled variate, whose degrees of freedom is provided by the function, together with multiplying limits , from which approximate 95% confidence intervals for the true spectrum may be constructed as . Alternatively, log may be returned, with additive limits.
The bandwidth of the corresponding smoothing window in the frequency domain is also provided. Spectrum estimates separated by (angular) frequencies much greater than may be assumed to be independent.
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
1: – IntegerInput
On entry: the length of the time series, .
2: – NagMeanOrTrendInput
On entry: whether the data are to be initially mean or trend corrected. for no correction, for mean correction, for trend correction.
, or .
3: – doubleInput
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).
4: – IntegerInput
On entry: the value of which determines the frequency width of the smoothing window as . A value of implies no smoothing is to be carried out.
5: – doubleInput
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.
. if .
6: – IntegerInput
On entry: the frequency division, , of smoothed spectral estimates as .
On entry: the order of the fast Fourier transform (FFT), , used to calculate the spectral estimates. kc should be a multiple of small primes such as where is the smallest integer such that , provided .
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.
8: – Nag_LoggedSpectraInput
On entry: indicates whether unlogged or logged spectral estimates and confidence limits are required. for unlogged. for logged.
9: – const doubleInput
On entry: the data points.
10: – double **Output
On exit: vector which contains the ng spectral estimates , for , in to (logged if ). 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.
11: – Integer *Output
On exit: the number of spectral estimates, , in g.
12: – doubleOutput
On exit: four associated statistics. These are the degrees of freedom in , the lower and upper 95% confidence limit factors in and respectively (logged if ), and the bandwidth in .
13: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
On entry, while . These arguments must satisfy kc% when .
On entry, while . These arguments must satisfy when .
The FFT is a numerically stable process, and any errors introduced during the computation will normally be insignificant compared with uncertainty in the data.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g13cbc is not threaded in any implementation.
g13cbc carries out a FFT of length kc to calculate the sample spectrum. The time taken by the function for this is approximately proportional to (but see Section 9 in c06pac for further details).
The example program reads a time series of length . It selects the mean correction option, a tapering proportion of , the option of no smoothing and a frequency division for logged spectral estimates of . It then calls g13cbc to calculate the univariate spectrum and prints the logged spectrum together with 95% confidence limits. The program then selects a smoothing window with frequency width and shape argument and recalculates and prints the logged spectrum and 95% confidence limits.