From 0bf9d9c0f8807c5c970828f1e2495d12d3e0d374 Mon Sep 17 00:00:00 2001 From: Sebastian Funk Date: Thu, 9 Feb 2023 17:51:40 +0000 Subject: [PATCH] update touchstone setup --- touchstone/.gitignore | 1 + touchstone/script.R | 58 +++++++++++++++++++++---------------------- touchstone/setup.R | 18 ++++++++++++++ 3 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 touchstone/setup.R diff --git a/touchstone/.gitignore b/touchstone/.gitignore index ee8eacf09..8ca6a88d0 100644 --- a/touchstone/.gitignore +++ b/touchstone/.gitignore @@ -1,4 +1,5 @@ * +!setup.R !script.R !config.json !.gitignore diff --git a/touchstone/script.R b/touchstone/script.R index 3c0f72cf3..ea24a4ad8 100644 --- a/touchstone/script.R +++ b/touchstone/script.R @@ -9,80 +9,80 @@ touchstone::branch_install() # benchmnark README example touchstone::benchmark_run( - expr_before_benchmark = 'source("touchstone/setup.R")', - default = 'epinow( + expr_before_benchmark = { source("touchstone/setup.R") }, + default = { epinow( reported_cases = reported_cases, - generation_time = generation_time_opts(generation_time), + generation_time = generation_time, delays = delay_opts(incubation_period, reporting_delay), rt = rt_opts(prior = list(mean = 2, sd = 0.2)), stan = stan_opts( cores = 2, samples = 500, chains = 2, - control = list(adapt_delta = 0.95)), + control = list(adapt_delta = 0.95), seed = 5339), verbose = interactive() - )', - n = 2 + ) }, + n = 1 ) # benchmark readme example with uncertain delays and gt touchstone::benchmark_run( - expr_before_benchmark = 'source("touchstone/setup.R")', - uncertain = 'epinow( + expr_before_benchmark = { source("touchstone/setup.R") }, + uncertain = { epinow( reported_cases = reported_cases, generation_time = generation_time_opts(ugeneration_time), delays = delay_opts(uincubation_period, reporting_delay), rt = rt_opts(prior = list(mean = 2, sd = 0.2)), stan = stan_opts( cores = 2, samples = 500, chains = 2, - control = list(adapt_delta = 0.95)), + control = list(adapt_delta = 0.95), seed = 5339), verbose = interactive() - )', - n = 2 + ) }, + n = 1 ) # benchmark readme example without delays touchstone::benchmark_run( - expr_before_benchmark = 'source("setup.R")', - no_delays = 'epinow( + expr_before_benchmark = { source("touchstone/setup.R") }, + no_delays = { epinow( reported_cases = reported_cases, - generation_time = generation_time_opts(generation_time), + generation_time = generation_time, rt = rt_opts(prior = list(mean = 2, sd = 0.2)), stan = stan_opts( cores = 2, samples = 500, chains = 2, - control = list(adapt_delta = 0.95)), + control = list(adapt_delta = 0.95), seed = 5339), verbose = interactive() - )', - n = 2 + ) }, + n = 1 ) # benchmark readme example with a stationary GP touchstone::benchmark_run( - expr_before_benchmark = 'source("setup.R")', - stationary = 'epinow( + expr_before_benchmark = { source("touchstone/setup.R") }, + stationary = { epinow( reported_cases = reported_cases, - generation_time = generation_time_opts(generation_time), + generation_time = generation_time, rt = rt_opts(prior = list(mean = 2, sd = 0.2), gp_on = "R0"), stan = stan_opts( cores = 2, samples = 500, chains = 2, - control = list(adapt_delta = 0.95)), + control = list(adapt_delta = 0.95), seed = 5339), verbose = interactive() - )', - n = 2 + ) }, + n = 1 ) # benchmark readme example with a weekly random walk touchstone::benchmark_run( - expr_before_benchmark = 'source("touchstone/setup.R")', - random_walk = 'epinow( + expr_before_benchmark = { source("touchstone/setup.R") }, + random_walk = { epinow( reported_cases = reported_cases, - generation_time = generation_time_opts(generation_time), + generation_time = generation_time, rt = rt_opts(prior = list(mean = 2, sd = 0.2), rw = 7), gp = NULL, stan = stan_opts( cores = 2, samples = 500, chains = 2, - control = list(adapt_delta = 0.95)), + control = list(adapt_delta = 0.95), seed = 5339), verbose = interactive() - )', - n = 2 + ) }, + n = 1 ) # create artifacts used downstream in the GitHub Action diff --git a/touchstone/setup.R b/touchstone/setup.R new file mode 100644 index 000000000..3a0d05621 --- /dev/null +++ b/touchstone/setup.R @@ -0,0 +1,18 @@ +library("EpiNow2") + +reported_cases <- example_confirmed[1:60] + +# set up example generation time +generation_time <- generation_time_opts( + disease = "SARS-CoV-2", source = "ganyani", fixed = TRUE +) + +# set delays between infection and case report +incubation_period <- get_incubation_period( + disease = "SARS-CoV-2", source = "lauer" +) + +reporting_delay <- list( + mean = convert_to_logmean(2, 1), mean_sd = 0, + sd = convert_to_logsd(2, 1), sd_sd = 0, max = 10 +)