Perform K-means (or its close kin) clustering with only a distance matrix, not points-by-features data I want to perform K-means clustering on objects I have, but the objects aren't described as points in space, i.e. by objects x features dataset.  However, I am able to compute the distance between any two objects (it is based on a similarity function). So, I dispose of the distance matrix objects x objects.
I've implemented K-means before, but that was with points dataset input; and with distance matrix input it's not clear to me how to update the clusters to be the cluster "centers" without a point-representation.  How would this normally be done? Are there versions of K-means or methods close to it, for that?
 A: I certainly don't know how it's "normally" done, and for the record, I don't know much about cluster analysis.  However, are you familiar with Multidimensional Scaling?  (Here's another reference, the wiki, and you could search CV under the multidimensional-scaling tag.)  Multidimensional scaling takes in a matrix of pairwise distances, which sounds like your situation.  From the MDS, you can get the locations of the objects in the lowest-dimensional space necessary to adequately represent them.  I would guess you could use those locations to do a subsequent cluster analysis like k-means; alternatively, once you had the output, you might no longer need the CA.  
I don't know if you use R, but here is the task view for Psychometrics, which includes a section on MDS in R.  Hope that helps.
A: Optimal Cluster Preserving Embedding of Nonmetric Proximity Data should fit your case. The paper shows how you can obtain a metric vector representation of your objects given only a matrix of pairwise dissimilarity function such that the cluster assignments will be preserved for a range of clustering algorithms, including $k$-means.
In your case, what you basically need to do is:


*

*Have your dissimilarity matrix $D$ with zero self-dissimilarity.

*In case it is not symmetric already, symmetrize by averaging $D_{ij}$ and $D_{ji}$.

*center it (i.e. subtract row and column mean) to obtain $D^c$

*Calculate $S^c = -\frac{1}{2}D^c$

*Perform a spectral shift: Subtract the $S^c$'s smallest eigenvalue from $S^c$'s spectrum to ensure it becomes positive-semidefinite. Do this to obtain $\tilde S^c$.

*Calculate the eigenvector decomposition of $\tilde S^c = V \Lambda V^\top$.

*Restore a vector representation in a $n-1$-dimensional metric space of your data: $X = V\Lambda^{1/2}$.


This assumes that $n$ is not too large. If it is, additionally doing PCAwill give you a more meaningful representation of the data. (The paper describes how to do this, too).
A: Obviously, k-means needs to be able to compute means.
However, there is a well-known variation of it known as k-medoids or PAM (Partitioning Around Medoids), where the medoid is the existing object most central to the cluster. K-medoids only needs the pairwise distances.
A: You are exactly describing the problem setting of kernel $k$-means; when you cannot represent a data point as a Euclidean vector, but if you can still calculate (or define) the inner product between two data points then you can kernelize the algorithm. The following webpage provides brief description of the algorithm:
Kernel $k$-means page
This kernel trick is a very popular and fundamental idea in Statistics and machine learning. 
Wiki page on the kernel trick
If you are interested, the book Learning with Kernels from by Bernhard Schölkopf and Alexander J. Smola will be a very nice introduction.
This note from Max Welling seems very nice; also, if you are using R you can take a look at this R package.
MDS might be a one way to solve your problem, but it does not directly attack the problem you want to solve; while kernel k-means does.
A: Your data can also be viewed as a network, and you can use one of the many network clustering algorithms available. For this you would probably need to apply a threshold on the edge weights, and transform distances to similarities. It is not the 'statistics' way of doing things, but cluster analysis is an underspecified problem to begin with, and as explorative tools network clustering algorithms perform very well.
A: I don't know why it is so uncommon in literature, however the solution suggested by @gung and @ttnphns (first projecting your pairwise distances into a Euclidean space using Principal Coordinates Analysis, for example through this package if you use R, and then doing K-means usual way) is simple and doesn't require specialized algorithms. I personally used it here embedded in an optimization framework and it worked fairly well.
A: @gung is absolutely correct suggesting you multidimensional scaling (MDS) as a preliminary tool to create points X dimensions data out of distance matrix. I'm to add just few strokes. K-means clustering implies euclidean distances. MDS will give you points-in-dimensions coordinates thereby guaranteeing you euclidean distances. You should use metric MDS and request number of dimensions as large as possible, because your aim is to minimize error of reconstracting the data, not to map it in 2D or 3D.
What if you don't have MDS software at hand but have some matrix functions such as eigenvalue decomposition or singular-value decomposition? Then you could do simple metric MDS yourself - Torgerson MDS, also known as Principal Coordinates analysis (PCoA). It amounts to a bit "twisted" Principal Components analysis. I won't be describing it here, although it is quite simple. You can read about it in many places, e.g. here.
Finally, it is possible to program "K-means for distance matrix input" directly - without calling or writing functions doing PCoA or another metric MDS. We know, that (a) the sum of squared deviations from centroid is equal to the sum of pairwise squared Euclidean distances divided by the number of points; and (b) know how to compute distances between cluster centroids out of the distance matrix; (c) and we further know how Sums-of-squares are interrelated in K-means. All it together makes the writing of the algorithm you want a straightforward and not a complex undertaking. One should remember though that K-means is for Euclidean distances / euclidean space only. Use K-medoids or other methods for non-euclidean distances.
A similar question.
A: With regard to clustering and MDS I would suggest the following resources:


*

*Numerical Ecology (Pierre Legendre and Louis Legendre): http://www.sciencedirect.com/science/bookseries/01678892/20 or http://tinyurl.com/cgrdfqk (google books)
-- chapter on 'Ecological resemblance'

*Cluster Analysis (Brian S. Everitt, Sabine Landau, Morven Leese, Daniel Stahl): http://tinyurl.com/bld7k8h (google books)
-- chapter on 'Measurement of proximity'

*Course 'Biostatistics-II, Multivariate Methods' by Prof. Brian C. McCarthy at Ohio University: http://www.ohio.edu/plantbio/staff/mccarthy/multivariate/multivariate.htm
These references also nicely cover the topics of similarity and distance functions (proximity measures) for binary and continuous data.
