Ranking Bonobo Dominance with David’s Scores
Introduction
So recently I ended up going down a node-ranking paper rabbit-hole and ended up in the weird and wonderful world of animal dominance hierarchies. Many dominance metrics are built around observed dyadic (pair-wise) interactions of animals. When two animals (bonobos, mice, etc.) meet, one animal will start chasing, and the other will start fleeing. To make this easy, lets call the animal chasing the “chaser”, and the animal fleeing the “runner”. The animals that chase more often will be more dominant, and animals that run more often will be less dominant.
The purpose of this post is to explore one of these obscure dyadic node ranking metrics in depth — David’s Scores. We’ll use David’s Scores to find the most chaser-y and the most runner-y bonobos, but it’s super applicable to other dyadic static ranking problems. If you need a ranking system that updates over time, something like Elo is probably a better fit.
I’ll include some code in this post, but the full notebook and raw edgelist are both available on my github.
Dataset
I’m using a bonobo interaction dataset taken from the EloRating package in R. The dataset contains data for “chasing” and “fleeing” bonobos [1]. We can rank bonobos by dominance using out-degree and in-degree. In this context, out-degree is the number of times a bonobo chased any other bonobo and unweighted out-degree is the number of unique bonobos chased. In-degree is the same thing, but for being chased. In the original dataset, the names of the bonobos were all two letter codes- you know how concerned bonobos are with privacy. So I’ve given them much cooler names to keep this post lit.
Lets meet our 7 contestents:
Right off the bat, there are a few clear stand-outs for the dominance awards. Reek has had a tough life — he’s been chased away 321 times by all 6 bonobos. Ouch. That said, he’s still chased more bonobos than both Kobra and King Bonobong in absolute terms. Ho ho ho is apparently to bonobos as Santa Clause is to elves. A lot of bonobos are afraid of his presents (sorry)! BUT he’s been chased 8 times. Is that more impressive than Helios’ 84 wins and 0 losses? And what do we make of Denise? She has impressive chasing numbers, but she’s only interacted with <= 5 other bonobos… does she have what it takes to win most dominant bonobo? Lets take a quick look at a graph where edges are the weighted logged interactions between bonobos.
How would you rank them?
How would you rank the above bonobos from most-to-least dominant? It’s actually harder than it sounds- think about ranking in terms of only in- or out-degree: is chasing Reek 100 times really worth more than chasing 9 other bonobos 10 times? Probably not (sorry Reek). This also introduces a proportion problem — are 100 wins and 10 losses worth more than 80 wins and no losses? Probably not! David’s Scores are a way of balancing edge weight and number of unique bonobos with whom i interacts.
David’s Scores, Mathematically
The algorithm itself is relatively simple- we’ll walk through it line by line in a moment, but first lets talk about the mathematical definition. David’s Scores look at the proportion of wins for individual i in its interactions with another individual j. (Pij) is the number of times that i defeats j (sij) divided by the total number of interactions with i and j (nij). The proportion of losses by i in its interactions with j (Pij) equals 1 — Pij. If nij = 0 then Pij = 0 and Pji = 0 [1]. The David’s score is thus calculated with the following formula:
DS = w1 + w2 — l1 — l2
Where w1 represents the sum of the rows of the proportion matrix, w2 represents the dot product of w1 and the proportion matrix, l1 represents the column sums of the proportion matrix, and l2 represents the dot product of l1 and the proportion matrix.
But like what are David’s Scores
Basically, David’s scores normalize Weighted, Directed adjacency matrices to deal with all of those issues that make ranking with in-degree and out-degree difficult. David Scores are calculated off of a weighted Proportion Matrix — this Matrix incorporates weights from our original matrix, but also looks at the proportion of wins to losses across all accounts.
This approach surfaces nodes with extreme deviations in what would be expected. If Denise chased 6 bonobos 10 times and was chased by the same 6 bonobos 10 times, she’d receive a score of 0. This makes sense, as she’d be neither neither dominant nor submissive. She’d just be an average player. David’s scores will be large and positive if bonobos that chase lots of other bonobos at high volumes without getting chased back. David’s scores will be large and negative if bonobos are chased by lots of other bonobos and rarely chase back.
If that’s still unclear, here’s code I wrote to calculate David’s Scores in Python from a directed, weighted NetworkX Graph. Lets go through it!
First, we extract the adjacency Matrix, transpose it, and add 1. The adding 1 is to prevent zero division when we calculate the proportion Matrix. We also create a symmetrized (sum) matrix by adding X with its transpose
adj = nx.adjacency_matrix(G)
# convert to a dense matrix
X = (adj.todense()) # add 1 to not divide by zero. symmetrize!
tmat = X.T+1
sym = X + tmat
Next we create our weighted, symmetrized proportion Matrix.
Dij = np.divide(tmat, sym) - (((np.divide(tmat, sym) - 0.5)/(sym+1)))
Finally, we can calculate the components of David's scores from our Dij proportion Matrix!
# get row and col sums of proportion matrix
w1 = np.sum(Dij, axis = 0)
l1 = np.sum(Dij, axis = 1) # get row and col sums weighted by the proportion matrix
l2 = l1.T * Dij
w2 = np.dot(w1, Dij)# Get David's Scores for each node
DS = w1 + w2 - l1.T - l2
Results
Lets see how our contestants ranked:
The most negative score, unsurprisingly, was Reek, followed closely by King Bonobong and Denise. Why do you think Denise is so low given that she chased 90 times? But plot twist — Ho ho ho was actually not the most dominant by this metric. Ho ho ho was chased too many times! Dzachoo and Helios were almost never chased back, and this gave them highly positive scores.
Thank you to the 7 bonobos for participating. Lets all hope that Reek finds the bonobo equivalent to Xanax.
References
[1] de Vries H, Stevens JMG, Vervaecke H (2006). “Measuring and testing the steepness of dominance hierarchies.” Animal Behaviour, 71, 585–592. doi: 10.1016/j.anbehav.2005.05.015.