Learn R Programming

mt (version 2.0-1.20)

pca.outlier: Outlier detection by PCA

Description

Outlier detection by the Mahalanobis distances of PC1 and PC2. Also plot PC1 and PC2 with its confidence ellipse.

Usage

pca.outlier(x, center = TRUE, scale=TRUE,conf.level = 0.975,...) 

pca.outlier.1(x, center = TRUE, scale=TRUE, conf.level = 0.975, group=NULL, main = "PCA", cex=0.7,...)

Value

A list with components:

plot

plot object of class "trellis" by pca.outlier only.

outlier

Outliers detected.

conf.level

Confidence level used.

mah.dist

Mahalanobis distances of each data sample.

cutoff

Cutoff of Mahalanobis distances used for outlier detection.

Arguments

x

A data frame or matrix.

center

A logical value indicating whether the variables should be shifted to be zero centred before PCA analysis takes place.

scale

A logical value indicating whether the variables should be scaled to have unit variance before PCA analysis takes place.

conf.level

The confidence level for controlling the cutoff of the Mahalanobis distances.

group

A string character or factor indicating group information of row of x. It is used only for plotting.

main

An overall title for PCA plot.

cex

A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default.

...

Further arguments for plotting

Author

Wanchang Lin

See Also

pcaplot, grpplot, panel.outl,panel.elli, pca_plot_wrap

Examples

Run this code
  data(iris)

  ## call lattice version
  pca.outlier(iris[,1:4], adj=-0.5)
  ## plot group
  pca.outlier(iris[,1:4], adj=-0.5,groups=iris[,5])
  ## more information about groups
  pca.outlier(iris[,1:4],groups=iris[,5],adj = -0.5, xlim=c(-5, 5),
                auto.key = list(x = .05, y = .9, corner = c(0, 0)),
                par.settings = list(superpose.symbol=list(pch=rep(1:25))))

  ## call basic graphic version
  pca.outlier.1(iris[,1:4])
  ## plot group
  pca.outlier.1(iris[,1:4], group=iris[,5])

Run the code above in your browser using DataLab