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
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.
The text was updated successfully, but these errors were encountered:
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 mysf
objects tosp
to perform the tests, then tidy the results on the back end using thebroom
package.To calculate Moran’s I the spdep function needs to know zip codes' distances from one another. Feeding an
sp
object 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.The text was updated successfully, but these errors were encountered: