Skip to content

Commit

Permalink
update examples in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed Oct 19, 2023
1 parent 3c0c941 commit 21e0695
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ Calling `regional_epinow()` runs the `epinow()` on each region in turn (or in pa
```{r, message = FALSE, warning = FALSE}
estimates <- regional_epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
rt = rt_opts(prior = list(mean = 2, sd = 0.2), rw = 7),
gp = NULL,
stan = stan_opts(cores = 4, warmup = 250, samples = 1000)
Expand Down
33 changes: 16 additions & 17 deletions inst/dev/recover-synthetic/rt.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ source(here::here("inst", "dev", "recover-synthetic", "plot.R"))
old_opts <- options()
options(mc.cores = 4)

reporting_delay <- dist_spec(
mean = convert_to_logmean(2, 1), mean_sd = 0.1,
sd = convert_to_logsd(2, 1), sd_sd = 0.1, max = 15
)

#' get example delays
obs <- obs_opts(scale = list(mean = 0.1, sd = 0.025), return_likelihood = TRUE)

# fit model to data to recover realistic parameter estimates and define settings
# shared simulation settings
init <- estimate_infections(example_confirmed[1:100],
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
delays = delay_opts(example_incubation_period + example_reporting_delay),
rt = rt_opts(prior = list(mean = 2, sd = 0.1), rw = 14),
gp = NULL, horizon = 0,
obs = obs
Expand All @@ -37,7 +32,9 @@ sim_R <- sims$summarised[variable == "R"]$median

# pull out simulated cases
posterior_sample <- sims$samples[sample == 1]
sim_cases <- posterior_sample[variable == "reported_cases", .(date, confirm = value)]
sim_cases <- posterior_sample[
variable == "reported_cases", .(date, confirm = value)
]
sim_inf <- posterior_sample[variable == "infections"]$value

save_ggplot(plot(sims), "sims")
Expand All @@ -60,8 +57,8 @@ for (method in c("nuts")) {
# GP
gp[[method]] <-
estimate_infections(sim_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + example_reporting_delay),
rt = rt_opts(prior = list(mean = 2, sd = 0.25)),
stan = stanopts,
obs = obs,
Expand All @@ -75,8 +72,8 @@ for (method in c("nuts")) {
# Backcalculation
backcalc[[method]] <-
estimate_infections(sim_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + example_reporting_delay),
rt = NULL,
stan = stanopts,
obs = obs,
Expand All @@ -90,8 +87,8 @@ for (method in c("nuts")) {
# RW (weekly)
weekly_rw[[method]] <-
estimate_infections(sim_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + example_reporting_delay),
rt = rt_opts(
prior = list(mean = 2, sd = 0.25),
rw = 7
Expand All @@ -109,8 +106,8 @@ for (method in c("nuts")) {
# RW (every month) + stationary Guassian process
gp_rw[[method]] <-
estimate_infections(sim_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
example_generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + example_reporting_delay),
rt = rt_opts(
prior = list(mean = 2, sd = 0.25), rw = 14, gp_on = "R0"
),
Expand All @@ -128,8 +125,10 @@ for (method in c("nuts")) {
if (fit_daily) {
daily_rw[[method]] <-
estimate_infections(sim_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
example_generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(
example_incubation_period + example_reporting_delay
),
rt = rt_opts(
prior = list(mean = 2, sd = 0.25),
rw = 1
Expand Down

0 comments on commit 21e0695

Please sign in to comment.