Dear R user,
                      I want to do sparse principal component analysis
(spca). I am using elastic net package for this and spca() and the code is
following from the example.

My question is How can I decide the *K =? *and *para=c(7,4,4,1,1,1)) . So,
here k=6 i.e the no of Principal Components. and each pcs say , *
**
pc1 number of non zero loading is 7

pc2 number of non zero loading is 4

pc3 number of non zero loading is 4

pc4 number of non zero loading is 1

pc5 number of non zero loading is 1

pc6 number of non zero loading is 1

*How can I know in which pc,s how many non zero loadings will be? Any
code??? One answer can be cross validation but I did not find in the
package. *
**
*Thanks for your help*

*Code:*

library(elasticnet)
> out2<-spca(pitprops,*K=6*,type="Gram",sparse="varnum",trace=TRUE,*
para=c(7,4,4,1,1,1))
*iterations 10
iterations 20
iterations 30
iterations 40
> out2
Call:
spca(x = pitprops, K = 6, para = c(7, 4, 4, 1, 1, 1), type = "Gram",
    sparse = "varnum", trace = TRUE)
6 sparse PCs
Pct. of exp. var. : 28.2 13.9 13.1  7.4  6.8  6.3
Num. of non-zero loadings :  7 4 4 1 1 1
Sparse loadings
           PC1    PC2    PC3 PC4 PC5 PC6
topdiam -0.477  0.003  0.000   0   0   0
length  -0.469  0.000  0.000   0   0   0
moist    0.000  0.785  0.000   0   0   0
testsg   0.000  0.619  0.000   0   0   0
ovensg   0.180  0.000  0.656   0   0   0
ringtop  0.000  0.000  0.589   0   0   0
ringbut -0.290  0.000  0.470   0   0   0
bowmax  -0.343 -0.029 -0.048   0   0   0
bowdist -0.414  0.000  0.000   0   0   0
whorls  -0.383  0.000  0.000   0   0   0
clear    0.000  0.000  0.000  -1   0   0
knots    0.000  0.000  0.000   0  -1   0
diaknot  0.000  0.000  0.000   0   0   1
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to