Kendall rank correlation coefficient (tau-a)
Let be pairs of unique observations of two variables .
For ,
if and or and ,
then the pairs are said concordant.
Otherwise they are discordant.
If or they are neither concordant nor discordant.
In this case Kendall's rank coeeficient or correlation is defines as:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <stdio.h> using namespace std; #define N 4 int main() { int i, j; double x[N] = {10, 25, 30, 35}; double y[N] = {5, 10, 7, 15}; int C = 0, D = 0; int K = 0; double tau; for (i=0; i < (N-1); i++) { for (j=i+1; j < N; j++) { if ( (x[i] > x[j] && y[i] > y[j]) || (x[i] < x[j] && y[i] < y[j]) ) C++; if ( (x[i] > x[j] && y[i] < y[j]) || (x[i] < x[j] && y[i] > y[j]) ) D++; K++; printf ( "K=%d : i=%d j=%d C=%d D=%d\n" , K, i, j, C, D); } } tau = ( double ) (C-D) / (N*(N-1) / 2); printf ( "\nK=%d C=%d D=%d tau=%f\n" , K, C, D, tau); return 0; } |
Συνδεθείτε για περισσότερες δυνατότητες αλληλεπίδρασης,
σχολιασμοί, εξωτερικοί σύνδεσμοι, βοήθεια, ψηφοφορίες, αρχεία, κτλ.
σχολιασμοί, εξωτερικοί σύνδεσμοι, βοήθεια, ψηφοφορίες, αρχεία, κτλ.
Εκπαιδευτικό υλικό από τον
Αθανάσιο Σταυρακούδη
σας παρέχετε κάτω από την άδεια
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.
Σας παρακαλώ να ενημερωθείτε για κάποιους επιπλέον περιορισμούς
http://stavrakoudis.econ.uoi.gr/stavrakoudis/?iid=401.