Skip to content

Commit 2d366dc

Browse files
kathsherrattsbfnk
andauthored
Update descriptive.R (#73)
- Drop horizon and trend from table 1 - Switch to showing Mean (SD) - minor text change to table caption Co-authored-by: Sebastian Funk <sebastian.funk@lshtm.ac.uk>
1 parent b4d59f2 commit 2d366dc

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

R/descriptive.R

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,12 @@ table_confint <- function(scores, group_var = NULL) {
4343
n_models = n_distinct(Model),
4444
p_models = round(n_models / total_models * 100, 1),
4545
mean = mean(wis, na.rm = TRUE),
46-
ci = calc_ci(wis, na.rm = TRUE, R = 1000)
46+
sd = sd(wis, na.rm = TRUE)
4747
) |>
48-
unnest(ci) |>
4948
mutate(
5049
Models = paste0(n_models, " (", p_models, "%)"),
5150
Forecasts = paste0(n_forecasts, " (", p_forecasts, "%)"),
52-
"Mean WIS (95% CI)" = paste0(
53-
round(mean, 2), " (",
54-
round(lboot, 2), "-", round(uboot, 2), ")"
55-
)
51+
"Mean WIS (SD)" = paste0(round(mean, 2), " (", round(sd, 2), ")")
5652
)
5753

5854
if (!is.null(group_var)) {
@@ -68,12 +64,8 @@ create_raw_table1 <- function(scores, targets) {
6864
mutate(Variable = "Overall", group = "")
6965
method <- table_confint(scores, "Method")
7066
targets <- table_confint(scores, "CountryTargets")
71-
horizon <- table_confint(scores, "Horizon") |>
72-
filter(!is.na(Variable))
73-
trend <- table_confint(scores, "Trend")
7467
bind_rows(
75-
overall, method, targets,
76-
horizon, trend
68+
overall, method, targets
7769
)
7870
}
7971

@@ -108,7 +100,7 @@ print_table1 <- function(scores) {
108100
Variable,
109101
starts_with("Models_"),
110102
starts_with("Forecasts_"),
111-
starts_with("Mean WIS (95% CI)_")
103+
starts_with("Mean WIS (SD)_")
112104
)
113105
## reorder
114106
for (outcome in rev(outcome_targets)) {
@@ -127,20 +119,18 @@ print_table1 <- function(scores) {
127119
kable(
128120
caption = paste0(
129121
"Characteristics of forecasts sampled from ",
130-
"the European COVID-19 Forecast Hub, March 2021-2023.",
131-
"Each forecast was scored for accuracy using the weighted ",
132-
"interval score (WIS), summarised by the mean ",
133-
"with bootstrapped 95% confidence interval."
122+
"the European COVID-19 Forecast Hub, March 2021-2023. ",
123+
"Forecast performance was measured using the weighted ",
124+
"interval score (WIS), with a lower score indicating a more ",
125+
"accurate forecast."
134126
),
135127
col.names = str_remove(colnames(table1), "_.*$"),
136128
align = c("l", rep("r", ncol(table1) - 1))
137129
) |>
138130
pack_rows(index = c(
139131
" " = 1,
140132
"Method" = 5,
141-
"Number of country targets" = 2,
142-
"Week ahead horizon" = 4,
143-
"3-week trend in incidence" = 3
133+
"Number of country targets" = 2
144134
)) |>
145135
add_header_above(headers_to_add)
146136
}

0 commit comments

Comments
 (0)