The data used is taken from https://github.com/VictimOfMaths/COVID-19/ The github source contains all the code for downloading data from their original sources and includes a very nice visualisation that combines a deprivation index with proportion of deaths through covid.
The first wave is here defined as deaths occurring in the months of March to July 2020 and the second wave deaths from August to December 2020.
The msoa data is fine grained which leads to more heterogenity than would occur whn data are aggregated over a broader spatial scale. The distribution of covid fatality per ten thousand of the population is highly skewed and more closely approximates to a log normal distribution than a symmetrical normal distribution.
ggplot(msoa_wave,aes(x=log10(covid/(pop/10000)))) + geom_histogram(fill="grey",colour="black",binwidth=0.03) + theme_bw() + facet_wrap("wave",ncol=1)
msoa %>% group_by(wave,msoa11cd) %>% summarise(All=sum(Other, na.rm=TRUE), COVID=sum(COVID, na.rm=TRUE),pop=min(pop,na.rm=TRUE) ) %>% ggplot(aes(x=All/pop,y=COVID/pop,col=wave)) + geom_point() +geom_smooth() +facet_wrap(~wave)
## `summarise()` has grouped output by 'wave'. You can override using the `.groups` argument.
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
msoa_wave %>% mutate(logcovid=log10((covid+1)/(pop/10000))) -> msoa_wave
msoa_wave %>% filter(wave=="wave1") ->w1
msoa_wave %>% filter(wave=="wave2") ->w2
msoahex %>% right_join(w1, by="msoa11cd") ->w1_geo
msoahex %>% right_join(w2, by="msoa11cd") ->w2_geo
library(RColorBrewer)
colors <- brewer.pal(7, "RdYlGn")[7:1]
qtm(backhex) +
tm_shape(w1_geo) +
tm_fill("logcovid", palette = colors, midpoint = NA) + tm_borders(lwd = 0)
ww<-merge(w1,house_prices)
ggplot(ww,aes(x=log10(price),y=logcovid)) +geom_point(size=0.1) + geom_smooth(method="lm")
## `geom_smooth()` using formula 'y ~ x'
ww<-merge(w1,house_prices)
ggplot(ww,aes(x=log10(price),y=logcovid,col=RegionNation)) +geom_point(size=0.1) + geom_smooth(method="lm") + facet_wrap(~RegionNation)
## `geom_smooth()` using formula 'y ~ x'
#mapview(w1_geo)
qtm(backhex) +
tm_shape(w2_geo) +
tm_fill("logcovid", palette = colors, midpoint = NA) + tm_borders(lwd = 0)
ww<-merge(w2,house_prices)
ggplot(ww,aes(x=log10(price),y=logcovid)) +geom_point(size=0.01) + geom_smooth(method="lm")
## `geom_smooth()` using formula 'y ~ x'
ww<-merge(w2,house_prices)
ggplot(ww,aes(x=log10(price),y=logcovid,col=RegionNation)) +geom_point(size=0.01) + geom_smooth(method="lm") + facet_wrap(~RegionNation)
## `geom_smooth()` using formula 'y ~ x'
#mapview(w2_geo,zcol="logcovid")
las_wave %>% filter(wave=="wave1") ->w1
las_wave %>% filter(wave=="wave2") ->w2
lashex %>% right_join(w1, by="Lacode") ->w1_geo
lashex %>% right_join(w2, by="Lacode") ->w2_geo
qtm(backhex) +
tm_shape(w1_geo) +
tm_fill("logcovid", palette = colors, midpoint = NA) + tm_borders(lwd = 0)
qtm(backhex) +
tm_shape(w2_geo) +
tm_fill("logcovid", palette = colors, midpoint = NA) + tm_borders(lwd = 0)
las_wave %>% pivot_wider(c(1,2,8),names_from=wave,values_from=logcovid) %>%
ggplot(aes(x=wave1,y=wave2)) +geom_point() +geom_smooth(method="lm")
## `geom_smooth()` using formula 'y ~ x'