You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main package used throughout this notebook will be **spatmap**. This package provides functions
123
-
that compute and visualize a variety of local spatial statistics. The visualizations include cluster maps
124
-
and their associated significance maps. The mapping functions are built off of **tmap** and can have additional
125
-
layers added to them like `tm_borders` or `tm_layout`.
126
-
127
-
119
+
that visualize a variety of local spatial statistics. This package is built off of **rgeoda** for the statistical computations and **tmap** for the mapping component. All of the visualizations are built with a similar style
120
+
to GeoDa. The visualizations include cluster maps and their associated significance maps. The mapping functions
121
+
are built off of **tmap** and can have additional layers added to them like `tm_borders` or `tm_layout`.
128
122
129
123
### geodaData
130
124
@@ -190,44 +184,25 @@ and should not be interpreted in an absolute sense.
190
184
### Implementation
191
185
192
186
With the function `moran_map` from **spatmap**, we can create a local moran cluster map. The parameters
193
-
needed are a**sf** dataframe, which is **guerry** in our case, and the name of a variable from the **sf**
187
+
needed are an**sf** dataframe, which is **guerry** in our case, and the name of a variable from the **sf**
194
188
dataframe. It is important to note the default parameters of `moran_map`. These include `permutations = 999`,
195
-
`alpha = .05`, and `weights = NULL`. We will show examples of these later, but they are important to keep in
196
-
mind.
197
-
189
+
`alpha = .05`, and `weights = NULL`. Permutations is the number of permutations used in computing the reference distributions
190
+
of the local statistic for each location. Alpha is the cutoff significance level. The weights parameter is where we specify
191
+
the weights used for the computation of the local statistics. In the NULL case, 1st order queen contiguity are computed.
198
192
```{r}
199
193
moran_map(guerry,"Donatns")
200
194
```
201
195
202
-
To get a significance map for the local moran cluster map, we use `significance_map`. The default
196
+
To get a significance map for the local moran, we use `significance_map`. The default
203
197
parameters are the same for this function as `moran_map`. Default number of permutations is 999,
204
-
the alpha level is .05, and there is option for custom weights, but 1st order queen contiguity
198
+
the alpha level is .05, and there is an option for custom weights, but 1st order queen contiguity
205
199
are used as default. For the significance map that corresponds with the local moran cluster map,
206
-
we set `type = "moran"`. To get the significance map that directly corresponds to the cluster map,
207
-
we will need to set the same ranomization seed before running each function.
200
+
we set `type = "moran"`.
208
201
```{r}
209
202
significance_map(guerry,"Donatns", type = "moran")
210
203
```
211
204
212
205
213
-
#### Random seeds
214
-
215
-
Both the cluster and significance mapping functions use randomization to assess significance of
216
-
local statistics. The significance map shows the p-values of location, while the cluster map shows
217
-
the specific cluster classifcation. To reproduce the randomization used in one map, the same random
218
-
seed must be set before using the associated function. We demonstrate this below by using `set.seed`,
219
-
before `moran_map`, and again before `significance_map`. We use **2020** for the random seed in both cases,
220
-
this will give use the same randomization in both functions. We use `tmap_arrange` To display the maps
221
-
side by side. They both show the same significant counties because the randomization seeds are the same,
222
-
and the same cut-off p-value is used to assess significance in both maps. If we do not set the same randomization
223
-
seeds, the resulting maps are likely to show differences in significanct locations.
224
-
```{r}
225
-
set.seed(2020)
226
-
p1 <- moran_map(guerry,"Donatns")
227
-
set.seed(2020)
228
-
p2 <- significance_map(guerry,"Donatns", type = "moran")
229
-
tmap_arrange(p1,p2,ncol = 2)
230
-
```
231
206
232
207
233
208
#### tmap additions
@@ -249,7 +224,7 @@ We can set the **tmap** mode to "view"" to get an interactive base map with `tma
249
224
tmap_mode("view")
250
225
moran_map(guerry,"Donatns") +
251
226
tm_borders() +
252
-
tm_layout(title = "Local Moran Cluster Map of Donatns")
227
+
tm_layout(title = "Local Moran Cluster Map of Donatns",legend.outside = TRUE)
253
228
```
254
229
255
230
We set `tmap_mode("plot")` to get normal maps for the rest of the notebook. While basemaps are a nice
@@ -260,18 +235,21 @@ tmap_mode("plot")
260
235
261
236
### Randomization Options
262
237
263
-
To obtain higher significance levels, we need to use more permutations in the calculation
238
+
To obtain higher significance levels, we need to use more permutations in the computation
264
239
of the the local moran for each location. For instance, a pseudo pvalue of .00001 would
265
240
require 999999 permutations. To get more permutations, we set `permutations = 99999` in
266
241
`moran_map`. It is important to note that the maximum number of permutations for this function is 99999.
0 commit comments