# 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 '12 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 '12 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 '12 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 '12 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 '12 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.