This is a bit of an elaboration on a question I posted earlier, 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!

  • $\begingroup$ Is there a danger that an underlying spatial feature is a significant factor - beyond just the issue that close cells have similar scores? As the treatment cells are clustered in space, if they are unluckily in a zone that happens to impact on the response, it won't be possible to distinguish the effects. $\endgroup$ Apr 13, 2013 at 2:15
  • $\begingroup$ I though about this - fortunately I don't think it's a particularly likely scenario in my case. $\endgroup$
    – ali_m
    Apr 13, 2013 at 19:02

1 Answer 1


According to this paper, OLS is consistent in the presence of spatial autocorrelation, but standard errors are incorrect and need to be adjusted. Solomon Hsiang provides stata and matlab code for doing so. Unfortunately I'm not familiar with any R code for this.

There are certainly other approaches to this sort of problem in spatial statistics that explicitly model spatial processes. This one just inflates the standard errors.

  • $\begingroup$ Thanks for response, although I must admit that I found the references rather heavy going as a non-statistician. My (vague!) understanding is that what you're suggesting would require me to form a linear regression model relating differences in treatment and spatial distance to differences in response. I'd prefer to avoid forming explicit linear models if possible, since it's very likely that the relationship between distance and response similarity is roughly linear only over a restricted range of distances. Can you think of a way to test this hypothesis without resorting to linear models? $\endgroup$
    – ali_m
    Apr 18, 2013 at 1:18
  • $\begingroup$ Theoretical econometricians unfortunately seem to take pleasure in obfuscating. Basically what it says is run whatever regression you want, and then go fix the standard errors later (i.e.: using Sol's code). You say you don't want to specify a linear model. Why not specify a really simple one? Y= a + bT + e? where T is your treatment? This is the same thing as a T test, with the added feature that you could tack stuff onto it if you change your mind. $\endgroup$ Apr 18, 2013 at 3:17
  • $\begingroup$ Space doesn't come into it until you try to estimate the variance of your estimator. Intuitively, if all the difference is close together, you're less certain that your estimate isn't just a relic of some unobserved spatial shock. $\endgroup$ Apr 18, 2013 at 3:18
  • 1
    $\begingroup$ But based on Sol's code I would still have to select a spatial kernel with some specified cutoff or bandwidth. When I choose the bandwidth of the kernel I'm making an implicit assumption about the spatial scale over which I expect my response values to be correlated. $\endgroup$
    – ali_m
    Apr 18, 2013 at 14:58
  • $\begingroup$ That is true. I forget whether Sol implements a gaussian or uniform or what kind of kernel. Are you truly in a situation where you are completely uninformed about what sorts of unobserved spatial shocks are possible and what scales they might operate over? Could you specify several different bandwidths, and maybe plot the standard errors as a function of bandwidth to see how your result is sensitive to the choice, then perhaps use the most conservative bandwidth that is logically consistent with what the data generating process might be? $\endgroup$ Apr 18, 2013 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.