| cov.dellipse {metRology} | R Documentation |
Constructs a covariance and location object for use in plotting data ellipses.
Description
Constructs a covariance matrix and associated location using a variety
of (possibly robust) estimators. The returned object is suitable for use
by plot.d.ellipse.
Usage
cov.dellipse(x, y = NULL, cov.method = c("spearman", "kendall", "pearson",
"MCD", "OGK", "GK", "gk", "rgk", "mcd", "mve"),
scalefn = NULL, locfn = NULL, cov.control = list())
Arguments
x |
An R |
y |
A numeric vector of the same length as |
cov.method |
A character value specifying the covariance method used. |
scalefn |
A function that computes univariate scale and (optionally) location estimates from a
numeric vector.
If provided, |
locfn |
A function that computes univariate location estimates from a numeric vector.
If used, |
cov.control |
A named list of arguments passed to the covariance calculation used. Note that this can
override |
Details
cov.dellipse is a wrapper for a range of covariance estimation methods found in
various packages. Its operation and defaults depend on the particular covariance
estimator specified by cov.method. Details for each are as follows.
spearman,kendallBy default, the median and mad are used as location and scale respectively, and the covariance is calculated from the product of scale estimates and the Spearman rank correlation or Kendall's tau respectively. If either
scalefnorlocfnis supplied,scalefnis used for scale estimation andlocfnfor location. For bothspearmanandkendall,scalefnis only used as a scale estimator and need not take amu.tooargument.pearsonBy default, the mean and sd are used as location and scale respectively, and the covariance is calculated from the product of scale estimates and the Pearson correlation. If either
scalefnorlocfnis supplied,scalefnis used for scale estimation andlocfnfor location, making it possible (if not very sensible) to use a combination of robust scale or location functions with the Pearson correlation coefficient. For this case,scalefnis only used as a scale estimator and need not take amu.tooargument.MCD,mcdBoth compute the Minimum Covariance Determinant (MCD) estimator, a robust multivariate location and scale estimate with a high breakdown point, via the 'Fast MCD' or 'Deterministic MCD' ("DetMcd") algorithm.
"MCD"uses the implementationcovMcdin the robustbase package;"mcd"usescov.mcdin the MASS package. Neither require or usescalefnorlocfn. Note that these MCD implementations differ appreciably for small samples (at least to n=60).MCDincludes consistency and finite sample correction whereasmcdapparently does not apply a finite sample correction. As a result, themcdscales can be considerably smaller for modest data set sizes.OGKComputes the orthogonalized pairwise covariance matrix estimate described by Maronna and Zamar (2002), as implemented by the
covOGKin the robustbase package. By default, scale and location usescaleTau2from robustbase. Alternatives can be specified either by providing bothscalefnandlocfnor by including an argumentsigmamuincov.control, which is passed tocovOGK. SeecovOGKfor a description ofsigmamu. Ifsigmamuis not present incov.controland bothscalefnandlocfnare provided, scale and location are constructed fromscalefnandlocfn. If only one of these is provided, a warning is issued and]{scaleTau2}is used.GKComputes a simple pairwise covariance estimate suggested by Gnanadesikan and Kettenring (1972), as implemented by the
covGKin the robustbase package. By default, scale and location usescaleTau2from robustbase. Alternatives can be specified either by providingscalefnandlocfnor by including an argumentscalefnincov.control, which is passed tocovGK. SeecovGKfor a description ofscalefn. Ifscalefnis not present incov.control, scale and location are constructed fromscalefnandlocfn. Iflocfnis omitted,scalefnis used if it takes an argumentmu.tooand the median is used otherwise.gkAs
GK, except that the variables are scaled to unit (robust) sd (usingscalefn) before calculating the covariance (which is then rescaled). This can prevent large scale differences from masking outliers in a variable with small scale.rgkImplements Gnanadesikan and Kettenring's second covariance estimate based on scaled variables
(Z_1, Z_2)and a robust correlation\rho^*calculated as\rho^*=(\hat{\sigma}_{+}^{*2} - \hat{\sigma}_{-}^{*2})/(\hat{\sigma}_{+}^{*2} - \hat{\sigma}_{-}^{*2})where
\hat{\sigma}_{+}^{*2}and\hat{\sigma}_{-}^{*2}are robust variances of(Z_1+Z_2)and(Z_1-Z_2)respectively, calculated usingscalefn. The advantage over"gk"and"GK"is that the correlation coefficient is guaranteed to be in[-1,1], making for a positive definite covariance matrix. Scaling also helps prevent large scale differences from masking outliers in a variable with small scale.mveUses uses
cov.mvein the MASS package, which is based on the location and covariance matrix for a minimum volume ellipsoid. The method neither requires nor usesscalefnorlocfn.
Value
An object of class cov.dellipse, which is a list with (at least) components
- method
Character string describing method; identical to
cov.method- cov
2x2 covariance matrix
- cor
2x2 correlation matrix
- center
vector (length 2) specifying centre of ellipse
- scale
vector, length 2, specifying scale estimates for each variable
- n.obs
number of points (rows) used in the covariance estimate
This list is intended to be consistent with that returned by cov.wt.
Author(s)
Stephen L R Ellison
References
Maronna, R.A. and Zamar, R.H. (2002) Robust estimates of location and dispersion of high-dimensional datasets; Technometrics 44(4), 307-317.
Gnanadesikan, R. and John R. Kettenring (1972) Robust estimates, residuals, and outlier detection with multiresponse data. Biometrics 28, 81-124
See Also
cov.rob in MASS, covMcd, covOGK and
covGK in robustbase.
Examples
data(potassium)
cov.dellipse(potassium) #Defaults to Spearman rank correlation
#With different method
cov.dellipse(potassium, cov.method="OGK")
#Same as above but specifying control parameters
library(robustbase) #For scaleTau2
cov.dellipse(potassium, cov.method="OGK", cov.control=list(sigmamu=scaleTau2))
#With individually specified (mad) scale
cov.dellipse(potassium, cov.method="GK", scalefn=mad)
#Defaults to median for location because mad()
#does not accept a mu.too argument
cov.dellipse(potassium, cov.method="GK", scalefn=scaleTau2)
#Defaults to specified scalefn for location because scaleTau2
#accepts mu.too=TRUE