spectrum {stats} | R Documentation |
Spectral Density Estimation
Description
The spectrum
function estimates the spectral density of a
time series.
Usage
spectrum(x, ..., method = c("pgram", "ar"))
Arguments
x |
A univariate or multivariate time series. |
method |
String specifying the method used to estimate the
spectral density. Allowed methods are |
... |
Further arguments to specific spec methods or
|
Details
spectrum
is a wrapper function which calls the methods
spec.pgram
and spec.ar
.
The spectrum here is defined (for historical compatibility) with
scaling 1/frequency(x)
.
This makes the spectral density a density over the range
(-frequency(x)/2, +frequency(x)/2]
,
whereas a more common scaling is 2\pi
and range
(-0.5, 0.5]
(e.g., Bloomfield 1976) or 1 and range
(-\pi, \pi]
.
If available, a confidence interval will be plotted by
plot.spec
: this is asymmetric, and the width of the centre
mark indicates the equivalent bandwidth.
Value
An object of class "spec"
, which is a list containing at
least the following components:
freq |
vector of frequencies at which the spectral density is estimated. (Possibly approximate Fourier frequencies.) The units are the reciprocal of cycles per unit time (and not per observation spacing): see ‘Details’ below. |
spec |
Vector (for univariate series) or matrix (for multivariate
series) of estimates of the spectral density at frequencies
corresponding to |
coh |
|
phase |
|
series |
The name of the time series. |
snames |
For multivariate input, the names of the component series. |
method |
The method used to calculate the spectrum. |
The result is returned invisibly if plot
is true.
Note
The default plot for objects of class "spec"
is quite complex,
including an error bar and default title, subtitle and axis
labels. The defaults can all be overridden by supplying the
appropriate graphical parameters.
Author(s)
Martyn Plummer, B.D. Ripley
References
Bloomfield P (1976). Fourier Analysis of Time Series: An Introduction. Wiley.
Brockwell PJ, Davis RA (1991). Time Series: Theory and Methods, series Springer Series in Statistics. Springer New York. ISBN 9780387974293.
Venables WN, Ripley BD (2002).
Modern Applied Statistics with S, series Statistics and Computing.
Springer, New York, NY.
doi:10.1007/978-0-387-21706-2.
(Especially
pages 392–7.)
See Also
spec.ar
,
spec.pgram
;
plot.spec
.
Examples
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")