# 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 '12 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? –  gui11aume Jul 23 '12 at 21:30
add comment

## 1 Answer

The test you seem to be referring to is Pearson's chi-square test of independence. There are more general versions of this test for categorical data which permit you to more precisely specify the relationships that you want to test. Some references are:

Goodman, Leo (1987), "New Methods for Analyzing the Intrinsic Character of Qualitative Variables using Cross-Classified Data," American Journal of Sociology, 93 (3), 529-83.

Goodman, Leo A. (1991), "Measures, Models, and Graphical Displays in the Analysis of Cross-Classified Data," Journal of the American Statistical Association, 86 (416), 1085-111.

If you cannot get access to the papers, a way you can compute what you want is to: (1) aggregate cells in the table and as you want to given your theory and compute revised expected values based on these aggregations; (2) compute the chi-square statistic in the normal way you do with a chi-square test of independence; (3) when computing the p-value, modify the degrees of freedom to reflect your model. Step 3 is a bit difficult to explain without a lot more detail about your model (it is not the type of thing that can be explained readily in a forum like this). However, a good place to get a general idea is to look at the case study by Goodman on car challenge

-
Thanks for the comment! I don't have access to either of those journals, unfortunately, though maybe I can bother somebody for copies. Do they have some way of doing Chi-Square-like tests, even when you aggregate many of the indices? I was aware of Pearson's test, but the versions I've seen don't allow for so much modification. Thanks again! –  visiting_student Jul 25 '12 at 13:26
I have added a paragraph to my answer to address your question. –  Tim Jul 25 '12 at 23:01
add comment