# How to do centroid clustering of sequences?

I want to cluster sequences using centroids. In the hclust package it is noted that "Method "centroid" is typically meant to be used with squared Euclidean distances".

Further, it seems as if TraMineRextras allows for conversion of state sequence objects to euclidean distances using seqemlt(). However, these do not seem to be squared. So, to get hclust to work with centroids, do I simply square the output of seqemlt() like so:

euclidean.distances^2


...and then put this object through hclust()?

• It is true that centroid hierarchical method, in order to compute euclidean distance between centroids must operate on squared pairwise distances between the objects. I'm not R user but I suppose that you are right. Square the distances and input the matrix to hclust. Dec 26, 2014 at 11:01

The seqemlt function from the TraMineRextras package does not return a dissimilarity matrix, but a numerical representation (matrix coord) of the sequences such that the Euclidean distances between the numerical transformed representations (rows of coord) correspond to the distances between sequences proposed by Rousset, Giret & Grelet al. (2012). If you compute the Euclidean distances between the rows of coord with dist, the results are non squared distances.
There are alternative ways of getting Euclidean distances. Using any dissimilarity measure ---such as optimal matching for example---you get numerical representations of the sequences by means of multidimensional scaling (e.g., see the R cmdscale function). You can then simply use the Euclidean distances between those numerical representations, which you obtain for instance with dist.