# need derivation of join-count variance (spatial autocorrelation stat), know where it is?

I am using interlibrary loan to get Cliff and Ord's book Spatial Processes, but the semester just ended and it is slow now. On page 18ish of this book, Cliff and Ord show how the variance for the join-count statistic is calculated and also how this variance was derived. I have the variance equation, but need to see the derivation because I need to calculate variance of join-counts WHILE taking edge effects into account. So, I must modify the variance but can only do this if I understand the steps in its derivation very well (which is hard to do when looking at a reduced form equation). Time is of the essence, has anyone seen an online reference that shows this derivation and can point me to it? It might take quite a while to have this book in hand, given the situation. Also, buying a book like this for a few pages is a bit extravagant given the cost of books like this. Thanks. I doubt anyone can help, it is too odd a question likely.

## 1 Answer

The join-count statistic is a special case of a class that includes the Getis-Ord $G$, Moran, and Geary statistics [Haining, Spatial Data Analysis Theory and Practice (2003), p. 242]. They are united by a graph-theoretic abstraction in which spatial features are nodes, features $i$ and $j$ (with $i \ne j$) considered adjacent are joined by edges $e_{ij}$ having weights $\omega_{ij}$, and to each feature $i$ is assigned a definite attribute $z_i$. These statistics vary only in how they measure association of the attribute. The measure that defines the join-count statistic is the binary indicator of equality:

$$\gamma_{ij} = \gamma(z_i, z_j) = I(z_i, z_j) = \begin{array}{ll} \{ & \begin{array}{ll} 1 & z_i=z_j \\ 0 & z_i\ne z_j. \end{array} \end{array}$$

Let $\Gamma = (V, E, \omega, z)$ designate the vertices, edges, their weights, and the attributes, respectively. The value of the statistic is obtained by the weighted sum of the $\gamma_{ij}$ over the edges:

$$J(\gamma; \Gamma) = \sum_{e_{ij}\in E} \omega_{ij} \gamma_{ij}.$$

The distribution of such a statistic depends on assumptions made about the distributions of the $z_i$. Although I have not seen this (classic) text, references to it indicate that in this section it assumes a permutation distribution ("sampling without replacement") for the $z_i$. That is, we take the multiset of $\{z_i\}$ as given and contemplate the distribution attained by $J$ when the $\{z_i\}$ undergo any permutation with equal probabilities.

The variance of $J$ is obtained by calculating its first two moments. Let's begin with the first moment, its expectation. By linearity of expectation,

$$\mathbb{E}[J] = \sum_{e_{ij}\in E} \omega_{ij} \mathbb{E}[\gamma_{ij}].$$

For the join count statistic,

$$\mathbb{E}[\gamma_{ij}] = \mathbb{E}[I(z_i,z_j)]$$

is just the chance that $z_i$ and $z_j$ will have the same value when chosen randomly without replacement from the $\{z_i\}$. Let there be $n \gt 1$ vertices and suppose that one of the possible values of the $z_i$ is "black" and that $B$ of the $z_i$ have this value. This chance then obviously equals

$$\mathbb{P}[z_i=\text{black} \wedge z_j=\text{black}] = \frac{B}{n}\frac{B-1}{n-1} = \frac{\binom{B}{2}}{\binom{n}{2}}.$$

For instance, specializing to the case of just two attributes ("white" and "black") and equal weights $\omega_{ij}=1$ at all edges, we obtain

$$\mathbb{E}[J] = \frac{\binom{B}{2}+\binom{W}{2}}{\binom{n}{2}}\sum_{e_{ij}\in E} \omega_{ij}.$$

Further specializing to a toroidal grid, each vertex has exactly four edges and each edge is shared among two vertices, implying there are $2n$ edges, whence $W = \sum_{e_{ij}\in E} \omega_{ij} = 2n$, simplifying the expectation to $2n\left(\binom{B}{2}+\binom{W}{2}\right)/\binom{n}{2}$. (As a check, when $B\approx W\approx n/2$ this reduces approximately to $n/2$, which is the intuitively obvious result.)

Armed with this preliminary success, let's tackle the second moment. It looks more complicated, but succumbs to the same treatment.

$$\mathbb{E}[J^2] = \sum_{e_{ij}\in E}\sum_{e_{i'j'}\in E} \omega_{ij}\omega_{i'j'} \mathbb{E}[\gamma_{ij}\gamma_{i'j'}].$$

Evidently we need to compute expectations of the form

$$E_{i,j,i',j'} = \mathbb{E}[\gamma_{ij}\gamma_{i'j'}] = \mathbb{E}[I(z_i=z_j)I(z_{i'}=z_{j'})].$$

The possibilities are exhausted by three disjoint cases:

1. $\{i,j\} = \{i',j'\}$. Here, $I(z_i=z_j)I(z_{i'}=z_{j'})=I(z_i=z_j)$, so

$$\mathbb{E}[I(z_i=z_j)I(z_{i'}=z_{j'})]=\mathbb{E}[I(z_i=z_j)],$$

which we have previously computed.

2. $\{i,j,i',j'\}$ consists of three distinct indexes. It follows that $I(z_i=z_j)I(z_{i'}=z_{j'})=1$ if and only if all three associated values are equal, whence the expectation is

$$\frac{\binom{B}{3} + \binom{W}{3}}{\binom{n}{3}}.$$

3. $\{i,j, i',j'\}$ consists of four distinct indexes. Reasoning as before, the chance of this equals

$$\frac{2\binom{B}{2}\binom{W}{2} + \binom{B}{2}\binom{W-2}{2} + \binom{B-2}{2}\binom{W}{2}}{\binom{n}{2}\binom{n-2}{2}}.$$

That's as far as we need to go here, because all the ingredients are in place for computing the double summation for any weighted graph $(V, E, \omega_{ij})$. The actual answer depends on the graph structure. For unit weights $\omega_{ij}=1$, then given any edge $e_{ij}$, you will need to count the number of edges $e_{i'j'}$ of types (2) and (3) above.

Calculations for sampling with replacement (another probability model) are a little simpler, so I won't provide the details. It amounts to replacing expressions $\binom{m}{k}$ by $m^k$ throughout.

Don't forget at the end to compute the variance by subtracting the square of the expectation from the second moment!

• Thanks for the timely and detailed reply. I am a bit confused. Are some of your addition symbols above intended to be multiplication? – wvguy8258 May 28 '13 at 1:29
• All the additions I can find are derived from partitioning the event "$z_i=z_j$" according to the possible common colors of the $z_i$ and $z_j$; therefore, those probabilities add. – whuber May 28 '13 at 14:25
• Thanks again. It took working a simple case out fully by hand, showing all constituent parts, to understand this more fully. I asked my previous question because I mistakenly assumed that you were writing the variance for unlike joins (BW) and what you wrote differed from equations found elsewhere (which were given in those places without any explanation to their construction). I am now able to write a program that will do what I would like for any join type (WW, BB, or BW). – wvguy8258 May 29 '13 at 3:44
• I'll make a note here for anyone else that might read this with my same question. In whuber's answer, the statements "three distinct indexes" and "four distinct indexes" refer to the subscript (i/j) for features/nodes/edges and not to the indicator function. I was being a bit dense and was caught for a bit thinking that, for instance, 3 unique indexes referred to 3 unique indicator function values. This was obviously an oversight on my part that others should avoid. "Three distinct indexes", for example, would be a case such as an edge pair with vertices (1,2) and (2,3), respectively – wvguy8258 May 29 '13 at 5:31
• Thank you for clarifying: I appreciate knowing where my exposition might be improved. – whuber May 29 '13 at 13:43