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:


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

  • $\begingroup$ 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. $\endgroup$
    – ttnphns
    Commented Dec 26, 2014 at 11:01

1 Answer 1


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.

However, Rousset et al's distance is a very specific distance (see Studer & Ritschard, 2014, p. 9) and you should not use it without having an idea of what you are measuring.

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.

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.