sparsel1pca: SparsEl1-PCA

sparsel1pcaR Documentation

SparsEl1-PCA

Description

L1-norm line fitting with L1-regularization.

Usage

   sparsel1pca(X, projDim=1, center=TRUE, projections="none", lambda=0)

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 median, default is TRUE.

projections

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

lambda

If negative and number of rows is at most 100, calculates all possible breakpoints for the regularization parameter. Otherwise, fits a regularlized line with lambda set to that value.

Details

The calculation is performed according to the algorithm described by Ling and Brooks (2023, working paper). The algorithm finds successive, orthogonal fitted lines in the data.

Value

'sparsel1pca' returns a list with class "sparsel1pca" 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.

dispExp

the proportion of L1 dispersion explained by the loadings vectors. Calculated as the L1 dispersion of the score on each component divided by the L1 dispersion in the original data.

projPoints

the matrix of projected points in terms of the original coordinates. The matrix has dimension nrow(X) x ncol(X).

minobjectives

the L1 distance of points to their projections in the fitted subspace.

References

Ling, X. and Brooks J.P. (2023) L1-Norm Regularized L1-Norm Best-Fit Lines, working paper.

Examples

##for a 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)
mysparsel1pca <- sparsel1pca(X, lambda=0.5)

##projects data into 2 dimensions.
mysparsel1pca <- sparsel1pca(X, projDim=2, center=FALSE, projections="l1", lambda=0.5)

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

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