Computes the "discrete spectral average estimator" of the spectrum of
x, i.e., the periodogram of x is smoothed with the given
kernel k (see Brockwell and Davies (1991), p. 351, for a
definition). If pl is TRUE, then the estimated spectrum
is plotted. Additionally, the plot contains information about the
"equivalent degrees of freedom" df and the bandwidth bw
of k (equation (6.10) of T. Thrall (1983)). If k is a
Daniell(0) kernel, then the periodogram
itself is returned.
Missing values are not handled.
Usage
spectrum (x, k = fejer.kernel(length(x)%/%2,length(x)/10), pl = TRUE, ...)
Arguments
x
a numeric vector or time series.
k
a smoothing kernel of class "kernel".
pl
a logical indicating whether the estimated spectrum is plotted.
P. J. Brockwell and R. A. Davis (1991):
Time Series: Theory and Methods,
2nd Edition, Springer Verlag, NY, pp. 350-365.
T. Thrall (1983): Computer Programming of spectrum estimation, in
D. R. Brillinger and P. R. Krishnaiah (Eds.), Handbook of
Statistics 3, Time Series in the Frequency Domain, Elsevier Science,
North-Holland, pp. 409-437.
data (sales) # Reproduce parts of example 11.7.1, Brockwell and Davis (1991)sal <- diff (sales)
le <- diff (lead)
k <- daniell.kernel (6)
spectrum (le, k)
spectrum (sal, k)