Testing spatial autocorrelation for presence-absence records? [duplicate]

I want to test the spatial autocorrelation for presence-absence data records, I know that the Moran's I test cannot be used here since I have categorical data.

I was thinking about the join-count statistic, but is there any work that applied this statistic to the presence-absence data?

I have data points and I don't know how to use this statistic here.

• Is your data presence-absence on a grid, in a set of regions, or at a set of point locations? Commented Mar 3, 2021 at 16:55
• @Spacedman my presence-absence data is on set of point locations Commented Mar 3, 2021 at 17:02

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.