FGSPCA: Feature Grouping and Sparse PCA with L2 loss function.

Description Usage Arguments Details Value Examples

View source: R/FGSPCAUtils.R

Description

Feature Grouping and Sparse PCA with L2 loss function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
FGSPCA(
  x,
  B_init,
  K,
  para,
  type = "predictor",
  use.corr = FALSE,
  max.iter = 200,
  trace = TRUE,
  eps.conv = 0.001,
  tau_S = 0.05,
  lambda2 = 0.1,
  lambda3 = 0.1,
  v = 1,
  c = 1.02,
  iter_m_max = 100,
  iter_k_max = 50,
  condition_tol = 1e-05,
  nnConstraint = FALSE,
  sparseTruncated = TRUE
)

Arguments

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 K

type

type of X, which can take values of type=c("predictor", "Gram"). If type="Gram" the model should deal with the root matrix of X. If type="predictor" the model should directly deal with the matrix X.

use.corr

FALSE (default). When type="predictor" we need to scale the data, scale=use.corr .

max.iter

200 (default) the max iteration of the A-B updating procedure

trace

TRUE (default) whether to do the print or not (print the number of the current iteration and the error at the iteration)

eps.conv

1e-3 (default) the convergence criterion for the A-B updating procedure

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 v=1.0.

c

the acceleration constant to speed up the convergence procedure, default c=1.02.

iter_m_max

the maximum number of the outer iterations (i.e. the m-iteration), default iter_m_max=100

iter_k_max

the maximum number of the inner iterations (i.e. the k-iteration), default iter_k_max=50

condition_tol

the conditional tolerance of both the outer and inner iterations, default condition_tol=1e-5

nnConstraint

Boolean, indicating the non-negative constraint is true or false, default FALSE

sparseTruncated

Boolean, indicating whether to use the truncated L1 penalty or not for sparsity, default TRUE

Details

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.

Value

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 .

Examples

 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))

ipapercodes/FGSPCA documentation built on Dec. 20, 2021, 7:58 p.m.