An exploration of infection trends from Our World in Data, retrieved 1900 Pacific Time 22 March 2020,
library(magrittr); library(ggplot2); library(reshape2)
library(dplyr); library(ggsci)
theme_set(theme_minimal())
TV = read.csv("TVCPM.csv")
names(TV) = c("Name", "Code", "Index", 'TestsPerMillion', "CasesPerMillion")
TV$Index = TV$Index + 26
First, the relationship between testing and data. It appears that the more you test, the more you find:
TV %>% filter(CasesPerMillion > 0) %>% filter(TestsPerMillion > 0) %>%
top_n(n = 20, wt = CasesPerMillion) %>%
ggplot(aes(x= TestsPerMillion, y = CasesPerMillion, label = Code)) +
geom_text(check_overlap = TRUE, size = 3) +
scale_x_log10(name = "Tests per Million Inhabitants", labels = scales::comma) +
scale_y_log10(name = "COVID-19 Cases per Million Inhabitants",
labels = scales::comma) +
geom_label(data = TV %>% filter(Code == "USA") %>%
filter(TestsPerMillion > 0) %>% filter(CasesPerMillion > 0),
aes(x = TestsPerMillion, y = CasesPerMillion, label = Code),
color = "blue") +geom_smooth(method = 'lm', se=FALSE)
This is, of course, a complicated relationship. However, we can explore this with regression:
TV %>% filter(CasesPerMillion > 0) %>% filter(TestsPerMillion > 0) %>% group_by(Code) %>% filter(Index == max(Index)) %>% lm(CasesPerMillion~ 0 + TestsPerMillion, data = .) %>% summary() %>% broom::tidy() %>% knitr::kable()
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| TestsPerMillion | 0.0372302 | 0.002563 | 14.52623 | 0 |
Worldwide, we see about .03 cases per test, or each person tested has about a 3% chance of being positive.
TV %>% filter(Code %in% c("CHN", "IRN", "ITA", "USA", "FRA")) %>% ggplot(aes(x = Index, y = CasesPerMillion, color = Code)) + geom_point() + scale_color_futurama()
Here we accept the China data without comment. It appears that at this moment, the United states is at a critical point; will our countermeasures be effective and level off (like the reported China data), or will it experience exponential growth, like France, Italy, and Iran?