# NOT RUN {
## Load Iris data and put some noise
data(iris)
noise = 0.2
X = as.matrix(iris[,1:4])
X = X + matrix(noise*rnorm(length(X)), nrow=nrow(X))
label = as.integer(iris$Species)
## try different regularization parameters
rpca1 = do.rpca(X, lambda=0.1)
rpca2 = do.rpca(X, lambda=1)
rpca3 = do.rpca(X, lambda=10)
## apply identical PCA methods
out1 = do.pca(rpca1$L, ndim=2)
out2 = do.pca(rpca2$L, ndim=2)
out3 = do.pca(rpca3$L, ndim=2)
## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3))
plot(out1$Y, col=label, main="RPCA+PCA::lambda=0.1")
plot(out2$Y, col=label, main="RPCA+PCA::lambda=1")
plot(out3$Y, col=label, main="RPCA+PCA::lambda=10")
par(opar)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab