[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Kendall's tau of two graph ranking list
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Kendall's tau of two graph ranking list |
Date: |
Thu, 3 Jul 2008 00:10:02 +0200 |
Hi,
I uses cov(x, y, method="kendall") . But it did not work.
Without any further detailed knowledge about R (I assume you are using
that), I think that in order to use cov() or cor(), you should provide
the rankings to cov(...). Example:
Let us assume that your vertices are called A, B, C and D.
Let your first ordering be A, B, D, C and the second one A, C, D, B.
Now, go according to your vertex names.
A is the first one and it is placed first in both ordering, therefore
the first element of your x and y vectors will be 1.
B is the second vertex and it is placed second in the first ordering
and fourth in the second ordering. Therefore, the next element of x
will be 2 and the next element of y will be 4.
Similarly, the elements corresponding to C in x and y will be 4 and 2,
respectively, since C is the 4th in the first ordering and 2 in the
second.
Finally, the elements corresponding to D in x and y will be 3 and 3.
Now, your x is:
> x <- c(1, 2, 4, 3)
> y <- c(1, 4, 2, 3)
The Kendall correlation is then:
> cor(x, y, method="kendall")
[1] 0
So, practically you'll have to transform your vectors before using
them with cor(). For instance, if the 4th element of your vector is 2,
then that means that the second vertex of the graph is ranked 4th, but
cor() requires a vector for which the indices of the elements
correspond to the vertex indices in the graph and the values of the
elements correspond to the ranks. What you are doing is the other way
round. Does it make sense?
--
Tamas