# Independence test with some aggregation

I have a bunch of data consisting of pairs (i,j), with both i and j drawn from the same set S of size k. I would like to do an independence test similar to a chi-square test.

However, I don't care very much about full independence. I'm really only interested in seeing if pairs of the form (i,i) show up more (or less) often than pairs of the form (i,j) with j not equal to i. So, it seems to make sense to aggregate the data, and to look at a 2 by k table with rows given by the first entry in a pair, and columns given by whether or not the second entry equals the first entry.

Can one do something like a chi-square test in this way? What might it look like/might I find references?

EDITED in response to whuber: Thanks for replying. I'm not sure I fully understand the question, but here goes. For me, the elements of S represent different groups (e.g. each element of S is a bank or government agency). If not a 2 by k table, what size would seem reasonable? I don't know what the labels would be for, say, a 2 by 2 table. I can guess rows for a 1 by 2 table, but then I can't imagine what the test would be - there's been too much aggregation. The 2 by k was there just because a) it seems clear that it contains all the data I'm interested in, and b) it contains substantially fewer entries than the full k by k table.

EDITED in response to gui11aume: Thanks for the help! The different elements of S represent e.g. different banks. A pair (i,j) might represent a certain type of trade involving bank i and bank j. In principle, it seems reasonable to just ask if a bank is more likely to deal with another part of itself, and so aggregate all of the data into the two blocks (both entries the same) and (entries are different). In practice, I'm a little worried about this, primarily due to scale issues. Some groups are involved in many orders of magnitudes more stuff than other groups. Normal contingency table tests seem to deal with this well, giving a separate normalization to each group. I don't know how to Aggregate into two blocks without making all but the largest groups effectively invisible. Of course, I'm not exactly an expert!

• In proposing a $2$ by $k$ table you suggest there is some importance to assessing different values of $i$ and $j$. However, your statement of the question does not imply any need for that. This makes me suspect there's more going on here than your abstract description would suggest and that the details may be important. Could you share with us more information about how these data are obtained and what the values of $i$ and $j$ might mean?
– whuber
Jul 23, 2012 at 16:52
• Welcome here visiting_student. I think @whuber meant that you should have only 2 counts if the values of $i$ and $j$ do not matter: the number of $(i,i)$ pairs and the number of $(i,j)$ pairs. In that sense it would be useful to know what your data is. What is the unit of $i$ and $j$, what do they represent? Jul 23, 2012 at 21:30