mcd

mcd computes Minimum Covariance Determinant

Syntax

Description

example

RAW =mcd(Y) mcd with all default options.

example

RAW =mcd(Y, Name, Value) mcd with optional arguments.

example

[RAW, REW] =mcd(___) mcd monitoring the reweighted estimates.

example

[RAW, REW, varargout] =mcd(___) mcd monitoring the exctracted subsamples.

Examples

expand all

  • mcd with all default options.
  •     n=200;
        v=3;
        randn('state', 123456);
        Y=randn(n,v);
        % Contaminated data
        Ycont=Y;
        Ycont(1:5,:)=Ycont(1:5,:)+3;
        RAW=mcd(Ycont);
    

  • mcd with optional arguments.
  •     n=200;
        v=3;
        randn('state', 123456);
        Y=randn(n,v);
        % Contaminated data
        Ycont=Y;
        Ycont(1:5,:)=Ycont(1:5,:)+3;
        RAW=mcd(Ycont,'plots',1);
    
    Total estimated time to complete MCD:  0.88 seconds 
    

  • mcd monitoring the reweighted estimates.
  •     n=200;
        v=3;
        randn('state', 123456);
        Y=randn(n,v);
        % Contaminated data
        Ycont=Y;
        Ycont(1:5,:)=Ycont(1:5,:)+3;
        [RAW,REW]=mcd(Ycont);
    

  • mcd monitoring the exctracted subsamples.
  •     n=200;
        v=3;
        randn('state', 123456);
        Y=randn(n,v);
        % Contaminated data
        Ycont=Y;
        Ycont(1:5,:)=Ycont(1:5,:)+3;
        [RAW,REW,C]=mcd(Ycont);
    

    Related Examples

  • mcd applied to the aircraft data (default plots).
  • See Pison et al. 2002, Metrika.

        X = load('aircraft.txt');
        Y = X(:,1:end-1);
        [RAW,RES] = mcd(Y,'bdp',0.25,'plots',1);
    
    Total estimated time to complete MCD:  0.19 seconds 
    

  • mcd applied to the aircraft data (plots using the scale of Pison et al).
  • See Pison et al. 2002, Metrika.

        X = load('aircraft.txt');
        Y = X(:,1:end-1);
        [RAW,REW] = mcd(Y,'bdp',0.25,'ysaveRAW',1);
    
        v=size(Y,2);
        % Compare the following figure with panel (b) of Fig. 8 of Pison et al.
        ylimy=[0 36];
        malindexplot(RAW.md,v,'conflev',0.975,'laby','robust distances','numlab',RAW.outliers,'ylimy',ylimy);
        title('Corrected MCD')
    
        % Compare the following figure with panel (4) of Fig. 8 of Pison et al.
        ylimy=[0 36];
        malindexplot(REW.md,v,'conflev',0.975,'laby','robust distances','numlab',REW.outliers,'ylimy',ylimy);
        title('Corrected reweighted MCD')
    
    
    Total estimated time to complete MCD:  0.26 seconds 
    

    Input Arguments

    expand all

    Y — Data matrix containing n observations on v variables. Rows of Y represent observations, and columns represent variables.

    Missing values (NaN's) and infinite values (Inf's) are allowed, since observations (rows) with missing or infinite values will be excluded from the computations.

    Data Types: single| double

    Name-Value Pair Arguments

    Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

    Example: 'bdp',1/4 , 'nsamp',10000 , 'refsteps',10 , 'reftol',1e-8 , 'refstepsbestr',10 , 'reftolbestr',1e-8 , 'bestr',10 , 'conflev',0.99 , 'conflevrew',0.99 , 'betathresh',1 , 'nocheck',1 , 'plots',1 , 'msg',1 , 'tolMCD',1e-20 , 'ysaveRAW',1 , 'ysaveREW',1 ,

    bdp —Breakdown point.scalar.

    (Number between 0 and 0.5). The default value is 0.5.

    Example: 'bdp',1/4

    Data Types: double

    nsamp —Number of subsamples.scalar.

    Number of subsamples of size v+1 which have to be extracted (if not given, default = 1000).

    Example: 'nsamp',10000

    Data Types: double

    refsteps —Number of refining iterations.scalar.

    Number of refining iterations in each subsample (default = 3).

    refsteps = 0 means "raw-subsampling" without iterations.

    Example: 'refsteps',10

    Data Types: double

    reftol —Refining steps tolerance.scalar.

    Tolerance for the refining steps.

    The default value is 1e-6;

    Example: 'reftol',1e-8

    Data Types: double

    refstepsbestr —Number of refining iterations.scalar.

    Number of refining iterations for each best subset (default = 50).

    Example: 'refstepsbestr',10

    Data Types: double

    reftolbestr —Tolerance for refining steps.scalar.

    Value of tolerance for the refining steps for each of the best subsets.

    The default value is 1e-8;

    Example: 'reftolbestr',1e-8

    Data Types: double

    bestr —Number of best solutions to store.scalar.

    Number of "best locations" to remember from the subsamples. These will be later iterated until convergence (default=5)

    Example: 'bestr',10

    Data Types: double

    conflev —Confidence level.scalar.

    Number between 0 and 1 containing confidence level which is used to declare units as outliers.

    Usually conflev=0.95, 0.975 0.99 (individual alpha) or 1-0.05/n, 1-0.025/n, 1-0.01/n (simultaneous alpha).

    Default value is 0.975

    Example: 'conflev',0.99

    Data Types: double

    conflevrew —Confidence level for use for reweighting.scalar.

    Number between 0 and 1 containing confidence level which is used to do the reweighting step. Default value is the one specified in previous option conflev.

    Example: 'conflevrew',0.99

    Data Types: double

    betathresh —Distribution to use.scalar.

    If betathresh = 1 the distribution which is used to declare units as outliers is a mixture of Rocke scaled F distribution and beta else (default) traditional chi^2 distribution is used.

    Example: 'betathresh',1

    Data Types: double

    nocheck —No check on input data.scalar.

    If nocheck is equal to 1 no check is performed on matrix Y. As default nocheck=0.

    Example: 'nocheck',1

    Data Types: double

    plots —Plot on the screen.scalar | structure.

    If plots is a structure or scalar equal to 1, generates:

    (1) a plot of Mahalanobis distances against index number. The confidence level used to draw the confidence bands for the MD is given by the input option conflev. If conflev is not specified a nominal 0.975 confidence interval will be used.

    (2) a scatter plot matrix with the outliers highlighted.

    If plots is a structure it may contain the following fields

    Value Description
    labeladd

    if this option is '1', the outliers in the spm are labelled with their unit row index. The default value is labeladd='', i.e. no label is added.

    nameY

    cell array of strings containing the labels of the variables. As default value, the labels which are added are Y1, ...Yv.

    Example: 'plots',1

    Data Types: double or structure

    msg —Display or not messages on the screen.scalar.

    If msg==1 (default) messages are displayed on the screen about estimated time to compute the final estimator else no message is displayed on the screen.

    Example: 'msg',1

    Data Types: double

    tolMCD —Tolerance to declare a subset as singular.scalar.

    The default value of tolMCD is exp(-50*v).

    Example: 'tolMCD',1e-20

    Data Types: double

    ysaveRAW —save Y.scalar.

    Scalar that is set to 1 to request that the data matrix Y is saved into the output structure RAW. This feature is meant at simplifying the use of function malindexplot.

    Default is 0, i.e. no saving is done.

    Example: 'ysaveRAW',1

    Data Types: double

    ysaveREW —save Y.scalar.

    Scalar that is set to 1 to request that the data matrix Y is saved into the output structure REW. This feature is meant at simplifying the use of function malindexplot.

    Default is 0, i.e. no saving is done.

    Example: 'ysaveREW',1

    Data Types: double

    smallsamplecor —small sample correction factor.scalar.

    Scalar which defines whether to use or not small sample correction factor to inflate the scale estimate. If it is equal to 1 the small sample correction factor is used. The default value of smallsamplecor is 1, that is the correction is used. See http://users.ugent.be/~svaelst/publications/corrections.pdf for further details about the correction factor.

    Example: 'smallsamplecor',1

    Data Types: double

    Output Arguments

    expand all

    RAW — description Structure

    Structure which contains the following fields

    Value Description
    h

    scalar. The number of observations that have determined the MCD estimator

    loc

    1 x v vector containing raw MCD location of the data

    cov

    robust MCD estimate of covariance matrix. It is the raw MCD covariance matrix (multiplied by a finite sample correction factor and an asymptotic consistency factor).

    cor

    The raw MCD correlation matrix

    obj

    The determinant of the raw MCD covariance matrix.

    bs

    (v+1) x 1 vector containing the units forming best subset associated with MCD estimate of location.

    md

    n x 1 vector containing the estimates of the robust Mahalanobis distances (in squared units). This vector contains the distances of each observation from the raw MCD location of the data, relative to the raw MCD scatter matrix RAW.cov

    outliers

    A vector containing the list of the units declared as outliers using confidence level specified in input scalar conflev

    conflev

    Confidence level that was used to declare outliers

    singsub

    Number of subsets without full rank. Notice that out.singsub > 0.1*(number of subsamples) produces a warning

    weights

    n x 1 vector containing the estimates of the weights.

    Weights assume values 0 or 1. Weight is 1 if the associated observation has been used to compute centroid and covariance matrix. These weights determine which observations are used to compute the final MCD estimates. Unless there is a perfect fit sum(RAW.weights)=h

    plane

    In case of an exact fit, RAW.plane contains the coefficients of a (hyper)plane a_1(x_i1-m_1)+...+a_p(x_ip-m_p)=0 containing at least h observations, where (m_1,...,m_p) is the MCD location of these observations.

    Y

    Data matrix Y. The field is present if option ysaveRAW was set to 1.

    class

    'mcd'

    REW — description Structure

    structure which contains the following fields:

    Value Description
    loc

    The robust location of the data, obtained after reweighting, if the raw MCD is not singular.

    Otherwise the raw MCD center is given here.

    cov

    The robust covariance matrix, obtained after reweighting and multiplying with a finite sample correction factor and an asymptotic consistency factor, if the raw MCD is not singular. Otherwise the raw MCD covariance matrix is given here.

    cor

    The robust correlation matrix, obtained after reweighting

    md

    n x 1 vector containing the estimates of the robust Mahalanobis distances (in squared units). This vector contains the distances of each observation from the reweighted MCD location of the data, relative to the reweighted MCD scatter of the data These distances allow us to easily identify the outliers. If the reweighted MCD is singular, RAW.md is given here.

    outliers

    A vector containing the list of the units declared as outliers after reweighting.

    weights

    n x 1 vector containing the estimates of the weights.

    Weights assume values 0 or 1. Weight is 0 if the associated observation has been declared outlier.

    These weights determine which observations are used to compute the final MCD estimates.

    Remark: if the reweighted MCD is singular, RAW.weights is given here.

    method

    In case of an exact fit, REW.method contains a character string containing information about the method and about singular subsamples (if any).

    plane

    In case of an exact fit, REW.plane contains the coefficients of a (hyper)plane a_1(x_i1-m_1)+...+a_p(x_ip-m_p)=0 containing at least h observations, where (m_1,...,m_p)

    Y

    Data matrix Y. The field is present if option ysaveREW was set to 1.

    class

    'mcdr'.

    More About

    expand all

    Additional Details

    MCD computes the MCD estimator of a multivariate data set. This estimator is given by the subset of h observations with smallest covariance determinant. The MCD location estimate is then the mean of those h points, and the MCD scatter estimate is their covariance matrix.

    The default value of h is roughly 0.5n (where n is the total number of observations), but the user may choose each value between n/2 and n.

    The MCD method is intended for continuous Gaussian variables, and assumes that the number of observations n is at least 5 times the number of variables p. If p is too large relative to n, it is better to use options betathresh=1 (that is to use a threshold based on beta distribution (for the units which determine the centroid and the covariance matrix) and F distribution (for the units which are excluded from the computation of centroid and covariance matrix) The MCD method was introduced in:

    Rousseeuw, P.J. (1984), "Least Median of Squares Regression," Journal of the American Statistical Association, Vol. 79, pp. 871-881.

    The program below uses the technique of concentration steps described in Rousseeuw, P.J. and Van Driessen, K. (1999), "A Fast Algorithm for the Minimum Covariance Determinant Estimator," Technometrics, 41, pp. 212-223.

    The MCD is a robust method in the sense that the estimates are not unduly influenced by outliers in the data, even if there are many outliers.

    Due to the MCD's robustness, we can detect outliers by their large robust distances. The latter are defined like the usual Mahalanobis distance, but based on the MCD location estimate and scatter matrix (instead of the nonrobust sample mean and covariance matrix).

    Remark: when more than h observations lie on a (hyper)plane, (perfect fit case) the program still yields the MCD location and scatter matrix, the latter being singular (as it should be), as well as the equation of the hyperplane.

    References

    Maronna, R.A., Martin D. and Yohai V.J. (2006), Robust Statistics, Theory and Methods, Wiley, New York.

    Acknowledgements

    This function follows the lines of MATLAB/R code developed during the years by many authors. In particular, parts of the code rely on the LIBRA mcd implementation of Hubert and Verboven. For more details, see:

    http://wis.kuleuven.be/stat/robust/LIBRA.html, http://www.econ.kuleuven.be/public/NDBAE06/programs/ and the R library Robustbasehttp://robustbase.r-forge.r-project.org// The core of our routines, e.g. the resampling approach, however, has been completely redesigned, with considerable increase of the computational performance. Note that, for the moment, FSDA does not adopt the 'divide and conquer' partitioning method proposed by Rousseeuw and Van Driessen to speed up computations for large datasets. This partitioning method is applied in the R and LIBRA implementations of the mcd.

    See Also

    This page has been automatically generated by our routine publishFS