1. Home
  2. SMOOTHSPECTRUM procedure

SMOOTHSPECTRUM procedure

Forms smoothed spectrum estimates for univariate time series (G. Tunnicliffe Wilson & S.J. Welham).

Options

PRINT = string token Controls printed output (description); default desc
METHOD = string token Method to be used for smoothing (lagwindow, direct, YuleWalker, exactautoregressive); default lagw
BANDWIDTH = scalar Frequency domain bandwidth for the smoothing window; must be set if METHOD=dire
MAXLAG = scalar Specifies the cut-off lag (i.e. the maximum lag of autocovariance used in the spectrum calculation) for METHOD=lagw, or the order of the autoregression for METHOD=Yule or exac; if this option is not set then BANDWIDTH must be set, and will be used to determine an appropriate value of MAXLAG
DIVISIONS = scalar Determines the number of frequency divisions into which the range [0.0, 0.5] is divided for calculating the spectrum; the default is chosen so that the bandwidth covers about four intervals
PROBABILITY = scalar Probability value used for confidence limits; default 0.9
TAPER = scalar The proportion of data to be tapered (applied for all settings of METHOD except exac); default 0.0
SHAPE = scalar The shape of the trapezium window (a value of 1.0 specifies a rectangular, and 0.0 a triangular window); default 0.5
YLOG = string token Whether to plot with a log-transformed Y-axis (yes, no); default no
XLOG = string token Whether to plot with a log-transformed X-axis (yes, no); default no
GRAPHICS = string token What sort of graphics to use (lineprinter, highresolution); default high
WINDOW = scalar Window to be used for plotting; default 1
PENS = variate The two pens to be used (after being defined appropriately) for drawing the plots; default !(1,2)

Parameters

SERIES = variates The series for which the spectrum is to be calculated
LENGTH = scalars or variates Scalar specifying that the first N units of the series are to be used, or a variate specifying the first and last units of the series to be used
SPECTRUM = variates Saves the smoothed spectrum; need not be declared in advance, but will be set up as a variate of the appropriate length within the procedure
LOWER = scalars or variates Scalar to save the multiplier of the spectrum used to calculate the lower limit, or a variate to save the values of the lower limit
UPPER = scalars or variates Scalar to save the multiplier of the spectrum used to calculate the upper limit, or a variate to save the values of the upper limit
FREQUENCY = variates Saves the frequency values at which the spectrum is calculated

Description

SMOOTHSPECTRUM calculates smoothed spectrum estimates for a univariate time series. The series is specified in a variate by the SERIES parameter. The parameter LENGTH can be used to specify that only part of the series is to be used: if LENGTH is set to a scalar N, then only units 1…N are used; alternatively, it can define a sub-series by being set to a variate of length 2 holding the numbers of the first and last units to be used. The spectrum can be saved by the SPECTRUM parameter. The method to be used for the smoothing is controlled by the METHOD option, with settings lagwindow for Parzen lag window smoothing, direct for frequency domain smoothing using a trapezium window, YuleWalker for autoregressive spectrum estimation based on Yule-Walker coefficients, and exactautoregressive for autoregressive estimation based on exact likelihood estimation of the coefficients.

For frequency domain smoothing (METHOD=direct), option BANDWIDTH specifies the bandwidth of the smoothing window and option SHAPE the shape of the trapezium window. The BANDWIDTH option is also used to determine an appropriate default for the MAXLAG option if this is not specified with other METHOD settings: for METHOD=lagwindow, MAXLAG specifies the cut-off lag (i.e. the maximum lag of autocovariance used in the spectrum calculation), while for METHOD=YuleWalker or exactautoregressive, it specifies the order of the autoregression.

The DIVISIONS option can define the number of frequency divisions into which the range [0.0, 0.5] is divided for calculating the spectrum; if this is omitted a default is chosen so that the bandwidth covers about four intervals. The frequency values at which the spectrum is calculated can be saved, in a variate, by the FREQUENCY parameter. The proportion of data to be tapered (relevant to all settings of METHOD except exactautoregressive) is controlled by the TAPER option; by default there is no tapering.

The LOWER and UPPER parameters can be set to scalars to save the scaling factor used to calculate the upper and lower bounds, or to variates to save the upper and lower bounds for the SPECTRUM variate.

Printed output can be suppressed by setting the option PRINT=*; by default, PRINT=description. The PROBABILITY option indicates the probability value used for confidence limits; 0.9 is used as the default.

The procedure will also plot the spectrum: option GRAPHICS controls whether this is done for line printer or on a high-resolution device. With high-resolution graphics, the plot will be produced using the current settings of the window specifed by the WINDOW option; by default WINDOW=1. The FRAME directive can be used to set the attributes of the window prior to calling the procedure. The PENS option controls which pens are to be used for the plots; the attributes of these pens are modified within the procedure. By default pens 1 and 2 are used, but these can be changed by setting option PENS to a variate of length 2 containing the numbers of the two pens required. Options YLOG and XLOG allow the X- and Y-axes to be represented on a logarithmic scale.

Options: PRINT, METHOD, BANDWIDTH, MAXLAG, DIVISIONS, PROBABILITY, TAPER, SHAPE, YLOG, XLOG, GRAPHICS, WINDOW, PENS.

Parameters: SERIES, LENGTH, SPECTRUM, LOWER, UPPER, FREQUENCY.

Method

A cosine bell window is used for the taper, with lag window and direct spectral smoothing carried out esentially as described in Bloomfield (1976). The autoregressive spectrum estimation uses the standard Yule-Walker equations, as presented for example in Box & Jenkins (1970). These are optionally refined by exact maximum likelihood estimation. The theoretical spectrum of the autoregressive model is then calculated. The error limits are calculated using scaled chi-square distributions. These are quite good for the case of lag window and direct smoothing, but in small samples are only very approximate for the autoregressive estimates. The series values are mean corrected before spectrum estimation, but not trend corrected.

Action with RESTRICT

Input and output structures must not be restricted; restriction of the input series to a contiguous set of units can be achieved by use of the LENGTH parameter.

References

Bloomfield, P. (1976). Fourier Analysis of Time Series: an Introduction. Wiley, New York.

Box, G.E.P. & Jenkins, G.M. (1970). Time Series Analysis, Forecasting and Control. Holden-Day, San Francisco.

See also

Directive: FOURIER.

Procedures: DFOURIER, MCROSSPECTRUM, PERIODTEST, PREWHITEN, REPPERIODOGRAM.

Commands for: Time series.

Example

CAPTION 'SMOOTHSPECTRUM example',\
        !t('Data from D.F. Andrews & A.M. Herzberg (1985),',\
        'Data: a collection of problems from many fields for the',\
        'student and research worker, Springer-Verlag: New York, p. 369.');\
        STYLE=meta,plain
VARIATE [VALUES =\
        8.075, 7.819, 7.366, 8.113, 7.380, 7.134, 7.222, 7.768,\
        7.386, 6.965, 6.478, 8.105, 8.060, 7.684, 7.580, 7.093,\
        6.129, 6.026, 6.679, 7.414, 7.112, 7.762, 7.645, 8.639,\
        7.667, 8.080, 6.678, 6.739, 5.569, 5.049, 5.642, 6.808,\
        6.636, 8.241, 7.968, 8.044, 7.791, 7.024, 6.102, 6.053,\
        5.941, 5.386, 5.811, 6.716, 6.923, 6.939, 6.705, 6.914] Profit
SMOOTHSPECTRUM [GRAPHICS=line; BANDWIDTH=0.05] Profit
SMOOTHSPECTRUM [GRAPHICS=line; METHOD=exactautoregressive; MAXLAG=8] Profit
Updated on March 5, 2019

Was this article helpful?