# Seeking appropriate statistic to measure spatial autocorrelation of points with binary values

I am trying to determine the level of spatial autocorrelation in a point dataset. The attribute I'm interested in is binary (presence/absence of a species), for which Moran's I is not appropriate. On the other hand, Joint Count statistics, which are typically recommended for binary or categorical data, apparently are not appropriate for point data.

What is an appropriate statistic to measure global and/or local spatial autocorrelation of points when the attribute of interest is binary?

Your assertion that a Join-Counts statistic is not appropriate for binary data is not correct. It is just a matter of how the spatial weights matrix (Wij) is specified. As in a Morna's-I, you cannot use a distance matrix in this type of analysis, However, an appropriate binary matrix of contingency can be calculated using a distance cutoff. You can create this type of spatial weights matrix as well as conduct a Join-Count analysis in the R spdep library. See the "joincount.test" and joincount.mc (for Monte Carlo permutation test) functions.

• Thanks, Jeffrey. Joint counts are clearly the way to go for binary data, but I saw a suggestion (can't recall where, now) that joint counts were only appropriate for area (not point) data. It wasn't apparent to me why you couldn't create the weights matrix using a distance threshold, and use a joint count, but I couldn't find examples of this in some cursory searches. Is there a reference you can provide for this type of use? Jan 29, 2013 at 19:15
• This is a large body of literature on Point Pattern Analysis. The Join-Counts statistic is not commonly used and, as such, is not very prevalent in the current literature. I would go back to early work by Diggle or Geits. What is your goal in quantifying spatial dependency in binomial data? You cannot use a Join-Counts coefficient in something like a mixed effects or CAR/SAR model. Here some some interesting background on occupancy pattern scaling (en.wikipedia.org/wiki/Scaling_pattern_of_occupancy) Jan 29, 2013 at 19:48
• RandomForest is a nonparametric model and, as such, is not effected by autocorrelation. The concern with this model is correlation within the bootstrap ensemble. Often autocorrelation can create "redundancy" in your data that creates bias in the Bootstrap. I would look at based on the conditional distribution(s) of your covariates. I have R code available "R - Plot Probability Density by Grouping Factor" here: conserveonline.org/workspaces/emt/documents/all.html Jan 29, 2013 at 20:19
• Oh, I would not generalize RF being entirely black box. This is in fact not the case. This model is often reffed to as "grey box". Since autocorrelation primary influences IID assumptions in frequentist methods it is a fairly safe assertion that nonparametric assumptions are not violated. Jan 29, 2013 at 20:33
• We are generalizing "nonparametric" statistics. This encompasses many methods. If you look back at Brieman's 2001 proofs you will see that RF does not assume independence. Hastie's book "Elements of Statistical Learning" provides a solid statistical background to sample theory in relation to machine learning methods. As stated previously, the concern is correlation in the ensemble which can certainly be caused by pseudoreplication/autocorrelation. However, this is not a model assumption in RF. However, if sever enough, the net effect of bias or overfit is obviously the same. Jan 30, 2013 at 21:47

Yes you can use join-counts (not "joint counts") for spatial point data autocorrelation measure. Here's how with discussion on appropriate weight matrix decision:

First let's make some data:

``````> set.seed(123)
> pts = st_as_sf(data.frame(x=runif(50),y=runif(50)),coords=1:2)
> pts\$S = factor(sample(c("Presence","Absence"),nrow(pts),TRUE))
> plot(pts,pch=19)
``````

To do join-counts, you need to decide where the joins are. For a grid that's usually the 4- or 8- nearest neighbours (rook or queen neighbours). For a set of points you have to find another definition, and there is some flexibility here.

You could try an N-nearest neighbour approach with ooh, 5 nearest neighbours:

``````> nn5 = knn2nb(knearneigh(pts,5))
> w = nb2listw(nn5, style="B")
``````

and then do the join-count tests:

``````> joincount.test(pts\$S, w)

Join count test under nonfree sampling

data:  pts\$S
weights: w

Std. deviate for Absence = -0.13997, p-value = 0.5557
alternative hypothesis: greater
sample estimates:
Same colour statistic           Expectation              Variance
47.00000              47.44898              10.28898

Join count test under nonfree sampling

data:  pts\$S
weights: w

Std. deviate for Presence = -0.53688, p-value = 0.7043
alternative hypothesis: greater
sample estimates:
Same colour statistic           Expectation              Variance
16.000000             17.448980              7.283882
``````

with similar ("no autocorrelation") conclusions from `joincount.mc`.

So how to choose the number of neighbours? Or why choose N-nearest neighbours anyway? You could also build voronoi polygons and use polygon adjacency for the connection matrix? Each or any of these should give you the same general conclusions about your autocorrelation unless your data is particularly weirdly arranged to be affected by a specific connection matrix. Try a few and confirm that - the more you do, the stronger your conclusion about your autocorrelation can be.

But remember this is really an exploratory statistic and usually only a stepping-stone to a formal model with testable hypotheses about the underlying data beyond complete spatial randomness of presence/absence conditional on the locations.

Binary data is a normal use case for spatial autocorrelation. I think most of spatial analysis book will talk about it. This document might be of help.

• The first page of your reference emphasizes that "data locations are regions," so it looks like it does not apply to point data at all. Jan 29, 2013 at 20:28

Your data can be analyzed using "Point Pattern Analysis" techniques. Specifically "Ripley's K" will most likely be best for you.

A good overview is here: http://www.people.vcu.edu/~dbandyop/pubh8472/RipleysK.pdf