awl1pca: awPCA

View source: R/awl1pca.R

awl1pcaR Documentation

awPCA

Description

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

Usage

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

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.

gamma

algorithm parameter to determine whether to use approximation formula or prcomp function.

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.

Value

'awl1pca' returns a list with class "awl1pca" 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-norm projections of 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.

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

##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)
myawl1pca <- awl1pca(X)

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

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

pcaL1 documentation built on Jan. 22, 2023, 1:55 a.m.