Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix figure in modelling vignette #130

Merged
merged 4 commits into from
Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 23 additions & 26 deletions vignettes/projecting_incidence.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ editor_options:
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,
message = FALSE,
warning = FALSE,
collapse = TRUE,
comment = "#>"
)
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE,
collapse = TRUE,
comment = "#>"
)

```

Expand Down Expand Up @@ -275,22 +276,11 @@ Now we will aggregate the simulations by day and evaluate the median
daily cases across all simulations.
```{r}
# Median daily number of cases aggregated across all simulations
median_daily_cases <- incidence_ts %>%
group_by(day) %>%
median_daily_cases <- incidence_ts_by_date %>%
group_by(date) %>%
summarise(median_cases = median(cases)) %>%
ungroup() %>%
arrange(day)

head(median_daily_cases)
```

As was done for the individual simulations, we will add a date column in the
same manner.
```{r}
# Add dates
median_daily_cases <- median_daily_cases %>%
mutate(date = index_date + days(seq(0, projection_end_day))) %>%
ungroup()
arrange(date)

head(median_daily_cases)
```
Expand All @@ -299,7 +289,7 @@ head(median_daily_cases)

We will now plot the individual simulation results alongside the median
of the aggregated results.
```{r viz, fig.cap ="COVID-19 incidence projected over a two week window. The gray lines represent individual simulations, red connected dots represent the median daily cases across all simulations, and the black triangles represent the observed data.", fig.width=6.0, fig.height=6}
```{r viz, fig.cap ="COVID-19 incidence in South Africa projected over a two week window in 2020. The light gray lines represent the individual simulations, the red line represents the median daily cases across all simulations, the black connected dots represent the observed data, and the dashed vertical line marks the beginning of the projection.", fig.width=6.0, fig.height=6}

ggplot(data = incidence_ts_by_date) +
geom_line(
Expand Down Expand Up @@ -338,19 +328,22 @@ ggplot(data = incidence_ts_by_date) +
y = cases
),
color = "black",
size = 1.75,
shape = 21
linewidth = 1
) +
scale_x_continuous(
breaks = seq(
min(incidence_ts_by_date$date),
max(incidence_ts_by_date$date),
10
5
),
labels = seq(
min(incidence_ts_by_date$date),
max(incidence_ts_by_date$date),
10
5
),
limits = c(
min(incidence_ts_by_date$date),
max(incidence_ts_by_date$date) - 4 # for a better visual look
)
) +
scale_y_continuous(
Expand All @@ -365,6 +358,10 @@ ggplot(data = incidence_ts_by_date) +
250
)
) +
labs(x = "Date", y = "Daily cases (median)")
geom_vline(
mapping = aes(xintercept = max(covid19_sa$date)),
linetype = "dashed"
) +
labs(x = "Date", y = "Daily cases")
```
## References