The goal of motifator is to allow users to generate spatial motifs that replicate the ones seen in real-world data, without including any potentially identifying information.


You can install motifator from github with:


Consider this example: You want to compare the impact of spatial clustering of different levels of vaccination coverage in a model of infectious disease transmission. So, let’s make a map where we assume that about 50% of the population is vaccinated, but there is no spatial clustering.

Our metric of spatial clustering for this example is Moran’s I. Theoretical values of I run from -1 to 1. I = -1 implies anticorrelation, in which neighboring cells have values that are maximally different from each other. By contrast, values closer to +1 indicate strong spatial autocorrelation.

Let’s sample a map with strong spatial correlation:

This results in an average I value of 0.79 and an average proportion of 0.51.

Now for comparison, let’s do the same thing but for a 10 x 10 map with no spatial structure and the same mean:

This results in an average I value of 0.04 and an average proportion of 0.50.

And with anti-correlation:

This results in an average I value of -0.14 and an average proportion of 0.50. This value is a bit short of our target value of I, but we can see that the variance of the cell values has increased significantly. Acheiving the theoretical maximum value of -1 may be particularly infeasible for continuous outputs constrained to (0,1) because it necessitates a perfectly inverse relationship in the value of neighboring cells. Future iterations should pre-derive the minimum and maximum values of I given the output range and allow users to set the correlation parameter as a function of this range.