SPECTRUM Procedure |
@SPECTRUM computes and optionally graphs the estimated spectrum of a single series. Use @CROSSPEC to compute and graph cross-spectral statistics such as coherence and phase.
@SPECTRUM( options ) series start end
Parameters
|
series |
series to analyze |
|
start, end |
range of series to use. By default, the defined range of series. |
Options
ORDINATES=Number of ordinates [depends upon length,seasonal]
WINDOW=[FLAT]/TENT/QUADRATIC
WIDTH=window width [depends upon ordinates]
WEIGHT=VECTOR of customized relative weights for a half-window.
For, instance WEIGHT=||3,2,1|| would give a centered window with weights in the pattern 1,2,3,2,1 normalized to sum to one.
PERIODOGRAM/[NOPERIODOGRAM]
Compute the unsmoothed periodogram rather than a smoothed estimate.
TAPER=TRAPEZOIDAL/COSINE/[NONE]
WTAPER=Taper width [.25 of length]
[GRAPH]/NOGRAPH
HEADER="Header for graph"
FOOTER="Footer for graph"
[LOGSCALE]/NOLOGSCALE
Graph spectrum in log scale or not.
SPECTRUM=(output) series for \([0,\pi]\) spectrum (0 frequency at entry 1)
Variables Defined
|
%EDF |
Equivalent Degrees of Freedom for spectral window. |
Example
*
* Brockwell & Davis, "Time Series Analysis: Theory and Methods"
* Example 10.4.3 on page 354
*
open data sunspots.dat
calendar 1770
data(format=free,org=columns) 1770:1 1869:1 sunspots
*
diff(center) sunspots / cspots
@spectrum(footer="Figure 10.7 Periodogram of Wolfer Sunspot Numbers",$
periodogram,nologscale) cspots
@spectrum(footer="Figure 10.8 Spectral Estimate of Wolfer Sunspot Numbers",$
weights=||3.0,3.0,2.0,1.0||,nologscale,spectrum=smoothed,ordinates=128) cspots
*
* Confidence bands (text only does these for the artificial data). %EDF
* is the Equivalent Degrees of Freedom of the window used by @spectrum.
*
set lower = smoothed*%edf/%invchisqr(.025,%edf)
set upper = smoothed*%edf/%invchisqr(.975,%edf)
graph(footer="Spectral Estimate of Wolfer Sunspot Numbers with 95% Confidence Interval") 3
# smoothed
# lower / 2
# upper / 2
*
* Same thing done on log scale - the confidence bands are equal width
*
graph(footer="Log Spectral Estimate of Wolfer Sunspot Numbers with 95% Confidence Interval",log=10) 3
# smoothed
# lower / 2
# upper / 2
Copyright © 2025 Thomas A. Doan