Collaborative Representation-based Projection (CRP) is an unsupervised linear
dimension reduction method. Its embedding is based on \(\ell\)_2 graph construction,
similar to that of SPP where sparsity constraint is imposed via \(\ell_1\) optimization problem.
Note that though it may be way faster, rank deficiency can pose a great deal of problems,
especially when the dataset is large.

```
do.crp(
X,
ndim = 2,
preprocess = c("center", "scale", "cscale", "decorrelate", "whiten"),
lambda = 1
)
```

## Arguments

- X
an \((n\times p)\) matrix or data frame whose rows are observations

- ndim
an integer-valued target dimension.

- preprocess
an additional option for preprocessing the data.
Default is "center". See also `aux.preprocess`

for more details.

- lambda
regularization parameter for constructing \(\ell_2\) graph.

## Value

a named list containing

- Y
an \((n\times ndim)\) matrix whose rows are embedded observations.

- trfinfo
a list containing information for out-of-sample prediction.

- projection
a \((p\times ndim)\) whose columns are basis for projection.

## References

Yang W, Wang Z, Sun C (2015).
“A Collaborative Representation Based Projections Method for Feature Extraction.”
*Pattern Recognition*, **48**(1), 20--27.

## Examples

```
## use iris dataset
data(iris)
set.seed(100)
subid = sample(1:150,50)
X = as.matrix(iris[subid,1:4])
lab = as.factor(iris[subid,5])
## test different regularization parameters
out1 <- do.crp(X,ndim=2,lambda=0.1)
out2 <- do.crp(X,ndim=2,lambda=1)
out3 <- do.crp(X,ndim=2,lambda=10)
# visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3))
plot(out1$Y, col=lab, pch=19, main="CRP::lambda=0.1")
plot(out2$Y, col=lab, pch=19, main="CRP::lambda=1")
plot(out3$Y, col=lab, pch=19, main="CRP::lambda=10")
par(opar)
```