# qtranShapes: Auxiliary qtran subroutine of the Hartigan-Wong k-means for... In Anthropometry: Statistical Methods for Anthropometric Data

 qtranShapes R Documentation

## Auxiliary qtran subroutine of the Hartigan-Wong k-means for 3D shapes

### Description

The Hartigan-Wong version of the k-means algorithm uses two auxiliary algorithms: the optimal transfer stage (optra) and the quick transfer stage (qtran).

This function is the qtran subroutine adapted to the shape analysis context. It is used within `HartiganShapes`. See Hartigan and Wong (1979) for details of the original k-means algorithm and Amaral et al. (2010) for details about its adaptation to shape analysis.

### Usage

```qtranShapes(array3D,n,c,ic1,ic2,nc,an1,an2,ncp,d,itran,indx)
```

### Arguments

 `array3D` Array with the 3D landmarks of the sample objects. `n` Number of sample objects. `c` Array of centroids. `ic1` The cluster to each object belongs. `ic2` This vector is used to remember the cluster which each object is most likely to be transferred to at each step. `nc` Number of objects in each cluster. `an1` \$an1(l) = nc(l) / (nc(l) - 1), l=1,...,numClust\$, where numClust is the number of clusters. `an2` \$an2(l) = nc(l) / (nc(l) + 1), l=1,...,numClust\$. `ncp` In the optimal transfer stage, ncp(l) stores the step at which cluster l is last updated, \$l=1,...,numClust\$. In the quick transfer stage, ncp(l) stores the step at which cluster l is last updated plus n, \$l=1,...,numClust\$. `d` Vector of distances from each object to every centroid. `itran` itran(l) = 1 if cluster l is updated in the quick-transfer stage (0 otherwise), \$l=1,...,k\$. `indx` Number of steps since a transfer took place.

### Value

A list with the following elements:: c,ic1,ic2,nc,an1,an2,ncp,d,itran,indx,icoun, updated after the optimal transfer stage. Note that icoun counts the steps where a re-allocation took place.

### Note

This function belongs to `HartiganShapes` and it is not solely used. That is why there is no section of examples in this help page.

### Note

This function is based on the qtran.m file available from https://github.com/johannesgerer/jburkardt-m/tree/master/asa136.

Guillermo Vinue

### References

Vinue, G., Simo, A., and Alemany, S., (2016). The k-means algorithm for 3D shapes with an application to apparel design, Advances in Data Analysis and Classification 10(1), 103–132.

Hartigan, J. A., and Wong, M. A., (1979). A K-Means Clustering Algorithm, Applied Statistics, 100–108.

Amaral, G. J. A., Dore, L. H., Lessa, R. P., and Stosic, B., (2010). k-Means Algorithm in Statistical Shape Analysis, Communications in Statistics - Simulation and Computation 39(5), 1016–1026.

Dryden, I. L., and Mardia, K. V., (1998). Statistical Shape Analysis, Wiley, Chichester.

`HartiganShapes`