@@ -70,11 +70,11 @@ create_raw_table1 <- function(scores, targets) {
7070}
7171
7272print_table1 <- function (scores ) {
73- outcome_targets <- unique(scores $ outcome_target )
74- tables <- outcome_targets | >
73+ epi_targets <- unique(scores $ epi_target )
74+ tables <- epi_targets | >
7575 map(\(outcome ) {
7676 scores <- scores | >
77- filter(outcome_target == outcome )
77+ filter(epi_target == outcome )
7878 table <- create_raw_table1(scores )
7979
8080 colnames(table )[! (colnames(table ) %in% c(" Variable" , " group" ))] <-
@@ -88,8 +88,8 @@ print_table1 <- function(scores) {
8888
8989 # # merge all
9090 table1 <- tables [[1 ]]
91- if (length(outcome_targets ) > 1 ) {
92- for (i in seq(2 , length(outcome_targets ))) {
91+ if (length(epi_targets ) > 1 ) {
92+ for (i in seq(2 , length(epi_targets ))) {
9393 table1 <- inner_join(table1 , tables [[i ]], by = c(" Variable" , " group" ))
9494 }
9595 }
@@ -103,14 +103,14 @@ print_table1 <- function(scores) {
103103 starts_with(" Mean WIS (SD)_" )
104104 )
105105 # # reorder
106- for (outcome in rev(outcome_targets )) {
106+ for (outcome in rev(epi_targets )) {
107107 table1 <- table1 | >
108108 relocate(ends_with(outcome ), .after = Variable )
109109 }
110110
111111 # # build extra headers
112112 headers_to_add <- c(" " = 1 , vapply(
113- outcome_targets , \(x ) sum(grepl(paste0(" _" , x , " $" ), colnames(table1 ))),
113+ epi_targets , \(x ) sum(grepl(paste0(" _" , x , " $" ), colnames(table1 ))),
114114 1L
115115 ))
116116
@@ -139,7 +139,7 @@ print_table1 <- function(scores) {
139139plot_over_time <- function (scores , ensemble , add_plot , show_uncertainty = TRUE ) {
140140 plot_over_time_target <- scores | >
141141 # Get mean & CIs
142- group_by(target_end_date , outcome_target , CountryTargets ) | >
142+ group_by(target_end_date , epi_target , CountryTargets ) | >
143143 reframe(
144144 n = n(),
145145 mean = mean(wis , na.rm = TRUE ),
@@ -160,7 +160,7 @@ plot_over_time <- function(scores, ensemble, add_plot, show_uncertainty = TRUE)
160160 )
161161 }
162162 plot_over_time_target <- plot_over_time_target +
163- facet_wrap(~ outcome_target , scales = " free_y" ) +
163+ facet_wrap(~ epi_target , scales = " free_y" ) +
164164 scale_x_date(date_labels = " %b %Y" ) +
165165 scale_fill_manual(
166166 values = c(
@@ -180,7 +180,7 @@ plot_over_time <- function(scores, ensemble, add_plot, show_uncertainty = TRUE)
180180
181181 plot_over_time_method <- scores | >
182182 # Get mean & CIs
183- group_by(target_end_date , outcome_target , Method ) | >
183+ group_by(target_end_date , epi_target , Method ) | >
184184 reframe(
185185 n = n(),
186186 mean = mean(wis , na.rm = TRUE ),
@@ -197,7 +197,7 @@ plot_over_time <- function(scores, ensemble, add_plot, show_uncertainty = TRUE)
197197 )
198198 }
199199 plot_over_time_method <- plot_over_time_method +
200- facet_wrap(~ outcome_target , scales = " free_y" ) +
200+ facet_wrap(~ epi_target , scales = " free_y" ) +
201201 scale_x_date(date_labels = " %b %Y" ) +
202202 scale_fill_brewer(
203203 aesthetics = c(" col" , " fill" ),
@@ -229,7 +229,7 @@ plot_over_time <- function(scores, ensemble, add_plot, show_uncertainty = TRUE)
229229# Ridge plot by model --------------------
230230plot_ridges <- function (scores , target = " Deaths" ) {
231231 scores | >
232- filter(outcome_target == target ) | >
232+ filter(epi_target == target ) | >
233233 group_by(Model ) | >
234234 mutate(
235235 median_score = median(wis , na.rm = TRUE ),
@@ -258,12 +258,12 @@ plot_ridges <- function(scores, target = "Deaths") {
258258# Table of targets by model -------------
259259table_targets <- function (scores ) {
260260 table_targets <- scores | >
261- select(Model , outcome_target , forecast_date , Location ) | >
261+ select(Model , epi_target , forecast_date , Location ) | >
262262 distinct() | >
263- group_by(Model , outcome_target , forecast_date ) | >
263+ group_by(Model , epi_target , forecast_date ) | >
264264 summarise(target_count = n(), .groups = " drop" ) | >
265265 ungroup() | >
266- group_by(Model , outcome_target ) | >
266+ group_by(Model , epi_target ) | >
267267 summarise(
268268 CountryTargets = all(target_count < = 2 ),
269269 min_targets = min(target_count ),
@@ -287,20 +287,20 @@ table_metadata <- function(scores) {
287287 classification <- classify_models() | >
288288 select(Model = model , Method = classification )
289289 model_scores <- scores | >
290- group_by(Model , outcome_target ) | >
290+ group_by(Model , epi_target ) | >
291291 table_confint() | >
292- select(Model , outcome_target , Forecasts )
292+ select(Model , epi_target , Forecasts )
293293 country_targets <- table_targets(scores ) | >
294- select(Model , outcome_target , CountryTargets )
294+ select(Model , epi_target , CountryTargets )
295295 metadata_table <- classification | >
296296 left_join(model_scores ) | >
297297 mutate(Description = paste0(" [Metadata](https://raw.githubusercontent.com/covid19-forecast-hub-europe/covid19-forecast-hub-europe/main/model-metadata/" , Model , " .yml)" )) | >
298298 inner_join(country_targets ) | >
299299 mutate(
300- outcome_target = sub(" s$" , " forecasts" , outcome_target )
300+ epi_target = sub(" s$" , " forecasts" , epi_target )
301301 ) | >
302302 pivot_wider(
303- names_from = " outcome_target " ,
303+ names_from = " epi_target " ,
304304 values_from = " Forecasts" ,
305305 values_fill = " "
306306 ) | >
@@ -312,7 +312,7 @@ table_metadata <- function(scores) {
312312# Data --------------------
313313data_plot <- function (scores , log = FALSE , all = FALSE ) {
314314 data <- scores | >
315- select(Location , outcome_target , target_end_date , Incidence ) | >
315+ select(Location , epi_target , target_end_date , Incidence ) | >
316316 distinct()
317317 pop <- read_csv(here(" data" , " populations.csv" ), show_col_types = FALSE ) | >
318318 rename(Location = location )
@@ -323,7 +323,7 @@ data_plot <- function(scores, log = FALSE, all = FALSE) {
323323 log_inc = log(Incidence + 1 )
324324 )
325325 total <- data | >
326- group_by(outcome_target , target_end_date ) | >
326+ group_by(epi_target , target_end_date ) | >
327327 summarise(
328328 Incidence = sum(Incidence ),
329329 population = sum(population ),
@@ -345,7 +345,7 @@ data_plot <- function(scores, log = FALSE, all = FALSE) {
345345
346346 plot <- plot +
347347 geom_line(data = total , linewidth = ifelse(all , 2 , 1 )) +
348- facet_wrap(~ outcome_target , scales = " free" ) +
348+ facet_wrap(~ epi_target , scales = " free" ) +
349349 xlab(" " )
350350
351351 if (log ) {
0 commit comments