Sparse PCA using elasticnet package in R - How to know how many number of nonzero values in one PC? Can someone help me on Sparse PCA? I am using the "elasticnet" package to perform sparse PCA. I am having a hard time in figuring out how many nonzero values should a component contain? 
For example, In this code: 
sparse.pca.result  <-  spca(X, K = 2, type = "predictor", sparse = "varnum", para = c(4, 4))

(para = c(4, 4)) indicates the number of non-zero components for each of the two PC’s respectively.
So the question is, how to identify the number of non-zero components?
I hope that someone could help me on this. 
 A: One way to do this a little more adaptively is to specify the penalty instead of the number of nonzeroes you want. (Set sparse='penalty'.) Then you can specify the same parameter value across all components, while still allowing them to have different levels of sparsity.
Ordinarily, one might select the penalty parameter via cross-validation, but spca cannot deal with missing values, so it's hard to hold out a set of entries. You could hack together something similar, though:


*

*Train the SPCA, holding out one case. You'll obtain L and R such that $X_{-1} \approx LR$. (Suppose $X_{-1}$ has cases as rows, and you left out row 1.)

*Using half the variables (columns), fit a regression model to predict $X_{1}$ from $R$. You'll obtain $L_1$ such that $L_1R \approx X_{1}$.

*Measure the predictive accuracy of the regression model using the other half of the variables.


You should probably hold out more than 1 row at a time. 
I'll look for references if anybody's still looking at this page -- drop me a comment.
