This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
63 lines (41 loc) · 2.56 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# motifator
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.
## Installation
You can install motifator from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("jzelner/motifator")
```
## Example
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:
```{r example}
require(motifator)
m <- sampleProportion(10, i_target = 0.9, mean_target = 0.5)
plotMap(m)
```
This results in an average *I* value of `r sprintf("%0.2f", mean(m$i))` and an average proportion of `r sprintf("%0.2f", mean(m$y_bar))`.
Now for comparison, let's do the same thing but for a `10 x 10` map with no spatial structure and the same mean:
```{r example2}
m <- sampleProportion(10, i_target = 0.0, mean_target = 0.5)
plotMap(m)
```
This results in an average *I* value of `r sprintf("%0.2f", mean(m$i))` and an average proportion of `r sprintf("%0.2f", mean(m$y_bar))`.
And with anti-correlation:
```{r example3}
m <- sampleProportion(10, i_target = -0.9, mean_target = 0.5)
plotMap(m)
```
This results in an average *I* value of `r sprintf("%0.2f", mean(m$i))` and an average proportion of `r sprintf("%0.2f", mean(m$y_bar))`. 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.