Learn R Programming

cvxclustr (version 1.1.1)

cvxclust_ama: Convex clustering via AMA

Description

cvxclust_ama performs convex clustering via AMA. 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_ama(X, Lambda, ix, M1, M2, s1, s2, w, gamma, nu, type = 2, max_iter = 100, tol = 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
The initial step size parameter when backtracking is applied. Otherwise it is a fixed step size in which case there are no guarantees of convergence if it exceeds 2/ncol(X).
type
An integer indicating the norm used: 1 = 1-norm, 2 = 2-norm.
max_iter
The maximum number of iterations.
tol
The convergence tolerance.
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 objective evaluated at the final iterate.dual The dual objective evaluated at the final iterate.iter The number of iterations taken.

Examples

Run this code
## Create random problem
seed <- 12345
p <- 10
n <- 20
rnd_problem <- create_clustering_problem(p,n,seed)
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 <- nrow(ix)
Lambda <- matrix(rnorm(p*nK),p,nK)
gamma <- 0.1
nu <- 1.999/n
max_iter <- 1e6
tol <- 1e-15
sol_ama <- cvxclust_ama(X,Lambda,ix,M1,M2,s1,s2,w,gamma,nu,max_iter=max_iter,tol=tol)

Run the code above in your browser using DataLab