# What test is suitable to calculate the correlation between two matrices of spatially distributed variables?

I have two matrices which each represent the distribution of a different variable on the same spatial domain (something like the distribution of cows on a field on one day versus the distribution of horses on the same field on a different day), and I'd like to check whether these matrices are correlated. I've been searching for an appropriate test but am still not sure what to use, so any advice would be much appreciated.

Thanks a lot!

-
Precisely how do these matrices "represent a distribution"? Are they really raster-like images of points, or could they be something else? If the former, are they spatially registered or not? –  whuber Oct 10 '11 at 14:42
Each element of the matrices can have a certain value, which represents the amount of one of the variables - say, the intensity of one of the signals - at the point in the spatial domain. So the variables are distributed across the same spatial domain, which happens to be a square "field" (exactly translatable to a matrix). I'm very interested in how the two variables co-localise across the domain. Sorry for the confusion and thank you for your interest. –  MG1 Oct 10 '11 at 15:34
OK, that's much clearer. The generality of your explanation raises some other points for clarification: (1) are these "signals" measured completely at every point or do the matrices represent samples of the signals? (2) Is there a possibility of error in either the locations or intensities? (3) What is the nature of the measurement scale: indicators, categories, counts, some continuous variable? –  whuber Oct 10 '11 at 16:56
The signals are measured completely and there's (assumed to be) no possibility of error in either location or intensity (the signals are generated using a fairly complex mathematical procedure in which we are aware of a certain error margin, but which we do not address at this point). The signals are continuous variables. –  MG1 Oct 11 '11 at 13:54

If you discretize your field into a grid, count the number of observations in each grid cell (seperately for both spatial point patterns, cows and horses), and then treat each grid cell as a seperate observation you could calculate the correlation between the two spatial point patterns. (Sometimes this may be called "quadrat" counting, and all this is doing is calculating the correlation between the quadrats.)

That has some undesirable ad hoc steps though (how small of grid cells?), but is a useful exploratory tool. Likely a next analytical step would be to evaluate Ripley's K statistic between the two spatial point patterns. I asked a similar and relevant question on the GIS forum, How to compare two spatial point patterns?, and that has some references for the Ripley's K statistic (plus software and other references on sampling) from @whuber.

Given the update in the comment, Ripley's K is probably not appropriate (Ripley's K is calculated by examining the pair-wise distances of spatial points, you don't have spatial points though!) Still treating each "element" of your matrix as one observation you can calculate the correlations between the intensities the same as the quadrat counting I suggested above.

But, that isn't all that enlightening of whether there is spatial "co-localization" between the two variables. One potential way to identify if the variables have some type of spatial auto-correlation between the two processes is to estimate the bivariate Moran's I (Wikipedia has an intro as to what univariate Moran's I is and its calculation, and the Geoda workbook goes into more detail about bivariate Moran's I as well as more general spatial regression modeling). Another potential methodology you could use is to calculate the empirical variogram between the two processes.

The more specific details you give about the the data and how the two processes are related will likely allow for more focused feedback (but I suspect this would be a good start).

-
Thank you for all your time and effort! I will investigate those ideas. –  MG1 Oct 11 '11 at 13:55