# Correlation/association between two point layers [duplicate]

I’d like to know if there is a way of obtaining a correlation/association test between two point layers in QGIS (or another open source software if not possible in QGIS)?

I have two point layers- one layer is the location of individuals (long and lat coordinates) who have contracted an infection. The second layer is the long and lat coordinates of important buildings (e.g. schools). I’d like to know if the location of infected individuals is correlated/associated with the location of important buildings.

I try to give my opinion about the problem, which I do not think is a duplicate of the question pointed out by @15Step in his/her comment.

First of all, two little disclaimers:

The above link will take you to my earlier question, which got a useful and sensible reply by @whuber. His reply entailed the use of a simulation in R to build the distribution of average minimum distances between individuals and buildings under the null hypothesis that there is no association between them. The latter is achieved (in whuber's example) by keeping the location of the two elements (i.e., individuals and building) unchanged and randomly swapping the assigment of each location to either of the two elements. Then the observed average distance is set against the randomized distribution and its statistical significance is computed.

Another approach would be using the G-cross function (out of the `spatstat` package), as described here (again by whuber): https://stats.stackexchange.com/questions/38013/interpretation-of-spatial-gcross-plots.

Yet another index, developed in archaeology, to test for spatial association between two point features is the Hodder-Okell's A index. The A index is about equal to 1 when the two patterns are randomly mingled; it is smaller than 1 when the two patterns are segregrated; it is larger than 1 when the features of the two point patterns tend to occur together. Statistical significance is assessed via a permutation approach, not dissimilar from the one described by whuber in his reply to my earlier question. The A-index is implemented in the `Aindex()` function out of a package that can be installed into R from GitHub (https://github.com/gianmarcoalberti/GmAMisc).

In summary, while I do know that I have addressed just part of your question, I think that one of the described solutions would allow you to achieve what you're after. Importing your shapefiles into R and putting one of the above solution to work would not take you too long.

• Actually, a robust way to address this problem would be the Besag-L (standardized Ripley's-K) cross statistic. It is straight forward enough to put this in a Monte Carlo framework to assess significance. Please keep in mind the underlying assumptions of point pattern statistics. It is critical that the data represent an observed point process and not a sample of a population. This becomes even more relevant when looking at bivariate problems. Here is an example: gis.stackexchange.com/questions/42427/… Commented Jun 15, 2018 at 15:19