acfrob: Robust Autocorrelation, Autocovariance or Partial...

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

Description

Robustly estimates (and by default plots) the autocorrelation function (acf), the autocovariance function (acvf) or the partial autocorrelation function (pacf) of a time series. This is a wrapper function calling one of various subroutines. See Dürre et al. (2015) for details.

Usage

1
2
3
4
acfrob(x, lag.max = NULL, type = c("correlation", "covariance", "partial"),
  approach = c("GK", "median", "multi", "partrank", "RA", "rank", "filter",
  "trim", "bireg"), ..., plot = TRUE, na.action = na.fail, psd = TRUE,
  scalefn = Qn, partial.method = c("automatic", "durbin-levinson"))

Arguments

x

univariate numeric vector or time series object.

lag.max

integer value giving the maximum lag at which to calculate the acf. Default is 10 * log(length(x), 10).

type

character string giving the type of acf to be computed. Possible values are "correlation" (the default), "covariance" or "partial".

approach

character string naming the approach used for computation, see Details.

...

further arguments passed to the internal function of the respective estimation approach.

plot

logical. If TRUE (the default) the acf is plotted.

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

psd

logical. If TRUE the autocorrelation is enforced to be positive semidefinite, see Details.

scalefn

function which calculates a scale estimator. 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.

partial.method

character string giving the method employed for calculation of the acf in case type == "partial", see Details.

Details

There are many approaches for robust autocorrelation estimation. The argument approach specifies which of the following approaches is to be used, where approach = "GK" is the default.

"GK"

One applies a Gnanadesikan-Kettenring (GK) estimator, which calculates the acf for every lag individually and is based on a scale estimator. This is method is quick and favourable if outliers are isolated. See the help page of acfrob.GK for more details and additional arguments.

"median"

One applies the so called median correlation, which calculates the acf for every lag individually. Basically this estimator substitutes the median for the mean in the definition of the empirical correlation. See the help page of acfrob.median for details.

"multi"

One applies a robust estimator for the correlation matrix to compute the acf en bloc. This method can get quite time consuming if lag.max is large (e.g. larger than 15). It is favourable if outliers occur in blocks. See the help page of acfrob.multi for details and further arguments.

"partrank"

One first calculates the partial autocorrelations and then derive the acf. This procedure has the advantage that one automatically gets a positive definite acf. See the help page of acfrob.partrank for more details and further arguments.

"RA"

One first robustly transforms the time series using a psi function and calculates the usual acf afterwards. See the help page of acfrob.RA for more details and further arguments.

"rank"

One applies a bivariate correlation estimator based on ranks and signs like Spearman's rho, which calculates the acf for every lag individually. It is favourable if one considers integer valued processes. See the help page of acfrob.rank for more details and further arguments.

"filter"

One applies the robust filter algorithm. This is basically a robust version of the Kalman filter. The acf is then either computed by applying the usual acf to the filtered time series or by a robust AR fit. See the help page of acfrob.filter for more details and further arguments.

"trim"

One applies a trimmed correlation, which calculates the acf for every lag individually. This estimator basically substitutes the mean by a trimmed mean in the definition of the empirical correlation. See the help page of acfrob.trim for more details and further arguments.

"bireg"

One applies a robust regression estimator where the dependent variable is the timeseries and the single explanatory variable the lagged timeseries ahifted back by "h" observations for the autocorrelation at lag "h". See the help page of acfrob.bireg for more details and further arguments.

For obtaining the robust autocovariance estimation (type = "covariance"), the acf is multiplied with a robust estimation of the marginal variance of the time series. This estimation is obtained by the squared scale estimator scalefn, which is by default Qn from the package robustbase.

The partial autocorrelation (type = "partial") could be computed by employing several methods. If partial.method = "durbin-levinson" one first estimates the acf by the chosen estimation approach and then derives the pacf from this by applying the Durbin-Levinson algorithm. This method works for all estimation approaches. For some approaches there exists a direct way to obtain the pacf. If partial.method = "automatic" (the default) such a direct way is used wherever it is available and otherwise the Durbin-Levinson algorithm is applied. For approach = "partrank" and approach = "filter" the pacf is calculated anyway and will be used directly if partial.method = "automatic".

Usually a positive definite acf is not guaranteed, alhough this will often be the case. There are some exceptions: the approaches "partrank" and "filter" will always produce positive semidefinite estimations. This is also true for "trim" and "RA" if one uses the argument "biascorr = FALSE". Furthermore the methods "gaussian" and "spearman" (the latter only if "biascorr = FALSE") of the approach "rank" produce positive semidefinite results. If one needs a positive definite and therefore valid acf in the other cases, one can enforce this property by setting psd = TRUE. Usually this will also improve the acf estimation. See the help page of make_acf_psd for more details.

Value

Object of classes "acfrob" and "acf". This is a list which includes all elements of an object of class "acf" (see acf for details) plus the following additional elements:

approach

character string naming the estimation approach. Coincides with argument approach.

are

numeric value giving the asymptotic relative efficiency (ARE) of the estimator as compared to the classical nonrobust estimator, under the assumption that the observations are uncorrelated and from a Gaussian distribution. If the ARE is not available for the chosen estimation approach, it is NA.

Author(s)

Alexander Dürre, Tobias Liboschik and Jonathan Rathjens

References

Dürre, A., Fried, R. and Liboschik, T. (2015): Robust estimation of (partial) autocorrelation, Wiley Interdisciplinary Reviews: Computational Statistics, vol. 7, 205–222, doi: 10.1002/wics.1351.

See Also

S3 method plot.

Classical, nonrobust estimation is provided by the function acf.

The subroutines which actually estimate the acf: acfrob.GK, acfrob.filter, acfrob.median, acfrob.multi, acfrob.partrank, acfrob.RA, acfrob.rank, acfrob.bireg, acfrob.trim.

Examples

1
2
3
4
5
set.seed(1066)
tss <- arima.sim(model = list(ar = 0.3, ma = 0.5), n = 100)
acfrob(tss, plot = FALSE)
acfrob(tss, type = "partial", plot = FALSE)
acfrob(tss, type = "covariance", plot = FALSE)

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