kmeansW: K-means with Weights of the Elements

View source: R/kmeansW.R

kmeansWR Documentation

K-means with Weights of the Elements

Description

It is a modification of kmeans Hartigan-Wong algorithm to consider the weight of the elements to classify.

Usage

kmeansW(x, centers, weight = rep(1,nrow(x)),
        iter.max = 10, nstart = 1)

Arguments

x

A numeric vector, matrix or data frame.

centers

Either the number of clusters or a set of initial (distinct) cluster centres. If a number, a random set of (distinct) rows in x is chosen as the initial centres.

weight

weight of the elements of x. by default the same.

iter.max

The maximum number of iterations allowed.

nstart

If centers is a number, how many random sets should be chosen?

Details

With the 'Hartigan-Wong' algorithm, this function performs the K-means clustering diminishing inertia intra classes. In this version the Fortran code kmnsW.f was changed by C++ code kmeanw.cc programed by Camilo Jose Torres, modifing C code programed by Burkardt.

Value

object of class FactoClass.tex with the following characteristics:

cluster

vector indicating the cluster of each element.

...

Author(s)

Camilo Jose Torres cjtorresj@unal.edu.co, Campo Elias Pardo cepardot@unal.edu.co

References

Hartigan, J. A. and Wong, M. A. (1979). A K-means clustering algorithm. Applied Statistics 28, 100–108.

Burkardt, J. (2008). ASA136 The K-Means Algorithm. https://people.sc.fsu.edu/~jburkardt/cpp_src/asa136/asa136.html

Examples

 data(Bogota)
 ac.bog <- Bogota[-1]
 il.bog <- Bogota[ 1]
 
 acs <- dudi.coa( ac.bog, nf=6 , scannf = FALSE )
 
 kmeansW( acs$li, 7, acs$lw )
 

FactoClass documentation built on Sept. 14, 2023, 1:07 a.m.