Last chance! 50% off unlimited learning
Sale ends in
spectrum
function estimates the spectral density of a
time series.spectrum(x, …, method = c("pgram", "ar"))
"pgram"
(the default)
and "ar"
. Can be abbreviated.plot.spec
."spec"
, which is a list containing at
least the following components:
freq
.NULL
for univariate series. For multivariate time
series, a matrix containing the squared coherency
between different
series. Column coh
contains the squared coherency between columns x
, where NULL
for univariate series. For multivariate
time series a matrix containing the cross-spectrum phase between
different series. The format is the same as coh
.plot
is true.spectrum
is a wrapper function which calls the methods
spec.pgram
and spec.ar
. The spectrum here is defined with scaling 1/frequency(x)
,
following S-PLUS. This makes the spectral density a density over the
range (-frequency(x)/2, +frequency(x)/2]
, whereas a more common
scaling is plot.spec
: this is asymmetric, and the width of the centre
mark indicates the equivalent bandwidth.spec.ar
,
spec.pgram
;
plot.spec
.require(graphics)
## Examples from Venables & Ripley
## spec.pgram
par(mfrow = c(2,2))
spectrum(lh)
spectrum(lh, spans = 3)
spectrum(lh, spans = c(3,3))
spectrum(lh, spans = c(3,5))
spectrum(ldeaths)
spectrum(ldeaths, spans = c(3,3))
spectrum(ldeaths, spans = c(3,5))
spectrum(ldeaths, spans = c(5,7))
spectrum(ldeaths, spans = c(5,7), log = "dB", ci = 0.8)
# for multivariate examples see the help for spec.pgram
## spec.ar
spectrum(lh, method = "ar")
spectrum(ldeaths, method = "ar")
Run the code above in your browser using DataLab