Learn R Programming

pcaL1 (version 1.5.7)

wl1pca: wPCA

Description

Performs a principal component analysis using the algorithm wPCA described by Park and Klabjan (2016).

Usage

wl1pca(X, projDim=1, center=TRUE, projections="l2",
         tolerance=0.001, iterations=200, beta=0.99)

Value

'wl1pca' returns a list with class "wl1pca" containing the following components:

loadings

the matrix of variable loadings. The matrix has dimension ncol(X) x projDim. The columns define the projected subspace.

scores

the matrix of projected points. The matrix has dimension nrow(X) x projDim.

projPoints

the matrix of L2 projections points on the fitted subspace in terms of the original coordinates. The matrix has dimension nrow(X) x ncol(X).

L1error

sum of the L1 norm of reconstruction errors.

nIter

number of iterations.

ElapsedTime

elapsed time.

Arguments

X

data, must be in matrix or table form.

projDim

number of dimensions to project data into, must be an integer, default is 1.

center

whether to center the data using the mean, default is TRUE

projections

whether to calculate projections (reconstructions and scores) using the L2 norm ("l2", default) or the L1 norm ("l1").

tolerance

for testing convergence; if the sum of absolute values of loadings vectors is smaller, then the algorithm terminates.

iterations

maximum number of iterations in optimization routine.

beta

algorithm parameter to set up bound for weights.

Details

The calculation is performed according to the algorithm described by Park and Klabjan (2016). The method is an iteratively reweighted least squares algorithm for L1-norm principal component analysis.

References

Park, Y.W. and Klabjan, D. (2016) Iteratively Reweighted Least Squares Algorithms for L1-Norm Principal Component Analysis, IEEE International Conference on Data Mining (ICDM), 2016. DOI: 10.1109/ICDM.2016.0054

Examples

Run this code
##for 100x10 data matrix X, 
## lying (mostly) in the subspace defined by the first 2 unit vectors, 
## projects data into 1 dimension.
X <- matrix(c(runif(100*2, -10, 10), rep(0,100*8)),nrow=100) +
               matrix(c(rep(0,100*2),rnorm(100*8,0,0.1)),ncol=10)
mywl1pca <- wl1pca(X)

##projects data into 2 dimensions.
mywl1pca <- wl1pca(X, projDim=2, center=FALSE)

## plot first two scores
plot(mywl1pca$scores)

Run the code above in your browser using DataLab