optimal.k: optimalK

Description Usage Arguments Note Author(s) References See Also Examples

View source: R/optimal.k.R

Description

Find optimal k of k-Medoid partitions using silhouette widths

Usage

1
optimal.k(x, nk = 10, plot = TRUE, cluster = TRUE, clara = FALSE, ...)

Arguments

x

Numeric dataframe, matrix or vector

nk

Number of clusters to test (2:nk)

plot

Plot cluster silhouettes(TRUE/FALSE)

cluster

Create cluster object with optimal k

clara

Use clara model for large data

...

Additional arguments passed to clara

Note

Depends: cluster

Author(s)

Jeffrey S. Evans <jeffrey_evans<at>tnc.org>

References

Theodoridis, S. & K. Koutroumbas(2006) Pattern Recognition 3rd ed.

See Also

pam for details on Partitioning Around Medoids (PAM)

clara for details on Clustering Large Applications (clara)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
require(cluster)
  x <- rbind(cbind(rnorm(10,0,0.5), rnorm(10,0,0.5)),
             cbind(rnorm(15,5,0.5), rnorm(15,5,0.5)))

  clust <- optimal.k(x, 20, plot=TRUE, cluster=TRUE)
    plot(silhouette(clust), col = c('red', 'green'))
      plot(clust, which.plots=1, main='K-Medoid fit')

# Extract multivariate and univariate mediods (class centres)
  clust$medoids
    pam(x[,1], 1)$medoids  

# join clusters to data
  x <- data.frame(x, k=clust$clustering) 

jeffreyevans/spatialEco documentation built on Nov. 10, 2018, 4:13 a.m.