Feb 9, 2013: These codes have been updated for igraph v0.6 in R 2.15.
This page is somewhat related to the 'edgelists with associated edge values' page:
Here, I will address how we go from the type of data I often deal with--a list of outcomes of interactions, whereby the same combination of individuals might interact multiple times over time. The data format look like something like a typical edgelist, except that each row represents a single interaction instead of a dyadic relation (which is the sum total of all observed interactions).
So the question is, how can we efficiently convert data on a set of interactions to a network of relations.
The full data is available below as 'interactions.csv'. This is actually an alternate format of the 'weighted edgelist' from the previous page.
For simplicity, this dataset does not contain any 'reversals'... but we'll deal with data with reversals a bit later.
This type of data can be converted easily to a network. Here's an example in igraph:
This should be the same as the same adjacency matrix we get in the 'edgelist with edge values' page, although the order of the vertices are different.
**HOWEVER, there is one problem with this network. Even though the adjacency matrix suggests that the edge weight information is included in this igraph object, there in fact is no edge weight here. This is clear if we just look at the summary information for g.
IGRAPH DN-- 7 50 --
attr: name (v/c)
This network does not have edge weights.
So, to make a network that actually incorporates edge weights, we have to go from the adjacency matrix (which, as shown above, has the weight values) and make a new igraph object:
IGRAPH DNW- 7 10 --
attr: name (v/c), weight (e/n)
Ok, so now we have what we want--a network that summarizes the cumulative interactions of all dyads.
So if we plot this figure:
This is identical to the previous page.
Ok, now let's deal with reversals.
First, we'll switch up the dataset a little bit to create some reversals. We'll just flip the winners & losers of 10 out of the 50 interactions.
Here, we see that, for example, #23871 beat #23778 11 times, but #23778 beat #23871 4 times.
Now, here is the crux of the problem--given that two individuals trade-off winning & losing, what is the relation between these two individuals? The simplest way is to say 'the individual that wins a majority of interaction is dominant'. This is clearly very simplistic, but it's probably the easiest and the possible alternatives are likely just as arbitrary...
... so, let's just go with 'majority wins'. Then, we need to convert this matrix of interactions into a matrix that actually represents dominance relations, based on cumulative interactions.
Here's one way to do that:
...as I wrote on the code annotations, you have to set up a guideline for yourself about what to do with 'non-interactions' and 'ties'. The other obvious flaw is that we lose all information about the proportion of times an individual won, etc... but these issues are beyond the scope of this little page.