Learn R Programming

Anthropometry (version 1.1)

trimmedoid: Trimmed k-medoids algorithm

Description

This is the trimmed k-medoids algorithm. It is used within trimowa. It is analogous to k-medoids but a proportion alpha of observations is discarded by the own procedure (the trimmed observations are self-determined by the data). Furthermore, the trimmed k-medoids is analogous to trimmed k-means. An algorithm for computing trimmed k-means can be found in Garcia-Escudero et al. (2003). See Ibanez et al. (2012) for more details.

Usage

trimmedoid(D,K,alpha,niter,Ksteps)

Arguments

D
Dissimilarity matrix.
K
Number of clusters.
alpha
Proportion of trimmed sample.
niter
Number of random initializations.
Ksteps
Steps per initialization.

Value

  • A list with the following elements:

    vopt: The objective value.

    copt: The trimmed medoids.

    asig: The assignation of each observation (asig=0 indicates trimmed individuals).

    ch: The goodness index.

    Dmod: Modified data with the non-trimmed women.

    qq: Vector with the non-trimmed points.

References

Ibanez, M. V., Vinue, G., Alemany, S., Simo, A., Epifanio, I., Domingo, J., and Ayala, G., (2012). Apparel sizing using trimmed PAM and OWA operators, Expert Systems with Applications 39, 10512--10520.

Garcia-Escudero, L. A., Gordaliza, A., and Matran, C., (2003). Trimming tools in exploratory data analysis, Journal of Computational and Graphical Statistics 12(2), 434--449.

Garcia-Escudero, L. A., and Gordaliza, A., (1999). Robustness properties of k-means and trimmed k-means, Journal of the American Statistical Association 94(447), 956--969.

See Also

dataDemo, WeightsMixtureUB, GetDistMatrix, trimowa, trimmedLloydShapes

Examples

Run this code
#Loading the data:
#Example for the first bust class:
data = dataDemo[(dataDemo$bust >= 74) & (dataDemo$bust < 78), ]   
num.variables <- dim(data)[2]

#Weights calculation:
orness <- 0.7
w <- WeightsMixtureUB(orness,num.variables)

#Constants required to specify the distance function:
K <- 3
bh <- (apply(as.matrix(log(data)), 2, range)[2,] 
       - apply(as.matrix(log(data)), 2, range)[1,]) / ((K-1) * 8) 
bl <- -3 * bh
ah <- c(28,20,30,25,23)
al <- 3 * ah

#Data processing.
num.persons <- dim(data)[1]
num.variables <- dim(data)[2]
datam <- as.matrix(data)
datat <- aperm(datam, c(2,1))                     
dim(datat) <- c(1,num.persons*num.variables)   
rm(datam)

#Dissimilarity matrix:
D <- GetDistMatrix(datat,num.persons,num.variables,w,bl,bh,al,ah,T)
rm(datat)

trimmedoid(D,K,0.01,6,7)

Run the code above in your browser using DataLab