Learn R Programming

robustbase (version 0.9-8)

covMcd: Robust Location and Scatter Estimation via MCD

Description

Compute a robust multivariate location and scale estimate with a high breakdown point, using the Fast MCD (Minimum Covariance Determinant) estimator.

Usage

covMcd(x, cor = FALSE, raw.only = FALSE,
       alpha =, nsamp =, nmini =, seed =, tolSolve=, trace =,
       use.correction =, wgtFUN =, control = rrcov.control())

Arguments

x
a matrix or data frame.
cor
should the returned result include a correlation matrix? Default is cor = FALSE
raw.only
should only the raw estimate be returned, i.e., no weighted reweit the returned result include a correlation matrix? Default is cor = FALSE
alpha
numeric parameter controlling the size of the subsets over which the determinant is minimized, i.e., alpha*n observations are used for computing the determinant. Allowed values are between 0.5 and 1 and the default is 0.5.
nsamp
number of subsets used for initial estimates or "best" or "exact". Default is nsamp = 500. For nsamp = "best" exhaustive enumeration is done, as long as the number of trials does not exceed
nmini
for large $n$, the algorithm splits the data into maximally $k_{\mathrm{rep}} = 5$ subsets of size nmini. The original algorithm had nmini = 300 hard coded.
seed
initial seed for random generator, see rrcov.control.
tolSolve
numeric tolerance to be used for inversion (solve) of the covariance matrix in mahalanobis.
trace
logical (or integer) indicating if intermediate results should be printed; defaults to FALSE; values $\ge 2$ also produce print from the internal (Fortran) code.
use.correction
whether to use finite sample correction factors; defaults to TRUE.
wgtFUN
a character string or function, specifying how the weights for the reweighting step should be computed. Up to April 2013, the only option has been the original proposal in (1999), now specified
control
a list with estimation options - this includes those above provided in the function specification, see rrcov.control for the defaults. If control is supplied, the parameters

Value

  • An object of class "mcd" which is basically a list with components
  • centerthe final estimate of location.
  • covthe final estimate of scatter.
  • corthe (final) estimate of the correlation matrix (only if cor = TRUE).
  • critthe value of the criterion, i.e. the determinant.
  • bestthe best subset found and used for computing the raw estimates, with length(best) == quan = h.alpha.n(alpha,n,p).
  • mahmahalanobis distances of the observations using the final estimate of the location and scatter.
  • mcd.wtweights of the observations using the final estimate of the location and scatter.
  • cnp2a vector of length two containing the consistency correction factor and the finite sample correction factor of the final estimate of the covariance matrix.
  • raw.centerthe raw (not reweighted) estimate of location.
  • raw.covthe raw (not reweighted) estimate of scatter.
  • raw.mahmahalanobis distances of the observations based on the raw estimate of the location and scatter.
  • raw.weightsweights of the observations based on the raw estimate of the location and scatter.
  • raw.cnp2a vector of length two containing the consistency correction factor and the finite sample correction factor of the raw estimate of the covariance matrix.
  • Xthe input data as numeric matrix, without NAs.
  • n.obstotal number of observations.
  • alphathe size of the subsets over which the determinant is minimized (the default is $(n+p+1)/2$).
  • quanthe number of observations, $h$, on which the MCD is based. If quan equals n.obs, the MCD is the classical covariance matrix.
  • methodcharacter string naming the method (Minimum Covariance Determinant).
  • callthe call used (see match.call).

newcommand

\CRANpkg

href

http://CRAN.R-project.org/package=#1

pkg

#1

concept

High breakdown point

Details

The minimum covariance determinant estimator of location and scatter implemented in covMcd() is similar to Rfunction cov.mcd() in MASS. The MCD method looks for the $h (> n/2)$ ($h = h(\alpha,n,p) =$ h.alpha.n(alpha,n,p)) observations (out of $n$) whose classical covariance matrix has the lowest possible determinant.

The raw MCD estimate of location is then the average of these $h$ points, whereas the raw MCD estimate of scatter is their covariance matrix, multiplied by a consistency factor and (if use.correction is true) a finite sample correction factor, to make it consistent at the normal model and unbiased at small samples. Both rescaling factors (consistency and finite sample) are returned in the length-2 vector raw.cnp2.

The implementation of covMcd uses the Fast MCD algorithm of Rousseeuw and Van Driessen (1999) to approximate the minimum covariance determinant estimator.

Based on these raw MCD estimates, (unless argument raw.only is true), a reweighting step is performed, i.e., V <- cov.wt(x,w), where w are weights determined by outlyingness with the respect to the scaled raw MCD. Again, a consistency factor and (if use.correction is true) a finite sample correction factor are applied. The reweighted covariance is typically considerably more efficient than the raw one, see Pison et al. (2002).

The two rescaling factors for the reweighted estimates are returned in cnp2. Details for the computation of the finite sample correction factors can be found in Pison et al. (2002).

References

P. J. Rousseeuw and A. M. Leroy (1987) Robust Regression and Outlier Detection. Wiley.

P. J. Rousseeuw and K. van Driessen (1999) A fast algorithm for the minimum covariance determinant estimator. Technometrics 41, 212--223.

Pison, G., Van Aelst, S., and Willems, G. (2002), Small Sample Corrections for LTS and MCD, Metrika 55, 111--123.

See Also

cov.mcd from package MASS; covOGK as cheaper alternative for larger dimensions.

BACON and covNNC, from package robustX;

Examples

Run this code
data(hbk)
hbk.x <- data.matrix(hbk[, 1:3])
covMcd(hbk.x)

## the following three statements are equivalent
c1 <- covMcd(hbk.x, alpha = 0.75)
c2 <- covMcd(hbk.x, control = rrcov.control(alpha = 0.75))
## direct specification overrides control one:
c3 <- covMcd(hbk.x, alpha = 0.75,
             control = rrcov.control(alpha=0.95))
c1

Run the code above in your browser using DataLab