Skip to content

Commit

Permalink
homogenize epinow2 code interface with quantify Rt
Browse files Browse the repository at this point in the history
  • Loading branch information
avallecam committed Mar 21, 2024
1 parent 9a7ec2a commit b9b836b
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions episodes/delays-functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ generation_time <- dist_spec(

In this episode, we will use the **distribution functions** that `{epiparameter}` provides to get a `max` value for this and any other package downstream in the pipeline!

Let's load the `{epiparameter}` and `{EpiNow2}` package. We'll use the pipe `%>%`, some `{dplyr}` verbs and `{ggplot2}`, so let's also call to the `{tidyverse}` package:
Let's load the `{epiparameter}` and `{EpiNow2}` package. For `{EpiNow2}`, we'll set 4 cores to be used in parallel computations. We'll use the pipe `%>%`, some `{dplyr}` verbs and `{ggplot2}`, so let's also call to the `{tidyverse}` package:

```{r,warning=FALSE,message=FALSE}
library(epiparameter)
library(EpiNow2)
library(tidyverse)
withr::local_options(list(mc.cores = 4))
```

## Distribution functions
Expand Down Expand Up @@ -376,12 +378,7 @@ epinow_estimates <- epinow(
# cases
reported_cases = example_confirmed[1:60],
# delays
generation_time = generation_time_opts(serial_interval_covid),
# computation
stan = stan_opts(
cores = 4, samples = 1000, chains = 3,
control = list(adapt_delta = 0.99)
)
generation_time = generation_time_opts(serial_interval_covid)
)
base::plot(epinow_estimates)
Expand Down Expand Up @@ -457,12 +454,7 @@ epinow_estimates <- epinow(
# cases
reported_cases = ebola_confirmed,
# delays
generation_time = generation_time_opts(serial_interval_ebola),
# computation
stan = stan_opts(
cores = 4, samples = 1000, chains = 3,
control = list(adapt_delta = 0.99)
)
generation_time = generation_time_opts(serial_interval_ebola)
)
plot(epinow_estimates)
Expand Down Expand Up @@ -505,12 +497,7 @@ epinow_estimates <- epinow(
reported_cases = example_confirmed[1:60],
# delays
generation_time = generation_time_opts(covid_serial_interval),
delays = delay_opts(covid_incubation_time),
# computation
stan = stan_opts(
cores = 4, samples = 1000, chains = 3,
control = list(adapt_delta = 0.99)
)
delays = delay_opts(covid_incubation_time)
)
```

Expand Down Expand Up @@ -570,12 +557,7 @@ epinow_estimates <- epinow(
reported_cases = example_confirmed[1:60],
# delays
generation_time = generation_time_opts(covid_serial_interval),
delays = delay_opts(covid_incubation_time),
# computation
stan = stan_opts(
cores = 4, samples = 1000, chains = 3,
control = list(adapt_delta = 0.99)
)
delays = delay_opts(covid_incubation_time)
)
base::plot(epinow_estimates)
Expand Down Expand Up @@ -679,12 +661,7 @@ epinow_estimates <- epinow(
reported_cases = ebola_confirmed,
# delays
generation_time = generation_time_opts(serial_interval_ebola),
delays = delay_opts(incubation_period_ebola),
# computation
stan = stan_opts(
cores = 4, samples = 1000, chains = 3,
control = list(adapt_delta = 0.99)
)
delays = delay_opts(incubation_period_ebola)
)
plot(epinow_estimates)
Expand Down

0 comments on commit b9b836b

Please sign in to comment.