Skip to content

Commit 650d4f9

Browse files
authored
add new infections argument when vaccination
1 parent fa3de06 commit 650d4f9

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

episodes/modelling-interventions.Rmd

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ vaccinate <- vaccination(
378378
)
379379
```
380380

381-
We pass our vaccination object into the model using argument `vaccination = vaccinate`:
381+
We pass our vaccination object into the model using the argument `vaccination = vaccinate`:
382382

383383
```{r output_vaccinate}
384384
output_vaccinate <- model_default(
@@ -434,12 +434,51 @@ output %>%
434434
)
435435
```
436436

437-
From the plot we see that the peak number of total number of infectious individuals when vaccination is in place is much lower compared to school closures and mask wearing interventions.
437+
From the plot, we see that the peak number of total number of infectious individuals when vaccination is in place is much lower compared to school closures and mask-wearing interventions.
438438

439439
:::::::::::::::::::::::::::::::::
440440
::::::::::::::::::::::::::::::::::::::::::::::::
441441

442+
Lastly, if you are interested in plotting the trajectory of new infections from an `epidemics::model_default()` with a `vaccination` intervention, you need to specify one additional argument.
443+
At `epidemics::new_infections()` specify `compartments_from_susceptible = "vaccinated"` to name the model compartments into which individuals transition from the "susceptible" compartment, and which are not related to infection. In the scenario above, "vaccinated" individuals who are no longer susceptible should not be counted as infected.
442444

445+
::::::::::::::::::::: spoiler
446+
447+
Notice that if we use `by_group = FALSE` in `epidemics::new_infections()`, we get a summary of the new infections in all demographic groups.
448+
Try keeping the default `by_group = TRUE` and adding `linetype = demography_group` when declaring variables in `ggplot(aes(...))`.
449+
450+
```{r}
451+
infections_baseline <- epidemics::new_infections(
452+
data = output_baseline,
453+
compartments_from_susceptible = "vaccinated", # if vaccination
454+
by_group = FALSE
455+
)
456+
457+
infections_intervention <- epidemics::new_infections(
458+
data = output_vaccinate,
459+
compartments_from_susceptible = "vaccinated", # if vaccination
460+
by_group = FALSE
461+
)
462+
463+
# Assign scenario names
464+
infections_baseline$scenario <- "Baseline"
465+
infections_intervention$scenario <- "Vaccination"
466+
467+
# Combine the data from both scenarios
468+
infections_baseline_intervention <- dplyr::bind_rows(infections_baseline, infections_intervention)
469+
470+
infections_baseline_intervention %>%
471+
ggplot(aes(x = time, y = new_infections, colour = scenario)) +
472+
geom_line() +
473+
geom_vline(
474+
xintercept = c(vaccinate$time_begin, vaccinate$time_end),
475+
linetype = "dashed",
476+
linewidth = 0.2
477+
) +
478+
scale_y_continuous(labels = scales::comma)
479+
```
480+
481+
:::::::::::::::::::::
443482

444483

445484
## Summary

0 commit comments

Comments
 (0)