st_coordinates()
sf
inla()
The test statistic is defined as:
\[X^2 = \sum_{i = 1}^{m}\frac{(n_{i,obs} - n_{i,exp})^2}{n_{i,exp}}\]
It follows a Chi-square distribution under the null hypothesis, i.e. under CSR.
\[X_{CSR}^2 \sim \chi_{m-1}^2\]