This is a bit of an elaboration on a [question I posted earlier](http://stats.stackexchange.com/questions/55778/equivalent-to-k-s-test-on-discrete-data-with-uneven-quantization), since I feel like my approach to the problem as a whole is probably quite flawed. Suppose I have a set of treatment and control cells, each with a position in space and some response value. I would like to know whether the treatment cells are significantly more similar in their responses than controls. However, the analysis is complicated by the fact that: - Across all cells there is some tendency for the responses of pairs of nearby cells to be more similar - My treatment cells are also significantly clustered in space So far, I have tried to find an upper bound on the probability of the null hypothesis using a bootstrap test: 1. For each possible pair of treatment cells, find a group of matched control pairs whose spatial distance is less than or equal to that of the treatment pair. The number of pairs that satisfy this criterion will vary depending on which treatment pair I'm considering. 2. Find the rank of each treatment pair within its distribution of matched control pairs and normalize it to between 0 and 1 3. Take the mean of the normalized ranks across groups as my 'real' score. 4. Bootstrap a null distribution by drawing randomly from each set of possible normalized ranks and taking the mean. 5. The normalized rank of the 'real' score within this null distribution gives me my p-value. Since I only consider control pairs whose distance is <= that of the treatment pair, this ought to be a very conservative test. However, if I were to consider control pairs whose distance is the same as the treatment pair to within +/- some tolerance, I will end up choosing control pairs that are, on average, more distant than the treatment pair (because the treatment pairs are spatially clustered there will tend to be a greater number of control pairs that are more distant than the treatment pair). Is there a better way of doing this analysis? I'm sure I must be missing something very obvious!