Few typos and slight rewords I saw
#Gloabl Moran's I
We will use the spdep package in R to help perform the Moran’s I test. I prefer working with sf objects in R, which is a newer way to store spatial data-structures that adheres to tidy principals. To take advantage of the robust spatial tests available in spdep, we must use sp objects rather than sf objects. I will convert my sf objects to sp to perform the tests, then tidy the results on the back end using the broom package.
To calculate Moran’s I the spdep function needs to know zip codes' distances from one another. Feeding an sp object to the poly2nb() function will build a neighbors list based on regions sharing the same boundary. Below visually shows the relationships this function is producing.
We are now ready to perform the Moran’s I test for spatial autocorrelation. I used the EBImoran.mc() function since we are working with COVID rates based on the population of a specific zip code. This function also automatically performs Monte Carlo simulations for us to compare our observed test statistic against. We must add the number of COVID cases and population for the zip code, as well as a list of weighted objects representing the neighborhood relationships we calculated earlier.
Few typos and slight rewords I saw
#Gloabl Moran's I
We will use the
spdeppackage in R to help perform the Moran’s I test. I prefer working with sf objects in R, which is a newer way to store spatial data-structures that adheres to tidy principals. To take advantage of the robust spatial tests available in spdep, we must use sp objects rather than sf objects. I will convert mysfobjects tospto perform the tests, then tidy the results on the back end using thebroompackage.To calculate Moran’s I the spdep function needs to know zip codes' distances from one another. Feeding an
spobject to thepoly2nb()function will build a neighbors list based on regions sharing the same boundary. Below visually shows the relationships this function is producing.We are now ready to perform the Moran’s I test for spatial autocorrelation. I used the
EBImoran.mc()function since we are working with COVID rates based on the population of a specific zip code. This function also automatically performs Monte Carlo simulations for us to compare our observed test statistic against. We must add the number of COVID cases and population for the zip code, as well as a list of weighted objects representing the neighborhood relationships we calculated earlier.