-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f98e32
commit d5fe820
Showing
27 changed files
with
647 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Raw case count features | ||
source("data/get-uk-data.R") | ||
|
||
data <- as.data.frame(data) | ||
|
||
data_regional <- split(data, data$region) | ||
|
||
# Mean difference between counts | ||
data_diffs <- purrr::map(data_regional, ~ | ||
dplyr::mutate(., | ||
diff_case_death = .$cases_blend - .$deaths_blend, | ||
diff_case_hosp = .$cases_blend - .$cases_hosp, | ||
diff_hosp_death = .$cases_hosp - .$deaths_blend, | ||
index = seq_len(nrow(.))) %>% | ||
dplyr::filter(date <= as.Date("2020-08-10"))) | ||
|
||
data_mean <- data_diffs %>% | ||
purrr::keep(names(.) %in% region_names$nhsregions) %>% | ||
purrr::transpose() %>% | ||
purrr::keep(names(.) %in% c("diff_case_death", "diff_case_hosp", "diff_hosp_death")) %>% | ||
purrr::map_depth(.depth = 2, t.test, na.rm=T) %>% | ||
purrr::map_depth(.depth = 2, ~ purrr::keep(., names(.) %in% c("estimate"))) %>% | ||
purrr::map_depth(.depth = 2, ~ dplyr::bind_rows(.)) %>% | ||
dplyr::bind_rows(., .id = "id") | ||
|
||
data_mean_min <- tidyr::pivot_longer(data_mean, cols = -id, values_to = "mean") %>% | ||
dplyr::group_by(id) %>% | ||
dplyr::filter(mean == min(mean)) | ||
|
||
data_mean_max <- tidyr::pivot_longer(data_mean, cols = -id, values_to = "mean") %>% | ||
dplyr::group_by(id) %>% | ||
dplyr::filter(mean == max(mean)) | ||
|
||
# Waves | ||
|
||
source("compare/wave-features.R") | ||
|
||
data_wave <- list( | ||
cases = purrr::map(data_regional, ~ wave_features(.x, "cases_blend", 7)), | ||
hosp = purrr::map(data_regional, ~ wave_features(.x, "cases_hosp", 7)), | ||
deaths = purrr::map(data_regional, ~ wave_features(.x, "deaths_blend", 7))) | ||
|
||
data_wave <- data_wave %>% | ||
purrr::transpose() %>% | ||
purrr::discard(.p = names(.) %in% c("Scotland", "Wales", "Northern Ireland")) | ||
|
||
|
||
|
||
# Test positivity --------------------------------------------------------- | ||
|
||
t.test(pos_tests[pos_tests$region == "Midlands", "pos_perc"]) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Ratio summary statistics | ||
summary_wide <- readRDS("rt-estimate/summary_wide.rds") | ||
|
||
library(dplyr) | ||
|
||
summary_ratio <- summary_wide | ||
#summary_ratio <- dplyr::filter(summary_ratio, date >= as.Date("2020-06-26")) | ||
summary_ratio <- split(summary_wide, summary_wide$region) | ||
|
||
caseb_deathb_med <- summary_ratio %>% | ||
purrr::map( ~ t.test(.x$caseb_deathb_med)) %>% | ||
purrr::transpose() %>% | ||
purrr::keep(., .p = names(.) %in% c("estimate", "conf.int")) %>% | ||
purrr::transpose() | ||
|
||
caseb_hosp_med <- summary_ratio %>% | ||
purrr::map( ~ t.test(.x$caseb_hosp_med)) %>% | ||
purrr::transpose() %>% | ||
purrr::keep(., .p = names(.) %in% c("estimate", "conf.int")) %>% | ||
purrr::transpose() | ||
|
||
hosp_deathb_med <- summary_ratio %>% | ||
purrr::map( ~ t.test(.x$hosp_deathb_med)) %>% | ||
purrr::transpose() %>% | ||
purrr::keep(., .p = names(.) %in% c("estimate", "conf.int")) %>% | ||
purrr::transpose() | ||
|
||
|
||
median <- dplyr::select(summary_wide, date, region, dplyr::starts_with("median")) | ||
lower90 <- dplyr::select(summary_wide, date, region, dplyr::starts_with("lower_90")) | ||
upper90 <- dplyr::select(summary_wide, date, region, dplyr::starts_with("upper_90")) |
Oops, something went wrong.