Description Usage Arguments Details Value Author(s) References See Also Examples
Calculates the spectrum (or the spectral density) of a time series robustly via pre-whitening or via the autocorrelation function, a wrapper calling an internal function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | spectrumrob(x, method = c("pgram", "acf"), plot = TRUE, ...)
spectrumrob.pgram(x, psifn = function(x) M_psi(x, type="smooth"),
arrob.method = c("yw", "regression", "filter", "gm", "nonrobust"),
kernel = c("parzen", "bartlett", "rectangular", "daniell"),
truncation = round(log(length(x), 10) * 10), bandwidth = NULL,
na.action = na.fail, series = deparse(substitute(x)), ...)
spectrumrob.acf(x, acf.approach = c("GK", "median", "multi", "partrank",
"RA", "rank", "trim", "bireg", "nonrobust"),
kernel = c("parzen", "bartlett", "rectangular", "daniell"),
truncation = round(log(length(x), 10) * 10), bandwidth = NULL,
var1 = FALSE, scalefn = Qn, na.action = na.fail,
series = deparse(substitute(x)), ...)
|
x |
numeric vector containing the time series. |
method |
character string giving the calculation method used: |
plot |
logical whether the result is plotted and returned invisibly (the default). |
psifn |
psi function for filtering of residuals if |
arrob.method |
character string giving the calculation method passed to |
acf.approach |
character string giving the approach for robustly estimating the autocorrelation function which is passed to |
kernel |
character string denoting the smoothing kernel used. Possible kernels are |
truncation |
integer value indicating the truncation of the acf for spectrum estimation via Fourier transform of acf. Otherwise this number is converted into the equivalent bandwidth. |
bandwidth |
numeric value giving the bandwidth for smoothing as a proportion of the frequency range. The given bandwidth is converted into the corresponding value for the argument |
var1 |
logical whether the variance estimator is fixed to 1, resulting in a spectral density estimation instead of a real spectrum. This only applies to the case |
scalefn |
function which calculates a scale estimator. Only relevant if |
na.action |
function to be called to handle missing values. Default is |
series |
the name of the time series. |
... |
further arguments passed to the acf calculation by |
There are two general methods to compute a robust spectrum.
If method == "pgram"
the pre-whitening method as described in Chapter 8.14 of Maronna et al. (2006) is applied. The method combines two spectrum estimations. First one fits an AR model robustly. See the help page of arrob
for an overview of possible methods which can be chosen by the argument arrob.method
. Afterwards residuals of this fit are calculated and transformed by a given psi function psifn
, which should project exceptional large values to 0. The usual spectrum of this residuals is then combined with the theoretical spectrum of the AR fit, see Maronna et al. (2006) for details.
If method == "ar"
, the spectrum is calculated directly from acf using the well-known relationship between acf and spectrum. The acf can be estimated robustly by various methods, choosing a specific approach by the argument acf.approach
. See the help page of acfrob
for more details and additional arguments. Because of computational reasons, it is usually not possible to estimate the whole acf up to lag n-1. Truncating the acf will always yield a smoothed estimate. However, this is desirable anyway in most applications.
Since the autocorrelation does not contain information about the scale of the time series, one can only derive the spectral density, which integrates to 1. If one is interested in the classical spectrum, one has to set var1 = FALSE
(the default). In this case the estimated spectral density is transformed to a spectrum using a scale estimator which can be specified using the argument scalefn
.
The degree of smoothing can be either determined by setting either a bandwidth bandwith
or a maximal lag of the acf truncation
. Note that a given bandwidth overwrites any value given by the argument truncation
.
An object of class "spec"
, see spectrum
for details.
Alexander Dürre and Jonathan Rathjens
Maronna, R. A., Martin, R. D., and Yohai, V. J. (2006): Robust Statistics: Theory and Methods, Wiley, chapter 8, doi: 10.1002/0470010940.
Classical, nonrobust estimation is provided by the function spectrum
.
1 2 3 4 | set.seed(1066)
tss <- arima.sim(model = list(ar = 0.3, ma = 5), n = 50)
spectrumrob(tss, method = "pgram", plot = FALSE)
spectrumrob(tss, method = "acf", plot = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.