The function calculates weights used in the calculation of biweight midcovariance and midcorrelation. The weights are designed such that outliers get smaller weights; the weights become zero for data points more than 9 median absolute deviations from the median.
bicovWeights(x, pearsonFallback = TRUE, maxPOutliers = 1,
outlierReferenceWeight = 0.5625,
defaultWeight = 0)
A vector or a two-dimensional array (matrix or data frame). If two-dimensional, the weights will be calculated separately on each column.
Logical: if the median absolute deviation is zero, should standard deviation be substituted?
Optional specification of the maximum proportion of outliers, i.e., data with weights equal to
outlierReferenceWeight
below.
A number between 0 and 1 specifying what is to be considered an outlier when calculating the proportion of outliers.
Value used for weights that correspond to a finite x
but the weights themselves
would not be finite, for example, when a column in x
is constant.
A vector or matrix of the same dimensions as the input x
giving the weights.
This function is based on Equation (3) in
Langfelder P, Horvath S (2012) Fast R Functions for Robust Correlations and Hierarchical Clustering Journal of Statistical Software 46(11) 1-17 PMID: 23050260 PMCID: PMC3465711
That article also describes the Pearson fallback and maximum proportion of outliers in detail. For a full discussion of the biweight midcovariance and midcorrelation, see
Wilcox RR (2005). Introduction to Robust Estimation and Hypothesis Testing. 2nd edition. Academic Press, Section 9.3.8, page 399 as well as Section 3.12.1, page 83.
# NOT RUN {
x = rnorm(100);
x[1] = 10;
plot(x, bicovWeights(x));
# }
Run the code above in your browser using DataLab