Learn R Programming

maigesPack (version 1.36.0)

robustCorr: Calculate a robust correlation value

Description

This function is intended to calculate robust correlation values between pairs of rows of numerical matrix or between two numerical vectors.

Usage

robustCorr(x, y=NULL)

Arguments

x
numerical matrix or vector. If a matrix the method calculates the robust correlations between all pairs of rows. If x is a vector, y must be specified as another vector of same length as x and the robust correlation between them is calculate.
y
optional numeric vector, must be specified if x is a vector.

Value

If x is a matrix, the method return a list with two square matrices, the first one containing the robust correlation values between all pairs of rows from x and the second containing the index of the point removed from calculation. If x is a vector, y must be specified and the function return a list with the robust correlation value between them and the index of the point removed.

Details

This function calculates a robust correlation value in a procedure similar to the leave-one-out used for cross-validation of classification results. The algorithm removes one point at a time and calculates a usual Pearson correlation value. Them, with a vector r of correlation values that has the same length as the columns of x (or vectors x and y), the algorithm decides by the min(r) or max(r), according with that one that is more distant from the median value.

See Also

cor from package stats.

Examples

Run this code
x <- runif(50, 0, 1)
y <- rbeta(50, 1, 2)
robustCorr(x, y)

z <- matrix(rnorm(100, 0, 1), 4, 25)
robustCorr(z)

Run the code above in your browser using DataLab