Learn R Programming

rrcov (version 0.4-08)

PcaProj: Robust Principal Components based on Projection Pursuit (PP): Croux and Ruiz-Gazen (2005) algorithm

Description

A fast and simple algorithm for approximating the PP-estimators for PCA: Croux and Ruiz-Gazen (2005)

Usage

PcaProj(x, ...)
    ## S3 method for class 'default':
PcaProj(x, k = 0, kmax = ncol(x), na.action = na.fail, trace=FALSE, ...)
    ## S3 method for class 'formula':
PcaProj(formula, data = NULL, subset, na.action, \dots)

Arguments

formula
a formula with no response variable, referring only to numeric variables.
data
an optional data frame (or similar: see model.frame) containing the variables in the formula formula.
subset
an optional vector used to select rows (observations) of the data matrix x.
na.action
a function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options, and is
...
arguments passed to or from other methods.
x
a numeric matrix (or data frame) which provides the data for the principal components analysis.
k
number of principal components to compute. If k is missing, or k = 0, the algorithm itself will determine the number of components by finding such k that $l_k/l_1 >= 10.E-3$ and $\Sigma_{j=1}^k l_j/
kmax
maximal number of principal components to compute. Default is kmax=10. If k is provided, kmax does not need to be specified, unless k is larger than 10.
trace
whether to print intermediate results. Default is trace = FALSE

Value

Details

PcaProj, serving as a constructor for objects of class PcaProj-class is a generic function with "formula" and "default" methods. For details see PCAproj and the relevant references.

References

C. Croux, A. Ruiz-Gazen (2005). High breakdown estimators for principal components: The projection-pursuit approach revisited, Journal of Multivariate Analysis, 95, 206--226.

Examples

Run this code
# multivariate data with outliers
    library(mvtnorm)
    x <- rbind(rmvnorm(200, rep(0, 6), diag(c(5, rep(1,5)))),
                rmvnorm( 15, c(0, rep(20, 5)), diag(rep(1, 6))))
    # Here we calculate the principal components with PCAgrid
    pc <- PcaProj(x, 6)
    # we could draw a biplot too:
    biplot(pc)
    
    # we could use another calculation method and another objective function, and 
    # maybe only calculate the first three principal components:
    pc <- PcaProj(x, 3, method="qn", CalcMethod="sphere")
    biplot(pc)
    
    # now we want to compare the results with the non-robust principal components
    pc <- PcaClassic(x)
    # again, a biplot for comparision:
    biplot(pc)

Run the code above in your browser using DataLab