Rpub link: -=https://rpubs.com/sakiyasuda/675431
On September 22nd, 2020, the government of Mexico reported the number of COVID-10 cases in its territory surpassed 700,000. Nearly 2,000 cases of COVID-19 have been reported, on a daily basis, while the recorded number of death in the country is now more than 300,000. As can be seen from the above-mentioned statistics, Mexico is currently suffering severe damage and casualties, due to an ongoing worldwide pandemic.
In this case, I will be looking to analyze the Spatio-Temporal patterns of COVID-19 in the country, with focus on Central Mexico. To be more specific, this analysis will be on Mexico City - (9), Mexico State - (15), and Morelos State - (17).
The first step will be installation of necessary libraries that are necessary for data analysis from R packages.
packages = c('rgdal', 'sf', 'spdep', 'tmap', 'tidyverse', 'rgeos','prettydoc','plotly')
for (p in packages){
if(!require(p, character.only = T)){
install.packages(p)
}
library(p,character.only = T)
}
As mentioned, this analysis is looking to focus on a current pandemic situation in Mexico. I extracted the data from Mexico’s Secretary of Health, under Mexican government.
(http://datosabiertos.salud.gob.mx/gobmx/salud/datos_abiertos/).
mexico <- readOGR(dsn = "data/geospatial", layer="municipalities_COVID")
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\sunho\Documents\SMU\3.2\gis\Take home2\Take_home_Two\data\geospatial", layer: "municipalities_COVID"
## with 2465 features
## It has 198 fields
I divided and categorized the data by three regions, in 09, 15, and 17. Each number represents a different region: (9) for Mexico City, (15) for Mexico State, and (17) for Morelos State. For an overall analysis on Central Mexico, I combined these datasets. This way, not only will it enable a comparison between regions, but it will also allow an overall view on the degree of influence of the COVID-19 on Central Mexico.
mexico_09 <- mexico[(mexico$CVE_ENT == '09'),]
mexico_15 <- mexico[(mexico$CVE_ENT == '15'),]
mexico_17 <- mexico[(mexico$CVE_ENT == '17'),]
central_mexico <- mexico[(mexico$CVE_ENT == '09' | mexico$CVE_ENT == '15' | mexico$CVE_ENT == '17'),]
Plot the area 09,15,16 and central mexico areas to check if the layers are well plotted.
plot(mexico_09, main = "Area 09")
plot(mexico_15, main = "Area 15")
plot(mexico_17, main = "ARea 17")
plot(central_mexico, main = "Central Mexico")
I will be mainly focused on cumulative cases as it allows me to determine the number of observation that lies with the past value in the dataset. By using cumulative cases, I will be able to analyze the cases of each area in central Mexico.
I have filtered the dataset into Mexico new cases and cumulative cases.
mexico_09_new <- mexico_09[,c(1:6,19:38)]
mexico_15_new <- mexico_15[,c(1:6,19:38)]
mexico_17_new <- mexico_17[,c(1:6,19:38)]
central_mexico_new <- central_mexico[,c(1:6,51:70)]
mexico_09_cumu <- mexico_09[,c(1:6,51:70)]
mexico_15_cumu <- mexico_15[,c(1:6,51:70)]
mexico_17_cumu <- mexico_17[,c(1:6,51:70)]
central_mexico_cumu <- central_mexico[,c(1:6,51:70)]
In order to calculate the covid 19 rate per population I need to calculate the total sum of cumulative cases
mexico_09_cumu@data$`total_count` <- as.numeric(apply(mexico_09_new@data[,7:26], 1, sum))
mexico_15_cumu@data$`total_count` <- as.numeric(apply(mexico_15_new@data[,7:26], 1, sum))
mexico_17_cumu@data$`total_count` <- as.numeric(apply(mexico_17_new@data[,7:26], 1, sum))
central_mexico_cumu@data$`total_count` <- as.numeric(apply(central_mexico_new@data[,7:26], 1, sum))
Calculate the Covid-19 Rate per 10000 population I have summed up the new cases and divided into the total population to calculate the covid-rate for each state in central Mexico and overall central Mexico.
mexico_09_cumu@data$`covid_rate` <- (mexico_09_cumu@data$`total_count`*10000)/mexico_09_cumu@data$`Pop2020`
mexico_15_cumu@data$`covid_rate` <- (mexico_15_cumu@data$`total_count`*10000)/mexico_15_cumu@data$`Pop2020`
mexico_17_cumu@data$`covid_rate` <- (mexico_17_cumu@data$`total_count`*10000)/mexico_17_cumu@data$`Pop2020`
central_mexico_cumu@data$`covid_rate` <- (central_mexico_cumu@data$`total_count`*10000)/central_mexico_cumu@data$`Pop2020`
mexico_cum_09_sf <- st_as_sf(mexico_09_cumu) %>%
select("CVE_ENT", "NOMGEO", "covid_rate")
mexico_cum_15_sf <- st_as_sf(mexico_15_cumu) %>%
select("CVE_ENT", "NOMGEO", "covid_rate")
mexico_cum_17_sf <- st_as_sf(mexico_17_cumu) %>%
select("CVE_ENT", "NOMGEO", "covid_rate")
central_mexico_sf <- st_as_sf(central_mexico_cumu) %>%
select("CVE_ENT", "NOMGEO", "covid_rate")
central_mexico_sf <- st_as_sf(central_mexico_cumu)
Let’s understand the cumulative cases in central Mexico. There were few cases for week 13 to week 16 but after that, it started to increase in cases till week 31. we can understand that the cases are gradually increasing and it slows down from week 31 to week 32.
let’s understand the covid19 rate using bar charts. From Mexico City 09, I can identity that Milpa Alta has the highest rate followed by Xochimilco
mexico_city_09_bar <- barplot(mexico_cum_09_sf$covid_rate, ylim = c(0, 200), main = "COVID 19 Rate in Mexico City 09", ylab="Covid 19 Rate")
axis(1, at=mexico_city_09_bar, labels=mexico_cum_09_sf$NOMGEO, las=3, cex.lab=4, cex.axis=0.5)
From Mexico City 15, it’s very clear that Apaxco city has the highest rate
mexico_city_15_bar <- barplot(mexico_cum_15_sf$covid_rate, ylim = c(0, 200), main = "COVID 19 Rate in Mexico City 15", ylab="Covid 19 Rate")
axis(1, at=mexico_city_15_bar, labels=mexico_cum_15_sf$NOMGEO, las=3, cex.lab=4, cex.axis=0.5)
From Mexico City 17, highest rate is Zacatepec follow by Tiayacapan and Puente de lxtla
mexico_city_17_bar <- barplot(mexico_cum_17_sf$covid_rate, ylim = c(0, 60), main = "COVID 19 Rate in Mexico City 17", ylab="Covid 19 Rate")
axis(1, at=mexico_city_17_bar, labels=mexico_cum_17_sf$NOMGEO, las=3, cex.lab=4, cex.axis=0.5)
central_mexico_bar <- barplot(central_mexico_sf$covid_rate, ylim = c(0, 1500), main = "COVID 19 Rate in central_mexico", ylab="Covid 19 Rate")
axis(1, at=central_mexico_bar, labels=central_mexico_sf$NOMGEO, las=3, cex.lab=4, cex.axis=0.5)
From the Choloropleth map, I can analyze that Area 09 have darker colours compared to other cities. Also, it spread to other regions by weeks
central_mexico_13 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul13, `geometry`)
central_mexico_13_tmap <- tm_shape(central_mexico_13) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 13", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_14 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul14, `geometry`)
central_mexico_14_tmap <- tm_shape(central_mexico_14) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 14", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
tmap_arrange(central_mexico_13_tmap,central_mexico_14_tmap, asp=1, ncol=2)
central_mexico_15 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul15, `geometry`)
central_mexico_15_tmap <- tm_shape(central_mexico_15) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 15", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_16 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul16, `geometry`)
central_mexico_16_tmap <- tm_shape(central_mexico_16) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 16", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_17 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul17, `geometry`)
central_mexico_17_tmap <- tm_shape(central_mexico_17) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 17", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
tmap_arrange(central_mexico_15_tmap,central_mexico_16_tmap,central_mexico_17_tmap, asp=1, ncol=3)
central_mexico_18 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul18, `geometry`)
central_mexico_18_tmap <- tm_shape(central_mexico_18) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 18", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_19 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul19, `geometry`)
central_mexico_19_tmap <- tm_shape(central_mexico_19) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 19", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_20 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul20, `geometry`)
central_mexico_20_tmap <- tm_shape(central_mexico_20) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 20", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
tmap_arrange(central_mexico_18_tmap,central_mexico_19_tmap,central_mexico_20_tmap, asp=1, ncol=3)
central_mexico_21 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul21, `geometry`)
central_mexico_21_tmap <- tm_shape(central_mexico_21) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 21", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_22 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul22, `geometry`)
central_mexico_22_tmap <- tm_shape(central_mexico_22) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 22", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_23 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul23, `geometry`)
central_mexico_23_tmap <- tm_shape(central_mexico_23) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 23", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
tmap_arrange(central_mexico_21_tmap,central_mexico_22_tmap,central_mexico_23_tmap, asp=1, ncol=3)
central_mexico_24 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul24, `geometry`)
central_mexico_24_tmap <- tm_shape(central_mexico_24) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 24", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_25 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul25, `geometry`)
central_mexico_25_tmap <- tm_shape(central_mexico_25) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 25", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_26 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul26, `geometry`)
central_mexico_26_tmap <- tm_shape(central_mexico_26) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 26", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
tmap_arrange(central_mexico_24_tmap,central_mexico_25_tmap,central_mexico_26_tmap, asp=1, ncol=3)
central_mexico_27 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul27, `geometry`)
central_mexico_27_tmap <- tm_shape(central_mexico_27) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 27", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_28 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul28, `geometry`)
central_mexico_28_tmap <- tm_shape(central_mexico_28) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 28", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_29 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul29, `geometry`)
central_mexico_29_tmap <- tm_shape(central_mexico_26) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 29", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
tmap_arrange(central_mexico_27_tmap,central_mexico_28_tmap,central_mexico_29_tmap, asp=1, ncol=3)
central_mexico_30 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul30, `geometry`)
central_mexico_30_tmap <- tm_shape(central_mexico_27) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 30", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_31 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul31, `geometry`)
central_mexico_31_tmap <- tm_shape(central_mexico_28) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 31", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
central_mexico_32 <- central_mexico_sf %>%
filter(CVE_ENT %in% c("09","15","17")) %>%
dplyr::select(`CVEGEO`, `CVE_ENT`, `CVE_MUN`, `NOMGEO`, `Pop2010`, `Pop2020`,`CUMULATIVE` = cumul32, `geometry`)
central_mexico_32_tmap <- tm_shape(central_mexico_26) +
tm_fill(col= "CUMULATIVE",
title = "cumulative rate") +
tm_borders(alpha = 0.5) +
tm_layout(main.title = "week 32", title.size = 0.5,main.title.position="center", legend.outside = TRUE)
tmap_arrange(central_mexico_30_tmap,central_mexico_31_tmap,central_mexico_32_tmap, asp=1, ncol=3)
Let’s take a look at different 09,15 and 17 of the overall covid_rate. From the chart, it’s clear that most of the cases are from Mexico 09 and 17.
mexico_09_tmap <- qtm(mexico_09_cumu, "covid_rate", title = "Mexico_09")
mexico_15_tmap <- qtm(mexico_15_cumu, "covid_rate", title = "Mexico_15")
mexico_17_tmap <- qtm(mexico_17_cumu, "covid_rate", title = "Mexico_17")
tmap_arrange(mexico_09_tmap, mexico_15_tmap, mexico_17_tmap,asp=1, ncol=3)
qtm(central_mexico_cumu, "covid_rate", title = "central_mexico")
I would compute the queen and rook contintuity map
central_mexico_cumu_wm_q <- poly2nb(central_mexico_cumu, queen=TRUE)
central_mexico_cumu_wm_r <- poly2nb(central_mexico_cumu, queen=FALSE)
plot(central_mexico_cumu, border="lightgrey")
plot(central_mexico_cumu_wm_q, coordinates(central_mexico_cumu), pch = 19, cex = 0.6, add = TRUE, col = "red")
plot(central_mexico_cumu, border="lightgrey")
plot(central_mexico_cumu_wm_r, coordinates(central_mexico_cumu), pch = 19, cex = 0.6, add = TRUE, col = "red")
Looking at the Queen and Rook Contiguity, I can identify 14 different links. Especially at the south-west od the map. Queen has more travel edges and corners. Hence, Queen continuity is more efficient for analysis.
I will be analysing suitable weight matric for the analysis. From the output, I can identify that the distance is EPSG meter.
st_crs(central_mexico_sf)
## Coordinate Reference System:
## User input: MEXICO_ITRF_2008_LCC
## wkt:
## PROJCRS["MEXICO_ITRF_2008_LCC",
## BASEGEOGCRS["ITRF2008",
## DATUM["International Terrestrial Reference Frame 2008",
## ELLIPSOID["GRS 1980",6378137,298.257222101,
## LENGTHUNIT["metre",1]],
## ID["EPSG",1061]],
## PRIMEM["Greenwich",0,
## ANGLEUNIT["Degree",0.0174532925199433]]],
## CONVERSION["unnamed",
## METHOD["Lambert Conic Conformal (2SP)",
## ID["EPSG",9802]],
## PARAMETER["Latitude of false origin",12,
## ANGLEUNIT["Degree",0.0174532925199433],
## ID["EPSG",8821]],
## PARAMETER["Longitude of false origin",-102,
## ANGLEUNIT["Degree",0.0174532925199433],
## ID["EPSG",8822]],
## PARAMETER["Latitude of 1st standard parallel",17.5,
## ANGLEUNIT["Degree",0.0174532925199433],
## ID["EPSG",8823]],
## PARAMETER["Latitude of 2nd standard parallel",29.5,
## ANGLEUNIT["Degree",0.0174532925199433],
## ID["EPSG",8824]],
## PARAMETER["Easting at false origin",2500000,
## LENGTHUNIT["metre",1],
## ID["EPSG",8826]],
## PARAMETER["Northing at false origin",0,
## LENGTHUNIT["metre",1],
## ID["EPSG",8827]]],
## CS[Cartesian,2],
## AXIS["(E)",east,
## ORDER[1],
## LENGTHUNIT["metre",1,
## ID["EPSG",9001]]],
## AXIS["(N)",north,
## ORDER[2],
## LENGTHUNIT["metre",1,
## ID["EPSG",9001]]]]
centroids <- sf::st_centroid(central_mexico_sf$geometry)
coords <- st_coordinates(centroids)
knb <- knn2nb(knearneigh(coords,k=5, longlat = FALSE))
knn_lw <- nb2listw(knb, style = 'B')
k1dists <- unlist(nbdists(knb, coords, longlat = FALSE))
summary(k1dists)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1789 8508 11669 12690 15985 50477
Some of the areas in the fixed-distance link are not well connected compare to 1st nearest neighbours
wm_dmax <- dnearneigh(coords, 0, 20857, longlat = FALSE)
par(mfrow=c(1,2))
plot(central_mexico_sf$geometry, border="lightgrey", main="1st Nearest Neighbours")
plot(knb, coords, add=TRUE, col="red", length=0.08)
plot(central_mexico_sf$geometry, border="lightgrey", main="Fixed Distance Link")
plot(wm_dmax, coords, add=TRUE, pch = 19, cex = 0.6)
Create the row-standardized weight matrix with nb2listw
rswm_q <- nb2listw(central_mexico_cumu_wm_q, zero.policy = TRUE)
summary(rswm_q)
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 176
## Number of nonzero links: 962
## Percentage nonzero weights: 3.10563
## Average number of links: 5.465909
## Link number distribution:
##
## 1 2 3 4 5 6 7 8 9 10 11 14
## 3 3 18 41 31 31 22 13 9 3 1 1
## 3 least connected regions:
## 721 739 765 with 1 link
## 1 most connected region:
## 761 with 14 links
##
## Weights style: W
## Weights constants summary:
## n nn S0 S1 S2
## W 176 30976 176 71.10695 731.679
Perform Moran’s I statistic test using moran.test()
moran.test(central_mexico_cumu$covid_rate, listw=rswm_q, zero.policy = TRUE, na.action=na.omit)
##
## Moran I test under randomisation
##
## data: central_mexico_cumu$covid_rate
## weights: rswm_q
##
## Moran I statistic standard deviate = 11.594, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.531355255 -0.005714286 0.002145937
Perform Moran’s I statistic using moran.mc()
set.seed(1234)
central_mexico_moran= moran.mc(central_mexico_cumu$covid_rate, listw=rswm_q, nsim=999, zero.policy = TRUE, na.action=na.omit)
central_mexico_moran
##
## Monte-Carlo simulation of Moran I
##
## data: central_mexico_cumu$covid_rate
## weights: rswm_q
## number of simulations + 1: 1000
##
## statistic = 0.53136, observed rank = 1000, p-value = 0.001
## alternative hypothesis: greater
mean(central_mexico_moran$res[1:999])
## [1] -0.006679371
var(central_mexico_moran$res[1:999])
## [1] 0.002109503
summary(central_mexico_moran$res[1:999])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -0.139460 -0.039707 -0.009462 -0.006679 0.023299 0.196044
hist(central_mexico_moran$res, freq=TRUE, breaks=50, xlab="Simulated Moran's I")
abline(v=0, col="red")
fips <- order(central_mexico_cumu$NOMGEO)
localMI <- localmoran(central_mexico_cumu$covid_rate, rswm_q)
head(localMI)
## Ii E.Ii Var.Ii Z.Ii Pr(z > 0)
## 270 4.310276 -0.005714286 0.1865610 9.992404 8.227084e-24
## 271 4.012195 -0.005714286 0.1865610 9.302286 6.872897e-21
## 272 2.329954 -0.005714286 0.2345049 4.823200 7.063663e-07
## 273 2.344484 -0.005714286 0.1146451 6.941074 1.945651e-12
## 274 4.443751 -0.005714286 0.1865610 10.301427 3.471191e-25
## 275 2.566689 -0.005714286 0.1146451 7.597336 1.511450e-14
The code chunk below list the content of the local Moran matrix derived by using printCoefmat().
printCoefmat(data.frame(localMI[fips,], row.names=central_mexico_cumu$NOMGEO[fips]), check.names=FALSE)
## Ii E.Ii Var.Ii Z.Ii
## Ã\201lvaro Obregón 2.96790820 -0.00571429 0.13176793 8.19183066
## Acambay de RuÃz Castañeda 0.29904078 -0.00571429 0.23450492 0.62932496
## Acolman 0.02861044 -0.00571429 0.13176793 0.09455885
## Aculco 0.61560808 -0.00571429 0.23450492 1.28304240
## Almoloya de Alquisiras 0.59943855 -0.00571429 0.23450492 1.24965201
## Almoloya de Juárez 0.15121531 -0.00571429 0.13176793 0.43231469
## Almoloya del RÃo 0.55402783 -0.00571429 0.23450492 1.15587803
## Amacuzac 0.23157634 -0.00571429 0.23450492 0.49000962
## Amanalco 0.07224975 -0.00571429 0.13176793 0.21477783
## Amatepec 0.73256751 -0.00571429 0.31441146 1.31665798
## Amecameca -0.05186129 -0.00571429 0.23450492 -0.09529443
## Apaxco 0.28999668 -0.00571429 0.47422455 0.42941323
## Atenco 0.06936081 -0.00571429 0.15459837 0.19093848
## Atizapán 0.35129869 -0.00571429 0.31441146 0.63669994
## Atizapán de Zaragoza 0.00013692 -0.00571429 0.15459837 0.01488138
## Atlacomulco -0.04151730 -0.00571429 0.18656099 -0.08289134
## Atlatlahucan 0.21041613 -0.00571429 0.13176793 0.59540301
## Atlautla 0.18681063 -0.00571429 0.18656099 0.44573478
## Axapusco 0.00102129 -0.00571429 0.23450492 0.01390910
## Axochiapan 0.18997812 -0.00571429 0.31441146 0.34899948
## Ayala 0.19172585 -0.00571429 0.10132734 0.62025762
## Ayapango 0.07591387 -0.00571429 0.15459837 0.20760487
## Azcapotzalco 4.31027555 -0.00571429 0.18656099 9.99240419
## Benito Juárez 2.67217372 -0.00571429 0.15459837 6.81067175
## Calimaya 0.02840330 -0.00571429 0.11464510 0.10076289
## Capulhuac -0.00531959 -0.00571429 0.31441146 0.00070390
## Chalco 1.13505714 -0.00571429 0.10132734 3.58373017
## Chapa de Mota 0.55129907 -0.00571429 0.23450492 1.15024309
## Chapultepec 0.14965968 -0.00571429 0.23450492 0.32085018
## Chiautla 0.11897926 -0.00571429 0.13176793 0.34350978
## Chicoloapan 0.00697826 -0.00571429 0.23450492 0.02621034
## Chiconcuac 0.14218027 -0.00571429 0.31441146 0.26375639
## Chimalhuacán -0.00255197 -0.00571429 0.23450492 0.00653025
## Coacalco de Berriozábal 0.07465783 -0.00571429 0.23450492 0.16596992
## Coatepec Harinas 0.53569615 -0.00571429 0.11464510 1.59900149
## Coatetelco 0.37417095 -0.00571429 0.15459837 0.96616201
## Coatlán del RÃo 0.30304282 -0.00571429 0.15459837 0.78526187
## Cocotitlán 0.61523283 -0.00571429 0.31441146 1.10740233
## Coyoacán 4.01219483 -0.00571429 0.18656099 9.30228600
## Coyotepec -0.05408075 -0.00571429 0.23450492 -0.09987765
## Cuajimalpa de Morelos 2.32995440 -0.00571429 0.23450492 4.82319989
## Cuauhtémoc 4.56733378 -0.00571429 0.15459837 11.63063175
## Cuautitlán -0.09161566 -0.00571429 0.11464510 -0.25370110
## Cuautitlán Izcalli -0.05421215 -0.00571429 0.15459837 -0.12334460
## Cuautla -0.08154299 -0.00571429 0.23450492 -0.15658770
## Cuernavaca -0.00100731 -0.00571429 0.13176793 0.01296692
## Donato Guerra 0.43761475 -0.00571429 0.23450492 0.91548282
## Ecatepec de Morelos 0.07801243 -0.00571429 0.08195606 0.29246475
## Ecatzingo 0.35067183 -0.00571429 0.23450492 0.73594405
## El Oro -0.03110005 -0.00571429 0.23450492 -0.05242208
## Emiliano Zapata 0.24545981 -0.00571429 0.15459837 0.63881101
## Gustavo A. Madero 2.34448356 -0.00571429 0.11464510 6.94107395
## Huehuetoca 0.05875724 -0.00571429 0.23450492 0.13313491
## Hueypoxtla 0.13972482 -0.00571429 0.31441146 0.25937733
## Huitzilac -0.54800341 -0.00571429 0.15459837 -1.37920378
## Huixquilucan 0.23394186 -0.00571429 0.18656099 0.55485327
## Isidro Fabela 0.14125433 -0.00571429 0.18656099 0.34026257
## Ixtapaluca 0.01005285 -0.00571429 0.15459837 0.04010056
## Ixtapan de la Sal 0.48981056 -0.00571429 0.18656099 1.14724194
## Ixtapan del Oro 0.50564595 -0.00571429 0.31441146 0.91196415
## Ixtlahuaca 0.21464182 -0.00571429 0.18656099 0.51016970
## Iztacalco 4.44375080 -0.00571429 0.18656099 10.30142684
## Iztapalapa 2.56668904 -0.00571429 0.11464510 7.59733559
## Jaltenco -0.00519974 -0.00571429 0.15459837 0.00130863
## Jantetelco 0.50140254 -0.00571429 0.23450492 1.04720580
## Jilotepec 0.43306493 -0.00571429 0.18656099 1.01586412
## Jilotzingo -0.00535744 -0.00571429 0.18656099 0.00082617
## Jiquipilco 0.33330269 -0.00571429 0.15459837 0.86222178
## Jiutepec 0.22411116 -0.00571429 0.23450492 0.47459388
## Jocotitlán 0.13908214 -0.00571429 0.13176793 0.39888985
## Jojutla 0.00355889 -0.00571429 0.23450492 0.01914927
## Jonacatepec de Leandro Valle 0.30008563 -0.00571429 0.23450492 0.63148260
## Joquicingo 0.15677537 -0.00571429 0.15459837 0.41325990
## Juchitepec -0.42497409 -0.00571429 0.10132734 -1.31710347
## La Magdalena Contreras 3.02647316 -0.00571429 0.31441146 5.40762865
## La Paz -0.01590005 -0.00571429 0.15459837 -0.02590545
## Lerma 0.01113800 -0.00571429 0.09067314 0.05596538
## Luvianos 0.24060635 -0.00571429 0.31441146 0.43929030
## Malinalco 0.34176524 -0.00571429 0.15459837 0.88374457
## Mazatepec 0.29519814 -0.00571429 0.15459837 0.76531047
## Melchor Ocampo 0.12772369 -0.00571429 0.31441146 0.23797440
## Metepec 0.14490721 -0.00571429 0.13176793 0.41493692
## Mexicaltzingo 0.28497127 -0.00571429 0.31441146 0.51841107
## Miacatlán 0.21264204 -0.00571429 0.13176793 0.60153500
## Miguel Hidalgo 3.38009770 -0.00571429 0.13176793 9.32734352
## Milpa Alta 4.35750406 -0.00571429 0.11464510 12.88632840
## Morelos 0.36599237 -0.00571429 0.15459837 0.94536142
## Naucalpan de Juárez 0.45193065 -0.00571429 0.11464510 1.35160849
## Nextlalpan -0.06055492 -0.00571429 0.11464510 -0.16196631
## Nezahualcóyotl 0.85686547 -0.00571429 0.11464510 2.54754291
## Nicolás Romero 0.02762146 -0.00571429 0.13176793 0.09183437
## Nopaltepec 0.01928086 -0.00571429 0.95366381 0.02559517
## Ocoyoacac -0.05191146 -0.00571429 0.11464510 -0.13643873
## Ocuilan 0.19341911 -0.00571429 0.11464510 0.58812054
## Ocuituco 0.34035674 -0.00571429 0.23450492 0.71464320
## Otumba -0.00420795 -0.00571429 0.23450492 0.00311061
## Otzoloapan 0.40847257 -0.00571429 0.18656099 0.95892777
## Otzolotepec 0.00663239 -0.00571429 0.15459837 0.03140129
## Ozumba 0.08780576 -0.00571429 0.13176793 0.25763204
## Papalotla 0.04531015 -0.00571429 0.31441146 0.09099741
## Polotitlán 0.71106095 -0.00571429 0.47422455 1.04085678
## Puente de Ixtla -0.36329394 -0.00571429 0.15459837 -0.90943223
## Rayón 0.00195686 -0.00571429 0.23450492 0.01584107
## San Antonio la Isla -0.01017098 -0.00571429 0.15459837 -0.01133470
## San Felipe del Progreso 0.27231213 -0.00571429 0.15459837 0.70710451
## San José del Rincón 0.48112931 -0.00571429 0.23450492 1.00534121
## San MartÃn de las Pirámides 0.02418816 -0.00571429 0.18656099 0.06923032
## San Mateo Atenco 0.08485207 -0.00571429 0.31441146 0.16151680
## San Simón de Guerrero 0.18375977 -0.00571429 0.31441146 0.33790963
## Santo Tomás 0.39412857 -0.00571429 0.31441146 0.71308312
## Soyaniquilpan de Juárez 0.27550153 -0.00571429 0.95366381 0.28796659
## Sultepec 0.70624137 -0.00571429 0.18656099 1.64832377
## Tecámac -0.00102663 -0.00571429 0.11464510 0.01384451
## Tejupilco 0.12300527 -0.00571429 0.13176793 0.35460077
## Temamatla 0.29675704 -0.00571429 0.18656099 0.70028334
## Temascalapa -0.01220166 -0.00571429 0.23450492 -0.01339654
## Temascalcingo 0.12466398 -0.00571429 0.23450492 0.26923357
## Temascaltepec 0.35759772 -0.00571429 0.10132734 1.14134363
## Temixco 0.26666876 -0.00571429 0.18656099 0.63062277
## Temoac 0.61583049 -0.00571429 0.23450492 1.28350168
## Temoaya 0.14588144 -0.00571429 0.13176793 0.41762078
## Tenancingo 0.08693587 -0.00571429 0.15459837 0.23563711
## Tenango del Aire -0.05866120 -0.00571429 0.18656099 -0.12258299
## Tenango del Valle 0.00590692 -0.00571429 0.10132734 0.03650799
## Teoloyucan -0.00057119 -0.00571429 0.23450492 0.01062059
## Teotihuacán -0.07271072 -0.00571429 0.15459837 -0.17039200
## Tepalcingo 0.09674644 -0.00571429 0.23450492 0.21158333
## Tepetlaoxtoc 0.06525327 -0.00571429 0.13176793 0.19550369
## Tepetlixpa 0.21161293 -0.00571429 0.18656099 0.50315720
## Tepotzotlán -0.01423038 -0.00571429 0.13176793 -0.02346042
## Tepoztlán -0.26695541 -0.00571429 0.13176793 -0.71967544
## Tequixquiac 0.18107619 -0.00571429 0.23450492 0.38572586
## Tetecala 0.37871645 -0.00571429 0.31441146 0.68559701
## Tetela del Volcán 0.38039574 -0.00571429 0.23450492 0.79732449
## Texcaltitlán 0.46337238 -0.00571429 0.15459837 1.19302798
## Texcalyacac -0.00081996 -0.00571429 0.15459837 0.01244775
## Texcoco 0.01092783 -0.00571429 0.09067314 0.05526741
## Tezoyuca 0.02916262 -0.00571429 0.31441146 0.06219976
## Tianguistenco -0.15110499 -0.00571429 0.06327661 -0.57798298
## Timilpan 0.35007483 -0.00571429 0.15459837 0.90487835
## Tláhuac 6.20913140 -0.00571429 0.18656099 14.38864603
## Tlalmanalco 0.16232595 -0.00571429 0.13176793 0.46292264
## Tlalnepantla -0.32136319 -0.00571429 0.18656099 -0.73079214
## Tlalnepantla de Baz 0.42728487 -0.00571429 0.13176793 1.19283998
## Tlalpan 3.31291166 -0.00571429 0.10132734 10.42545394
## Tlaltizapán de Zapata 0.13026592 -0.00571429 0.13176793 0.37460263
## Tlaquiltenango -0.03656745 -0.00571429 0.15459837 -0.07846884
## Tlatlaya 1.05742465 -0.00571429 0.95366381 1.08866026
## Tlayacapan 0.05306795 -0.00571429 0.18656099 0.13609296
## Toluca -0.03658818 -0.00571429 0.10132734 -0.09699024
## Tonanitla 0.00443413 -0.00571429 0.18656099 0.02349566
## Tonatico 0.34435373 -0.00571429 0.47422455 0.50834718
## Totolapan 0.38245258 -0.00571429 0.18656099 0.89868614
## Tultepec 0.00812030 -0.00571429 0.18656099 0.03202991
## Tultitlán 0.00796871 -0.00571429 0.09067314 0.04544038
## Valle de Bravo 0.00873575 -0.00571429 0.13176793 0.03980743
## Valle de Chalco Solidaridad -0.44050690 -0.00571429 0.18656099 -1.00663434
## Venustiano Carranza 4.55798281 -0.00571429 0.23450492 9.42412058
## Villa de Allende 0.60030563 -0.00571429 0.23450492 1.25144255
## Villa del Carbón 0.41083129 -0.00571429 0.18656099 0.96438868
## Villa Guerrero 0.33349008 -0.00571429 0.18656099 0.78532788
## Villa Victoria 0.48852305 -0.00571429 0.18656099 1.14426109
## Xalatlaco -0.00318767 -0.00571429 0.23450492 0.00521751
## Xochimilco 9.13736680 -0.00571429 0.18656099 21.16811327
## Xochitepec 0.26122734 -0.00571429 0.18656099 0.61802478
## Xonacatlán -0.00443331 -0.00571429 0.23450492 0.00264525
## Xoxocotla 0.04183113 -0.00571429 0.15459837 0.12092223
## Yautepec 0.26055911 -0.00571429 0.11464510 0.78641180
## Yecapixtla 0.26471301 -0.00571429 0.10132734 0.84954658
## Zacatepec -0.21438047 -0.00571429 0.23450492 -0.43089960
## Zacazonapan 0.30498889 -0.00571429 0.18656099 0.71934177
## Zacualpan 0.82681427 -0.00571429 0.23450492 1.71918716
## Zacualpan de Amilpas 0.52741487 -0.00571429 0.23450492 1.10092175
## Zinacantepec 0.02149357 -0.00571429 0.15459837 0.06919773
## Zumpahuacán 0.26555871 -0.00571429 0.15459837 0.68992854
## Zumpango -0.00387888 -0.00571429 0.10132734 0.00576592
## Pr.z...0.
## Ã\201lvaro Obregón 0.0000
## Acambay de RuÃz Castañeda 0.2646
## Acolman 0.4623
## Aculco 0.0997
## Almoloya de Alquisiras 0.1057
## Almoloya de Juárez 0.3328
## Almoloya del RÃo 0.1239
## Amacuzac 0.3121
## Amanalco 0.4150
## Amatepec 0.0940
## Amecameca 0.5380
## Apaxco 0.3338
## Atenco 0.4243
## Atizapán 0.2622
## Atizapán de Zaragoza 0.4941
## Atlacomulco 0.5330
## Atlatlahucan 0.2758
## Atlautla 0.3279
## Axapusco 0.4945
## Axochiapan 0.3635
## Ayala 0.2675
## Ayapango 0.4178
## Azcapotzalco 0.0000
## Benito Juárez 0.0000
## Calimaya 0.4599
## Capulhuac 0.4997
## Chalco 0.0002
## Chapa de Mota 0.1250
## Chapultepec 0.3742
## Chiautla 0.3656
## Chicoloapan 0.4895
## Chiconcuac 0.3960
## Chimalhuacán 0.4974
## Coacalco de Berriozábal 0.4341
## Coatepec Harinas 0.0549
## Coatetelco 0.1670
## Coatlán del RÃo 0.2162
## Cocotitlán 0.1341
## Coyoacán 0.0000
## Coyotepec 0.5398
## Cuajimalpa de Morelos 0.0000
## Cuauhtémoc 0.0000
## Cuautitlán 0.6001
## Cuautitlán Izcalli 0.5491
## Cuautla 0.5622
## Cuernavaca 0.4948
## Donato Guerra 0.1800
## Ecatepec de Morelos 0.3850
## Ecatzingo 0.2309
## El Oro 0.5209
## Emiliano Zapata 0.2615
## Gustavo A. Madero 0.0000
## Huehuetoca 0.4470
## Hueypoxtla 0.3977
## Huitzilac 0.9161
## Huixquilucan 0.2895
## Isidro Fabela 0.3668
## Ixtapaluca 0.4840
## Ixtapan de la Sal 0.1256
## Ixtapan del Oro 0.1809
## Ixtlahuaca 0.3050
## Iztacalco 0.0000
## Iztapalapa 0.0000
## Jaltenco 0.4995
## Jantetelco 0.1475
## Jilotepec 0.1548
## Jilotzingo 0.4997
## Jiquipilco 0.1943
## Jiutepec 0.3175
## Jocotitlán 0.3450
## Jojutla 0.4924
## Jonacatepec de Leandro Valle 0.2639
## Joquicingo 0.3397
## Juchitepec 0.9061
## La Magdalena Contreras 0.0000
## La Paz 0.5103
## Lerma 0.4777
## Luvianos 0.3302
## Malinalco 0.1884
## Mazatepec 0.2220
## Melchor Ocampo 0.4060
## Metepec 0.3391
## Mexicaltzingo 0.3021
## Miacatlán 0.2737
## Miguel Hidalgo 0.0000
## Milpa Alta 0.0000
## Morelos 0.1722
## Naucalpan de Juárez 0.0883
## Nextlalpan 0.5643
## Nezahualcóyotl 0.0054
## Nicolás Romero 0.4634
## Nopaltepec 0.4898
## Ocoyoacac 0.5543
## Ocuilan 0.2782
## Ocuituco 0.2374
## Otumba 0.4988
## Otzoloapan 0.1688
## Otzolotepec 0.4875
## Ozumba 0.3983
## Papalotla 0.4637
## Polotitlán 0.1490
## Puente de Ixtla 0.8184
## Rayón 0.4937
## San Antonio la Isla 0.5045
## San Felipe del Progreso 0.2398
## San José del Rincón 0.1574
## San MartÃn de las Pirámides 0.4724
## San Mateo Atenco 0.4358
## San Simón de Guerrero 0.3677
## Santo Tomás 0.2379
## Soyaniquilpan de Juárez 0.3867
## Sultepec 0.0496
## Tecámac 0.4945
## Tejupilco 0.3614
## Temamatla 0.2419
## Temascalapa 0.5053
## Temascalcingo 0.3939
## Temascaltepec 0.1269
## Temixco 0.2641
## Temoac 0.0997
## Temoaya 0.3381
## Tenancingo 0.4069
## Tenango del Aire 0.5488
## Tenango del Valle 0.4854
## Teoloyucan 0.4958
## Teotihuacán 0.5676
## Tepalcingo 0.4162
## Tepetlaoxtoc 0.4225
## Tepetlixpa 0.3074
## Tepotzotlán 0.5094
## Tepoztlán 0.7641
## Tequixquiac 0.3498
## Tetecala 0.2465
## Tetela del Volcán 0.2126
## Texcaltitlán 0.1164
## Texcalyacac 0.4950
## Texcoco 0.4780
## Tezoyuca 0.4752
## Tianguistenco 0.7184
## Timilpan 0.1828
## Tláhuac 0.0000
## Tlalmanalco 0.3217
## Tlalnepantla 0.7675
## Tlalnepantla de Baz 0.1165
## Tlalpan 0.0000
## Tlaltizapán de Zapata 0.3540
## Tlaquiltenango 0.5313
## Tlatlaya 0.1382
## Tlayacapan 0.4459
## Toluca 0.5386
## Tonanitla 0.4906
## Tonatico 0.3056
## Totolapan 0.1844
## Tultepec 0.4872
## Tultitlán 0.4819
## Valle de Bravo 0.4841
## Valle de Chalco Solidaridad 0.8429
## Venustiano Carranza 0.0000
## Villa de Allende 0.1054
## Villa del Carbón 0.1674
## Villa Guerrero 0.2161
## Villa Victoria 0.1263
## Xalatlaco 0.4979
## Xochimilco 0.0000
## Xochitepec 0.2683
## Xonacatlán 0.4989
## Xoxocotla 0.4519
## Yautepec 0.2158
## Yecapixtla 0.1978
## Zacatepec 0.6667
## Zacazonapan 0.2360
## Zacualpan 0.0428
## Zacualpan de Amilpas 0.1355
## Zinacantepec 0.4724
## Zumpahuacán 0.2451
## Zumpango 0.4977
central_mexico.localMI <- cbind(central_mexico_cumu,localMI)
central_moran <- tm_shape(central_mexico.localMI) +
tm_fill(col = "Ii",
style = "pretty",
palette = "RdBu",
title = "local moran statistics") +
tm_borders(alpha = 0.5)
tm_shape(central_mexico.localMI) +
tm_fill(col = "Pr.z...0.",
breaks=c(-Inf, 0.001, 0.01, 0.05, 0.1, Inf),
palette="-Blues",
title = "local Moran's I p-values") +
tm_borders(alpha = 0.5)
From the result, we can analyse that cluster are focused in area Mexico 09.
localMI.map <- tm_shape(central_mexico.localMI) +
tm_fill(col = "Ii",
style = "pretty",
title = "local moran statistics") +
tm_borders(alpha = 0.5)
pvalue.map <- tm_shape(central_mexico.localMI) +
tm_fill(col = "Pr.z...0.",
breaks=c(-Inf, 0.001, 0.01, 0.05, 0.1, Inf),
palette="-Blues",
title = "local Moran's I p-values") +
tm_borders(alpha = 0.5)
tmap_arrange(localMI.map, pvalue.map, asp=1, ncol=2)
The Lisa cluster Map will allow us to understand the spatial autocorrelation. Firstly, I will be using the LISA cluster map to plost Moran Scatterplot.
nci <- moran.plot(central_mexico_cumu$covid_rate, rswm_q, labels=as.character(central_mexico_cumu$NOMGEO), xlab="Covid19 Rate", ylab="Spatially Lag Covid19 Rate")
From the plot, we can observe that high covid 19 rate are clustered in spatially lag convid19 Rate 600-800 to Covid 19 Rate 600 to 800
central_mexico_cumu$Z.covid_rate <- scale(central_mexico_cumu$covid_rate) %>% as.vector
nci2 <- moran.plot(central_mexico_cumu$Z.covid_rate, rswm_q, labels=as.character(central_mexico_cumu$NOMGEO), xlab="z-Covid19 Rate", ylab="Spatially Lag z-Covid19 Rate")
that scatter plot is same as the previous scatter plot. From the graph, we can understand that Xochimilco has the hight Cumul rate
quadrant <- vector(mode="numeric",length=nrow(localMI))
DV <- central_mexico_cumu$covid_rate - mean(central_mexico_cumu$covid_rate)
C_mI <- localMI[,1] - mean(localMI[,1])
signif <- 0.05
quadrant[DV >0 & C_mI>0] <- 4
quadrant[DV <0 & C_mI<0] <- 1
quadrant[DV <0 & C_mI>0] <- 2
quadrant[DV >0 & C_mI<0] <- 3
quadrant[localMI[,5]>signif] <- 0
central_mexico.localMI$quadrant <- quadrant
colors <- c("#ffffff", "#2c7bb6", "#abd9e9", "#fdae61", "#d7191c")
clusters <- c("insignificant", "low-low", "low-high", "high-low", "high-high")
tm_shape(central_mexico.localMI) +
tm_fill(col = "quadrant",
style = "cat",
palette = colors[c(sort(unique(quadrant)))+1],
labels = clusters[c(sort(unique(quadrant)))+1]) +
tm_view(set.zoom.limits = c(11,17)) +
tm_borders(alpha=0.5)
From the cold spot area analysis, I can identify that the “High-High” area is a region that has higher relative to its surroundings.
fips <- order(central_mexico$NOMGEO)
gi.adaptive <- localG(central_mexico_cumu$covid_rate, knn_lw)
mexi_combined_cumu.gi <- cbind(central_mexico_cumu, as.matrix(gi.adaptive))
names(mexi_combined_cumu.gi)[29] <- "gstat_adaptive"
tm_shape(mexi_combined_cumu.gi) +
tm_fill(col = "gstat_adaptive",
style = "pretty",
palette="-RdBu",
title = "local Gi") +
tm_borders(alpha = 0.5) + tm_text("NOMGEO", size=0.2)
From the result above, most of the highlighted areas are in blue and Mexico 09 area tend to have a red colour. This tells me Mexico 09 have higher cluster population than Mexico 15 and 17. Even though Mexico City is small, I can identify that high population lead to high covid 19 rates.
From the Gi Visualisation, the main Covdi19 affected areas are highlighted in red colour. Most of the red areas are from Mexico 09 area. According to the datasets and following visualization, Area (09), Mexico City, has demonstrated a high degree of influence from the COVID-19. As can be seen above, colors describe the weight of GI values and represent whether the highlighted region is a hotspot or a coldspot; red means hotspot, while blue indicates a coldspot. For instance, Area (09) and (15), Mexico City and Mexico State, are indicated as hotspots, due to comparatively higher population in the geographical region than Area (17) - Morelos State. Moreover, Mexico City has the highest population density of the three regions. In other words, there is a correlation between spreading virus and population - and a higher population density can lead to a more critical situation, due to COVID-19.