R/pamward.R

Defines functions pamward

Documented in pamward

## runs a pam from the solution in k groups of a hierarchical clustering
## author: Gilbert Ritschard

pamward <- function(diss, k=3, method="ward", dist) {

  TraMineR.check.depr.args(alist(diss = dist))

  if (!inherits(diss, "dist")) {
    if (!isSymmetric(diss)) stop("diss should be a dist object or a symmetric matrix")
    diss <- as.dist(diss)
  }
  clustw <- agnes(diss, diss=T, method=method)
  clw <- cutree(clustw, k=k)
  centers <- disscenter(diss, group=clw, medoids.index="first")
  return <- pam(diss, diss=T, k=k, medoids=centers)
}

Try the TraMineRextras package in your browser

Any scripts or data that you put into this service are public.

TraMineRextras documentation built on Sept. 11, 2024, 6:52 p.m.