Next: testnfreq() Up: Time Series Macros Help Previous: multitaper()   Contents


spectrum(y, len [,reps]), y a REAL matrix, and len > 0 and reps > 0

Keywords: spectrum analysis, frequency domain
Sy <- spectrum(y, len) computes a smoothed periodogram estimate of the
spectrum of each column of REAL vector or matrix y.

Smoothing is accomplished by 4 successive convolutions of a "boxcar"
smoother of length len.  That is, the smoothing weights are
rep(1/len,len).  The total number of frequencies involved in each
spectrum estimate is 4*len - 3.  When len = 1 no smoothing is done.

spectrum(y, len, reps) does the same, except that reps convolutions
with a boxcar are used.  If reps is odd, then len must also be odd.

spectrum(y, 1) computes the unsmoothed periodogram.

The column means are subtracted before computing the periodograms, but
no other detrending or tapering is done.

See topic 'bandwidth' for information on the approximate bandwidth and
equivalent degrees of freedom associated with these estimates.

The spectrum is computed at the Nfreq Fourier frequencies 0, 1/Nfreq,
2/Nfreq, ..., (Nfreq-1)/Nfreq cycles per unit time, were Nfreq is
determined as follows:

  When variable S is defined and is a positive integer, Nfreq = S.  It
  is an error if S has a prime factor > 29.

  Otherwise, Nfreq = smallest integer >= 2*nrows(y) which has no prime
  factors > 29, that is Nfreq = goodfactors(2*nrows(y)).

Most of the time, macro compfa() is a better choice than spectrum() for
estimating spectra.  compfa() tapers the series and allows polynomial
detrending.  Moreover, you specify the amount of smoothing to use by
either a bandwidth or an EDF (equivalent degrees of freedom).  See
compfa() for details.

Other, quite different, choices for estimating spectra are macros
arspectrum() and burg().

See also arspectrum(), burg(), crsspectrum(), compfa(), compza().

Gary Oehlert 2003-01-15