EVOLUTION-MANAGER
Edit File: spec.pgram.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Estimate Spectral Density of a Time Series by a Smoothed...</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for spec.pgram {stats}"><tr><td>spec.pgram {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Estimate Spectral Density of a Time Series by a Smoothed Periodogram</h2> <h3>Description</h3> <p><code>spec.pgram</code> calculates the periodogram using a fast Fourier transform, and optionally smooths the result with a series of modified Daniell smoothers (moving averages giving half weight to the end values). </p> <h3>Usage</h3> <pre> spec.pgram(x, spans = NULL, kernel, taper = 0.1, pad = 0, fast = TRUE, demean = FALSE, detrend = TRUE, plot = TRUE, na.action = na.fail, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>univariate or multivariate time series.</p> </td></tr> <tr valign="top"><td><code>spans</code></td> <td> <p>vector of odd integers giving the widths of modified Daniell smoothers to be used to smooth the periodogram.</p> </td></tr> <tr valign="top"><td><code>kernel</code></td> <td> <p>alternatively, a kernel smoother of class <code>"tskernel"</code>.</p> </td></tr> <tr valign="top"><td><code>taper</code></td> <td> <p>specifies the proportion of data to taper. A split cosine bell taper is applied to this proportion of the data at the beginning and end of the series.</p> </td></tr> <tr valign="top"><td><code>pad</code></td> <td> <p>proportion of data to pad. Zeros are added to the end of the series to increase its length by the proportion <code>pad</code>.</p> </td></tr> <tr valign="top"><td><code>fast</code></td> <td> <p>logical; if <code>TRUE</code>, pad the series to a highly composite length.</p> </td></tr> <tr valign="top"><td><code>demean</code></td> <td> <p>logical. If <code>TRUE</code>, subtract the mean of the series.</p> </td></tr> <tr valign="top"><td><code>detrend</code></td> <td> <p>logical. If <code>TRUE</code>, remove a linear trend from the series. This will also remove the mean.</p> </td></tr> <tr valign="top"><td><code>plot</code></td> <td> <p>plot the periodogram?</p> </td></tr> <tr valign="top"><td><code>na.action</code></td> <td> <p><code>NA</code> action function.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>graphical arguments passed to <code>plot.spec</code>.</p> </td></tr> </table> <h3>Details</h3> <p>The raw periodogram is not a consistent estimator of the spectral density, but adjacent values are asymptotically independent. Hence a consistent estimator can be derived by smoothing the raw periodogram, assuming that the spectral density is smooth. </p> <p>The series will be automatically padded with zeros until the series length is a highly composite number in order to help the Fast Fourier Transform. This is controlled by the <code>fast</code> and not the <code>pad</code> argument. </p> <p>The periodogram at zero is in theory zero as the mean of the series is removed (but this may be affected by tapering): it is replaced by an interpolation of adjacent values during smoothing, and no value is returned for that frequency. </p> <h3>Value</h3> <p>A list object of class <code>"spec"</code> (see <code><a href="spectrum.html">spectrum</a></code>) with the following additional components: </p> <table summary="R valueblock"> <tr valign="top"><td><code>kernel</code></td> <td> <p>The <code>kernel</code> argument, or the kernel constructed from <code>spans</code>.</p> </td></tr> <tr valign="top"><td><code>df</code></td> <td> <p>The distribution of the spectral density estimate can be approximated by a (scaled) chi square distribution with <code>df</code> degrees of freedom.</p> </td></tr> <tr valign="top"><td><code>bandwidth</code></td> <td> <p>The equivalent bandwidth of the kernel smoother as defined by Bloomfield (1976, page 201).</p> </td></tr> <tr valign="top"><td><code>taper</code></td> <td> <p>The value of the <code>taper</code> argument.</p> </td></tr> <tr valign="top"><td><code>pad</code></td> <td> <p>The value of the <code>pad</code> argument.</p> </td></tr> <tr valign="top"><td><code>detrend</code></td> <td> <p>The value of the <code>detrend</code> argument.</p> </td></tr> <tr valign="top"><td><code>demean</code></td> <td> <p>The value of the <code>demean</code> argument.</p> </td></tr> </table> <p>The result is returned invisibly if <code>plot</code> is true. </p> <h3>Author(s)</h3> <p>Originally Martyn Plummer; kernel smoothing by Adrian Trapletti, synthesis by B.D. Ripley </p> <h3>References</h3> <p>Bloomfield, P. (1976) <em>Fourier Analysis of Time Series: An Introduction.</em> Wiley. </p> <p>Brockwell, P.J. and Davis, R.A. (1991) <em>Time Series: Theory and Methods.</em> Second edition. Springer. </p> <p>Venables, W.N. and Ripley, B.D. (2002) <em>Modern Applied Statistics with S.</em> Fourth edition. Springer. (Especially pp. 392–7.) </p> <h3>See Also</h3> <p><code><a href="spectrum.html">spectrum</a></code>, <code><a href="spec.taper.html">spec.taper</a></code>, <code><a href="plot.spec.html">plot.spec</a></code>, <code><a href="fft.html">fft</a></code></p> <h3>Examples</h3> <pre> require(graphics) ## Examples from Venables & Ripley spectrum(ldeaths) spectrum(ldeaths, spans = c(3,5)) spectrum(ldeaths, spans = c(5,7)) spectrum(mdeaths, spans = c(3,3)) spectrum(fdeaths, spans = c(3,3)) ## bivariate example mfdeaths.spc <- spec.pgram(ts.union(mdeaths, fdeaths), spans = c(3,3)) # plots marginal spectra: now plot coherency and phase plot(mfdeaths.spc, plot.type = "coherency") plot(mfdeaths.spc, plot.type = "phase") ## now impose a lack of alignment mfdeaths.spc <- spec.pgram(ts.intersect(mdeaths, lag(fdeaths, 4)), spans = c(3,3), plot = FALSE) plot(mfdeaths.spc, plot.type = "coherency") plot(mfdeaths.spc, plot.type = "phase") stocks.spc <- spectrum(EuStockMarkets, kernel("daniell", c(30,50)), plot = FALSE) plot(stocks.spc, plot.type = "marginal") # the default type plot(stocks.spc, plot.type = "coherency") plot(stocks.spc, plot.type = "phase") sales.spc <- spectrum(ts.union(BJsales, BJsales.lead), kernel("modified.daniell", c(5,7))) plot(sales.spc, plot.type = "coherency") plot(sales.spc, plot.type = "phase") </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>