The SPECTRA Procedure

Overview: SPECTRA Procedure

The SPECTRA procedure performs spectral and cross-spectral analysis of time series. You can use spectral analysis techniques to look for periodicities or cyclical patterns in data.

The SPECTRA procedure produces estimates of the spectral and cross-spectral densities of a multivariate time series. Estimates of the spectral and cross-spectral densities of a multivariate time series are produced using a finite Fourier transform to obtain periodograms and cross-periodograms. The periodogram ordinates are smoothed by a moving average to produce estimated spectral and cross-spectral densities. PROC SPECTRA can also test whether or not the data are white noise.

PROC SPECTRA uses the finite Fourier transform to decompose data series into a sum of sine and cosine waves of different amplitudes and wavelengths. The finite Fourier transform decomposition of the series $x_ t$ is

\begin{align*}  x_ t & = \frac{a_0}{2} + \sum _{k=1}^{m-1}f_ k ( a_{k} \cos \omega _ kt +b_{k} \sin \omega _ kt ) \\ f_ k & = \begin{cases}  1/2 & \textrm{if $n$ is even and $k=m-1$}\\ 1 & \textrm{otherwise} \end{cases}\end{align*}

where

$t$

is the time subscript, $t=0,1,2,\dots ,n-1$

$x_{t}$

are the equally spaced time series data

$n$

is the number of observations in the time series

$m$

is the number of frequencies in the Fourier decomposition: $m=\frac{n+2}{2}$ if $n$ is even, $m=\frac{n+1}{2}$ if $n$ is odd

$k$

is the frequency subscript, $k=0,1,2,\dots ,m-1$

${a_{0}}$

is the mean term: ${a_{0} = 2 {\overline x}}$

${a_{k}}$

are the cosine coefficients

${b_{k}}$

are the sine coefficients

${{\omega }_{k}}$

are the Fourier frequencies: ${{\omega }_{k} = \frac{2{\pi }k}{n}}$

Functions of the Fourier coefficients ${a_{k}}$ and ${b_{k}}$ can be plotted against frequency or against wave length to form periodograms. The amplitude periodogram ${J_{k}}$ is defined as follows:

\[  J_{k}=\frac{n}{2} ( a^{2}_{k}+ b^{2}_{k} )  \]

Several definitions of the term periodogram are used in the spectral analysis literature. The following discussion refers to the ${J_{k}}$ sequence as the periodogram.

The periodogram can be interpreted as the contribution of the kth harmonic ${{\omega }_{k}}$ to the total sum of squares (in an analysis of variance sense) in the decomposition of the process into two-degree-of-freedom components for each of the m frequencies. When n is even, ${{sin}( {\omega }_{\frac{n}{2}} )}$ is zero, and thus the last periodogram value is a one-degree-of-freedom component.

The periodogram is a volatile and inconsistent estimator of the spectrum. The spectral density estimate is produced by smoothing the periodogram. Smoothing reduces the variance of the estimator but introduces a bias. The weight function used for the smoothing process, W(), often called the kernel or spectral window, is specified with the WEIGHTS statement. It is related to another weight function, w(), the lag window, that is used in other methods to taper the correlogram rather than to smooth the periodogram. Many specific weighting functions have been suggested in the literature (Fuller, 1976; Jenkins and Watts, 1968; Priestley, 1981). Table 26.3 later in this chapter gives the relevant formulas when the WEIGHTS statement is used.

Letting i represent the imaginary unit ${\sqrt {-1}}$, the cross-periodogram is defined as follows:

\[  J^{xy}_{k} = \frac{n}{2} ( a^{x}_{k} a^{y}_{k} + b^{x}_{k} b^{y}_{k} ) + i \frac{n}{2} ( a^{x}_{k} b^{y}_{k} - b^{x}_{k} a^{y}_{k} )  \]

The cross-spectral density estimate is produced by smoothing the cross-periodogram in the same way as the periodograms are smoothed using the spectral window specified by the WEIGHTS statement.

The SPECTRA procedure creates an output SAS data set whose variables contain values of the periodograms, cross-periodograms, estimates of spectral densities, and estimates of cross-spectral densities. The form of the output data set is described in the section OUT= Data Set.