Package 'robcor'

Title: Robust Correlations
Description: Robust pairwise correlations based on estimates of scale, particularly on "FastQn" one-step M-estimate.
Authors: Paul Smirnov
Maintainer: Paul Smirnov <[email protected]>
License: GPL (>= 2)
Version: 0.1-6.1
Built: 2025-03-01 05:21:29 UTC
Source: https://github.com/cran/robcor

Help Index


Robust, Efficient and Fast Scale Estimate

Description

Compute the robust scale estimator FastQn, an efficient alternative to the MAD, a fast alternative to the Qn.

Usage

FastQn(x, center = median(x), scale = mad(x, center))

fqn(x, center = median(x), scale = mad(x, center))

s_FastQn(x, mu.too = FALSE, center = median(x), ...)

Arguments

x

numeric vector of observations.

center

optionally, the center: defaults to the median.

scale

optionally, the basic scale: defaults to the median absolute deviation.

mu.too

logical indicating if the center should also be returned for s_FastQn().

...

potentially further arguments for s_FastQn() passed to FastQn().

Details

This function computes one-step M-estimate of scale based on provided robust estimate (defaults to the MAD). It gives 50% breakdown point and Gaussian efficiency about 80%.

The fqn function is a shorter alias, like sd and mad.

Value

FastQn() returns a number, the FastQn robust scale estimator.

s_FastQn(x, mu.too=TRUE) returns a length-2 vector with location and scale; this is typically only useful for covOGK(*, sigmamu = s_FastQn) or robcor(*, scaler = s_FastQn).

Author(s)

Paul Smirnov <[email protected]>

References

Smirnov, P. O., Shevlyakov, G. L. (2010). On Approximation of the Qn-Estimate of Scale by Fast M-Estimates. In Book of Abstracts: International Conference on Robust Statistics (ICORS 2010) (pp. 94-95). Prague, Czech Republic.

See Also

mad, Qn.

Examples

set.seed(153)
x <- sort(c(rnorm(80), rt(20, df = 1)))
s_FastQn(x, mu.too=TRUE)
FastQn(x)

Positive Semidefinite Correlation Matrix Correction

Description

Correct pseudo-correlation matrices to make them positive semidefinite ones.

Usage

psdcor(m, method = c("higham", "eigen"), ...)

Arguments

m

pseudo-correlation matrix to correct.

method

optionally, correction method to use.

...

potentially further arguments for the particular correction method.

Details

This function applies transformation to the given matrix in order to make it positive semidefinite correlation matrix.

When method is higham, use Higham projections algorithm via nearPD() function.

When method is eigen, use direct eigenvalues correction via posdefify() function.

Value

The corrected matrix.

Author(s)

Paul Smirnov <[email protected]>


Robust Autocovariance and Autocorrelation Function Estimation

Description

Compute (and by default plot) an estimate of the autocovariance or autocorrelation function.

Usage

robacf(x, lag.max = NULL, type = c("correlation", "covariance"), plot = TRUE,
       scaler = "s_FastQn", ...)

Arguments

x

a univariate numeric time series object or a numeric vector.

lag.max

maximum lag at which to calculate the acf. Default is 10*log10(N) where N is the number of observations. Will be automatically limited to one less than the number of observations in the series.

type

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

plot

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

scaler

location-scale estimator to use in the algorithm. By default, s_FastQn() is used.

...

further arguments to be passed to plot.acf.

Details

This function is a robust replacement for acf().

Note, that implementation and documentation is not finished/polished yet.

Value

A list of class "acf". For description of elements see acf().

Note

WORK-IN-PROGRESS status.

Author(s)

Paul Smirnov <[email protected]>

References

Shevlyakov, G. L., Lyubomishchenko, N. S. and Smirnov, P. O. (2013). Some remarks on robust estimation of power spectra. Proceedings of the 11th International Conference on Computer Data Analysis and Modeling, Minsk, Belarus, 97–104.


Robust Fit Autoregressive Models to Time Series

Description

Fit an autoregressive time series model to the data using robust algorithms.

Usage

robar(x, order = 2, scaler = "s_FastQn")

Arguments

x

a univariate time series.

order

an order of model to fit.

scaler

location-scale estimator to use in the algorithm. By default, s_FastQn() is used.

Details

This function is a robust replacement for ar().

Note, that implementation and documentation is not finished/polished yet.

Value

A list of class "ar". For description of elements see ar().

Note

WORK-IN-PROGRESS status.

Author(s)

Paul Smirnov <[email protected]>

References

Shevlyakov, G. L., Lyubomishchenko, N. S. and Smirnov, P. O. (2013). Some remarks on robust estimation of power spectra. Proceedings of the 11th International Conference on Computer Data Analysis and Modeling, Minsk, Belarus, 97–104.

Examples

n <- 100
set.seed(361)
eps <- as.ts(rnorm(n))
x <- arima.sim(list(ar=c(1,-0.9)), n, innov=eps) # basic signal
z <- as.ts(rbinom(n, 1, 0.1) * rnorm(n, sd=10))  # noise
y <- x + z
spec.ar(robar(y, order=2))

Robust Pairwise Correlations.

Description

Compute a robust estimate of the correlation coefficient or correlation matrix via pairwise correlations.

Usage

robcor(x, y = NULL, method = c("ssd", "quadrant", "mcd"), partial = FALSE,
       post = "psdcor", scaler = "s_FastQn", regress = "lmrob")

Arguments

x

a numeric vector, matrix or data frame.

y

NULL (default) or a vector, matrix or data frame with compatible dimensions to x. The default is equivalent to y = x (but more efficient).

method

a character string indicating which correlation coefficient is to be computed.

partial

logical. Should a partial correlation algorithm be used?

post

function to apply after the matrix is built or NULL. By default, positive semidefinite correction is applied (psdcor()).

scaler

function to use as a location-scale estimator in "ssd" method. By default, s_FastQn() is used.

regress

function to use as a regression estimator in partial correlations algorithm. By default, lmrob() is used.

Details

This function is a robust replacement for cor().

Note, that implementation and documentation is not finished/polished yet.

Value

Either a single correlation coefficient or a correlation matrix estimate.

Note

WORK-IN-PROGRESS status.

Author(s)

Paul Smirnov <[email protected]>

References

Shevlyakov, G. L., Smirnov, P. O. (2011). Robust Estimation of the Correlation Coefficient: An Attempt of Survey. Austrian Journal of Statistics, 40(1&2), 147-156.