spectrumrob: Robust Spectrum

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

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.

Usage

 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)), ...)

Arguments

x

numeric vector containing the time series.

method

character string giving the calculation method used: "pgram" for the pre-whitening method and "acf" for calculation from a robustly estimated acf, see Details.

plot

logical whether the result is plotted and returned invisibly (the default).

psifn

psi function for filtering of residuals if method = "pgram", see Details.

arrob.method

character string giving the calculation method passed to arrob if method = "pgram", see there for details. One can additionally choose a nonrobust approach by "nonrobust".

acf.approach

character string giving the approach for robustly estimating the autocorrelation function which is passed to acfrob if method = "acf", see there for details. One can additionally choose a nonrobust approach by "nonrobust" but not the approach "filter".

kernel

character string denoting the smoothing kernel used. Possible kernels are "parzen" (the default), "bartlett", "rectangular" and "daniell".

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 truncation, which overrides any value given by that argument. Only if this argument is NULL, the given truncation is converted into the corresponding bandwidth and used for smoothing. A bandwidth of zero prevents from smoothing or at least tries to minimize smoothing if the method = "acf".

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 method = "acf".

scalefn

function which calculates a scale estimator. Only relevant if var1 = FALSE. Its argument must be a vector of the data. One could for example use one of the functions Qn (the default), Sn, scaleTau2 (all from the package robustbase), mad or (not robust) sd.

na.action

function to be called to handle missing values. Default is na.fail. Other reasonable possibilities are na.omit (omits all missing values at the beginning and the end of the time series and fails if there are more missing values), na.contiguous (uses longest contiguous stretch of non-missing observations) and na.extremify (experimental, sets missing values to very extreme values in the expectation that they have only little influence on the outcome of robust estimation methods).

series

the name of the time series.

...

further arguments passed to the acf calculation by acfrob if method == "acf" or the AR calculation if method == "pgram".

Details

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.

Value

An object of class "spec", see spectrum for details.

Author(s)

Alexander Dürre and Jonathan Rathjens

References

Maronna, R. A., Martin, R. D., and Yohai, V. J. (2006): Robust Statistics: Theory and Methods, Wiley, chapter 8, doi: 10.1002/0470010940.

See Also

Classical, nonrobust estimation is provided by the function spectrum.

Examples

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)

robts documentation built on May 2, 2019, 4:55 p.m.