#see SPCA.R for a more in-depth example
d <- 500 # dimension
m <- 1000 # sample size
a <- normalize(matrix(rnorm(m * d), m, d))
lambda1 <- 0.1 * matrix(data=1, nrow=4, ncol=1)
x0 <- svd(a, nv=4)$v
sprout <- spca.amanpg(a, lambda1, lambda2=Inf, f_palm=1e5, x0=x0, y0=x0, k=4, type=0,
gamma=0.5, maxiter=1e4, tol=1e-5, normalize = FALSE, verbose=FALSE)
print(paste(sprout$iter, "iterations,", sprout$sparsity, "sparsity,", sprout$time))
#extract loadings
#print(sprout$loadings)
Run the code above in your browser using DataLab