Learn R Programming

cvxclustr (version 1.1.1)

cvxclust_admm: Convex clustering via ADMM

Description

cvxclust_admm performs convex clustering via ADMM. This is an R wrapper function around C code. Dimensions of various arguments are as follows:
  • n is the number of data points
  • p is the number of features
  • k is the number non-zero weights.

Note that the indices matrices 'M1', 'M2', and 'ix' take on values starting at 0 to match the indexing conventions of C.

Usage

cvxclust_admm(X, Lambda, ix, M1, M2, s1, s2, w, gamma, nu, max_iter = 100, type = 2, tol_abs = 1e-05, tol_rel = 1e-04, accelerate = TRUE)

Arguments

X
The p-by-n data matrix whose columns are to be clustered.
Lambda
The p-by-k matrix of Lagrange multipliers.
ix
The k-by-2 matrix of index pairs.
M1
Index set used to track nonzero weights.
M2
Index set used to track nonzero weights.
s1
Index set used to track nonzero weights.
s2
Index set used to track nonzero weights.
w
A vector of k positive weights.
gamma
The regularization parameter controlling the amount of shrinkage.
nu
Augmented Lagrangian penalty parameter
max_iter
The maximum number of iterations.
type
An integer indicating the norm used: 1 = 1-norm, 2 = 2-norm.
tol_abs
The convergence tolerance (absolute).
tol_rel
The convergence tolerance (relative).
accelerate
If TRUE (the default), acceleration is turned on.

Value

U A list of centroid matrices.V A list of centroid difference matrices.Lambda A list of Lagrange multiplier matrices.nu The final step size used.primal The primal residuals.dual The dual residuals.tol_primal The primal residual tolerances.tol_dual The dual residual tolerances.iter The number of iterations taken.

Examples

Run this code
## Create random problems
p <- 10
n <- 20
seed <- 12345
nProbs <- 10
errors <- double(nProbs)
for (i in 1:nProbs) {
  seed <- seed + sample(1:1e2,1)
  rnd_problem <- create_clustering_problem(p,n,seed=seed,method='admm')
  X <- rnd_problem$X
  ix <- rnd_problem$ix
  M1 <- rnd_problem$M1
  M2 <- rnd_problem$M2
  s1 <- rnd_problem$s1
  s2 <- rnd_problem$s2
  w  <- rnd_problem$w
  nK <- length(w)
  Lambda <- matrix(rnorm(p*nK),p,nK)
  gamma <- 0.1
  nu <- 1
  max_iter <- 1e6
  tol_abs <- 1e-15
  tol_rel <- 1e-15
  sol_admm_acc <- cvxclust_admm(X,Lambda,ix,M1,M2,s1,s2,w,gamma,nu,max_iter=max_iter,
    tol_abs=tol_abs,tol_rel=tol_rel,accelerate=TRUE)
  sol_admm <- cvxclust_admm(X,Lambda,ix,M1,M2,s1,s2,w,gamma,nu,max_iter=max_iter,
    tol_abs=tol_abs,tol_rel=tol_rel,accelerate=FALSE)
  errors[i] <- norm(as.matrix(sol_admm_acc$U-sol_admm$U),'i')
}

Run the code above in your browser using DataLab