How do I test whether similar subjects are more likely to pair up? I have a bunch of subjects. These subjects can pair up (in unordered pairs), and can do so repeatedly, even repeatedly to the same other subject. So I have a list of pairings and how many times each has occurred. (An example might be a bunch of people and how many times any two of them has shaken hands.)
Now, each such pairing can be between 'like' subjects or between 'unlike' subjects. (There's a definition I use for 'like'; it's an equivalence, if that matters.) (In the example, you might consider handshakes between people of precisely the same surname or of not precisely the same surname.)
I wish to test whether a pairing of 'like' subjects is more likely than a pairing of 'unlike' subjects. How can I do this? Please bear in mind that I need to take into account that some of the subjects are less likely to pair altogether. (In the example, I'd want to know whether people of the same surname are more likely to shake hands. But I'd need to bear in mind that some people just shake hands more in general.)
I'll indicate what I've tried, but I don't know whether it's correct. I welcome confirmation that it's correct, explanation of why it's not, recommendation for fixing it, and/or wholly different methods. I did as follows: For each subject, find how many pairings it's in; call that its score. For any two subjects, find the product of their scores; call that the pair's score. Then, for the two subjects, find the actual number of pairings; divide that by the pair's score (which is to take into account the fact that some subjects are less likely to pair altogether). Consider this last number as the dependent variable and use ANOVA with 'like' and 'unlike' as my groups.
(Another idea I had was to use the pair's score (as above) as a factor in an ANCOVA (with, of course, 'like' and 'unlike' as the other factor, and the actual number of pair's pairings as the dependent variable). This seemed more intuitive, actually. But ANCOVA requires that the regression lines for the dependent variables against the continuous variables have equal slope for the different categorical variables, and in my case the slopes are 0.019 and 0.24.)
 A: Here is what I wound up doing. If I recall correctly (it's been a while), it was based on stuff I read in Statistical Analysis of Network Data by Eric D. Kolaczyk.
I created an undirected multigraph G, meaning its edges had no direction but any pair of vertices could have more than one edge. Its vertices were my subjects (the people in the example) and its edges were the pairings (the handshakes in the example). I found the number of edges between "like" vertices.
I then created a list of G's vertex degrees, and gave a name to each vertex. I added each of these vertices to a new graph H. I chose an arbitrary vertex u from that list (whose number on the list was positive), and then chose another vertex v randomly weighted by the number on the list. I subtracted 1 from the numbers on the list for u and v and added an edge to H for u and v. I repeated until all the vertices were exhausted. (If it turned out that one vertex was left, I rejected H and started over.)
I repeated this until I had 1000 different random. I then found, for each of those, how many edges were between "like" vertices.
