## How to compare two similarity matrices?

Hi,

Suppose that I have two nxn similarity matrices. These matrices contain similarity information between n items. Although both matrices contain similarities of the same n items they do not contain the same similarity values. This might be because the similarities between the items are calculated using different information.

I want to know how similar these matrices are. One simple thing is to find the frobenius distance between the two matrices. But this might be misleading I think.

Are there better ways? What I want to understand whether the structure contained in the two similarity matrices are similar or not.

Let me clarify what I mean by a similarity matrix. Suppose that we have n items. And suppose that each item i is represented with a vector of numbers. Then each element of the similarity matrix $S(i,j) = cosine(v_i, v_j)$ where $v_i$ and $v_j$ are the $ith$ and $jth$ item vectors and $cosine(v_i, v_j)$ is the cosine of the angle between $v_i$ and $v_j$. (Distance metrics other then cosine may also be used)

May be I should have used distance matrix instead of similarity matrix.

Thanks Ahmet

-
What definition of similarity matrix are you (and Steve H) using? – Tom Leinster Mar 12 2012 at 17:43
@Tom: I realize that I conflated similarity and dissimilarity matrices. The latter is generally regarded as a metric. I'm not sure if there is a generally used transformation from one to the other, but taking inverses and setting the diagonal as a special case should do the trick. – Steve Huntsman Mar 12 2012 at 17:51
Thanks, Steve, but I'm still not up to speed. What's the definition of dissimilarity matrix? I ask because I'm familiar with these terms being used in the literature on quantification of biodiversity, but they're not used very precisely there, and I guess the same terms are also used differently by other people in other contexts. In particular, your answer made me think you were using some definition of (dis)similarity matrix that had a kind of triangle inequality built in. – Tom Leinster Mar 12 2012 at 17:56
This is a modelling problem. We cannot say anything unless the original poster clarifies what he/she means. Some questions that might help: Why is Frobenius distance not ok? Can you give an example in which it over/underestimates the quantity that you need? How are your matrices normalized/constructed? – Federico Poloni Mar 12 2012 at 18:32
Let me clarify what I mean by a similarity matrix. Suppose that we have n items. And suppose that each item i is represented with a vector of numbers. Then each element of the similarity matrix S(i,j) = cosine(v_i, v_j). Where v_i and v_j are the ith and jth item vectors. Cosine is the cosine similarity metric (other metrics can also be used). – Ahmet Mar 12 2012 at 19:00

As far as you use the cosine as similarity measure, the matrix is a correlation matrix. For this situation in statistics there is the concept of "canonical correlation", and this might be then the most appropriate for your case: it gives an index how much "variance of one set of variables is explained by the other". The two set of variables are the two sets of vectors $\small v_i$ here.

Another option could be to compute the cholesky factors ("factor loadings matrices") L1 and L2 of each of the correlation matrices R1 and R2 and do a target-rotation of L1 to L2. Then, for instance, the squared distances of the vector-tips of each related vector in rotated(L1) and L2 could be summed and this could be understood as similarity measure of the matrices(!) - but this is no standard method as far as I know...

-

EDIT: I naively thought similarity matrix == dissimilarity matrix, this isn't the case. It's been too long since I did bioinformatics. My answer below should properly say "dissimilarity matrix satisfying the triangle inequality". Such a matrix can be constructed along the lines in the comments above.

A similarity matrix is just a metric on a finite space. The standard metric on the space of all finite metric spaces is the Gromov-Hausdorff metric.

-