Description Usage Arguments Details Value Examples
Feature Grouping and Sparse PCA with L2 loss function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
x |
the data matrix X |
B_init |
the initial value of matrix B |
K |
the number of principal components |
para |
a list of λ_1 with its length being |
type |
type of X, which can take values of |
use.corr |
|
max.iter |
|
trace |
|
eps.conv |
1e-3 (default) the convergence criterion for the |
tau_S |
τ, a global τ, which is assigned to τ_1=τ_2=τ . |
lambda2 |
λ_2, the tuning parameter corresponding to p_2(\cdot) |
lambda3 |
λ_3, the tuning parameter corresponding to p_3(\cdot) |
v |
the initial value of the Lagrange multiplier, with default |
c |
the acceleration constant to speed up the convergence procedure, default |
iter_m_max |
the maximum number of the outer iterations (i.e. the m-iteration), default |
iter_k_max |
the maximum number of the inner iterations (i.e. the k-iteration), default |
condition_tol |
the conditional tolerance of both the outer and inner iterations, default |
nnConstraint |
Boolean, indicating the non-negative constraint is true or false, default |
sparseTruncated |
Boolean, indicating whether to use the truncated L1 penalty or not for sparsity,
default |
The main function of the FGSPCA problem with L2 loss using the alternating updating, which updates A while fixing B and updates B while fixing A.
pev Percentage of Explained Variance
var.all the total variance
loadings the final normalized loadings of B
Alpha the final eqnA from the last update
ab_errors the A-B
updating errors
type (same as the input) the type of matrix X
K (same as the input) the number of principal components
para (same as the input) a list of λ_1 with its length being K
lambda2 (same as the input) λ_2
lambda3 (same as the input) λ_3
vn variable names
Mloss a matrix of loss with shape of i\times K, where i is the number of iterations.
Gloss global loss
Sloss sum loss
Tloss tail loss
LossList with each element being a list of the objective values of each subproblem. K*(i-1) + j .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | library(elasticnet) # to use the data "pitprop"
library(sparsepca)
data(pitprops)
# ## elasticnet::spca is the Sparse PCA of Zou (2006).
K <- 6
para <- c(0.06, 0.16, 0.1, 0.5, 0.5, 0.5)
out1 <- elasticnet::spca(
pitprops, K=6, type="Gram", sparse="penalty", trace=TRUE,
para=c(0.06,0.16,0.1,0.5,0.5,0.5))
K <- k <- 6
X <- rootmatrix(pitprops)
rspca.results <- sparsepca::rspca(X, k, alpha=1e-3, beta=1e-3, center=TRUE, scale=FALSE)
K <- 6
B_init <- rspca.results$loadings
tau_S=0.05; lambda1=0.01; lambda2=0.01; lambda3=0.1
para <- rep(lambda1, K)
out <- FGSPCA(
pitprops, B_init, K, para, type="Gram",
tau_S=tau_S, lambda2=lambda2, lambda3=lambda3)
NB <- out$loadings # the normalized loadings of FGSPCA
(fgspca.pev <- round(out$pev *100, 3))
(fgspca.cpev <- round(cumsum(out$pev) * 100, 3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.