diff --git a/R/epinow.R b/R/epinow.R index 6ca1fd078..b9edc5538 100644 --- a/R/epinow.R +++ b/R/epinow.R @@ -56,7 +56,11 @@ #' ) #' # set an example reporting delay. In practice this should use an estimate #' # from the literature or be estimated from data -#' reporting_delay <- LogNormal(mean = 2, sd = 1, max = 10) +#' reporting_delay <- LogNormal( +#' meanlog = Fixed(2), +#' sdlog = Fixed(1), +#' max = 10 +#' ) #' #' # example case data #' reported_cases <- example_confirmed[1:40] diff --git a/R/estimate_infections.R b/R/estimate_infections.R index 1d5b5f004..da59d7156 100644 --- a/R/estimate_infections.R +++ b/R/estimate_infections.R @@ -101,7 +101,11 @@ #' ) #' # set an example reporting delay. In practice this should use an estimate #' # from the literature or be estimated from data -#' reporting_delay <- LogNormal(mean = 2, sd = 1, max = 10) +#' reporting_delay <- LogNormal( +#' meanlog = Fixed(2), +#' sdlog = Fixed(1), +#' max = 10 +#' ) #' #' # for more examples, see the "estimate_infections examples" vignette #' def <- estimate_infections(reported_cases, diff --git a/R/regional_epinow.R b/R/regional_epinow.R index a5f08d062..e88e8ebf7 100644 --- a/R/regional_epinow.R +++ b/R/regional_epinow.R @@ -79,11 +79,16 @@ #' data = cases, #' generation_time = gt_opts(example_generation_time), #' delays = delay_opts(example_incubation_period + example_reporting_delay), -#' rt = rt_opts(prior = LogNormal(mean = 2, sd = 0.2)), -#' stan = stan_opts( -#' samples = 100, warmup = 200 -#' ), -#' verbose = interactive() +#' rt = rt_opts( +#' prior = LogNormal( +#' meanlog = Fixed(2), +#' sdlog = Fixed(0.2) +#' ), +#' stan = stan_opts( +#' samples = 100, warmup = 200 +#' ), +#' verbose = interactive() +#' ) #' ) #' options(old_opts) #' } diff --git a/R/simulate_infections.R b/R/simulate_infections.R index f3b66cc3f..beebe3cc5 100644 --- a/R/simulate_infections.R +++ b/R/simulate_infections.R @@ -277,7 +277,12 @@ simulate_infections <- function(estimates, R, initial_infections, #' est <- estimate_infections(reported_cases, #' generation_time = generation_time_opts(example_generation_time), #' delays = delay_opts(example_incubation_period + example_reporting_delay), -#' rt = rt_opts(prior = LogNormal(mean = 2, sd = 0.1), rw = 7), +#' rt = rt_opts(prior = LogNormal( +#' meanlog = Fixed(2), +#' sdlog = Fixed(0.1) +#' ), +#' rw = 7 +#' ), #' obs = obs_opts(scale = Normal(mean = 0.1, sd = 0.01)), #' gp = NULL, horizon = 0 #' ) diff --git a/man/epinow.Rd b/man/epinow.Rd index bfe6dc102..c1973bdb7 100644 --- a/man/epinow.Rd +++ b/man/epinow.Rd @@ -157,7 +157,11 @@ incubation_period <- LogNormal( ) # set an example reporting delay. In practice this should use an estimate # from the literature or be estimated from data -reporting_delay <- LogNormal(mean = 2, sd = 1, max = 10) +reporting_delay <- LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(1), + max = 10 +) # example case data reported_cases <- example_confirmed[1:40] diff --git a/man/estimate_infections.Rd b/man/estimate_infections.Rd index 0372966a0..e65d0f6d3 100644 --- a/man/estimate_infections.Rd +++ b/man/estimate_infections.Rd @@ -146,7 +146,11 @@ incubation_period <- LogNormal( ) # set an example reporting delay. In practice this should use an estimate # from the literature or be estimated from data -reporting_delay <- LogNormal(mean = 2, sd = 1, max = 10) +reporting_delay <- LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(1), + max = 10 +) # for more examples, see the "estimate_infections examples" vignette def <- estimate_infections(reported_cases, diff --git a/man/forecast_infections.Rd b/man/forecast_infections.Rd index 24c5b2c5d..23ceac66d 100644 --- a/man/forecast_infections.Rd +++ b/man/forecast_infections.Rd @@ -65,7 +65,12 @@ reported_cases <- example_confirmed[1:50] est <- estimate_infections(reported_cases, generation_time = generation_time_opts(example_generation_time), delays = delay_opts(example_incubation_period + example_reporting_delay), - rt = rt_opts(prior = LogNormal(mean = 2, sd = 0.1), rw = 7), + rt = rt_opts(prior = LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(0.1) + ), + rw = 7 + ), obs = obs_opts(scale = Normal(mean = 0.1, sd = 0.01)), gp = NULL, horizon = 0 ) diff --git a/man/regional_epinow.Rd b/man/regional_epinow.Rd index 6eca0c83a..20b9ee734 100644 --- a/man/regional_epinow.Rd +++ b/man/regional_epinow.Rd @@ -156,11 +156,16 @@ def <- regional_epinow( data = cases, generation_time = gt_opts(example_generation_time), delays = delay_opts(example_incubation_period + example_reporting_delay), - rt = rt_opts(prior = LogNormal(mean = 2, sd = 0.2)), - stan = stan_opts( - samples = 100, warmup = 200 - ), - verbose = interactive() + rt = rt_opts( + prior = LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(0.2) + ), + stan = stan_opts( + samples = 100, warmup = 200 + ), + verbose = interactive() + ) ) options(old_opts) } diff --git a/vignettes/EpiNow2.Rmd.orig b/vignettes/EpiNow2.Rmd.orig index 69d10bcdd..f2df29bc8 100644 --- a/vignettes/EpiNow2.Rmd.orig +++ b/vignettes/EpiNow2.Rmd.orig @@ -50,7 +50,11 @@ If data was not available we could instead specify an informed estimate of the l To demonstrate, we choose a lognormal distribution with mean 2, standard deviation 1 and a maximum of 10. *This is just an example and unlikely to apply in any particular use case*. ```{r} -reporting_delay <- LogNormal(mean = 2, sd = 1, max = 10) +reporting_delay <- LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(1), + max = 10 +) reporting_delay ``` @@ -94,7 +98,10 @@ estimates <- epinow( data = reported_cases, generation_time = gt_opts(example_generation_time), delays = delay_opts(example_incubation_period + reporting_delay), - rt = rt_opts(prior = LogNormal(mean = 2, sd = 0.2)), + rt = rt_opts(prior = LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(0.2) + )), stan = stan_opts(cores = 4, control = list(adapt_delta = 0.99)), verbose = interactive() ) @@ -148,7 +155,13 @@ estimates <- regional_epinow( data = reported_cases, generation_time = gt_opts(example_generation_time), delays = delay_opts(example_incubation_period + reporting_delay), - rt = rt_opts(prior = LogNormal(mean = 2, sd = 0.2), rw = 7), + rt = rt_opts( + prior = LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(0.2) + ), + rw = 7 + ), gp = NULL, stan = stan_opts(cores = 4, warmup = 250, samples = 1000) ) diff --git a/vignettes/epinow.Rmd.orig b/vignettes/epinow.Rmd.orig index d8960bfbd..ab7726db6 100644 --- a/vignettes/epinow.Rmd.orig +++ b/vignettes/epinow.Rmd.orig @@ -38,9 +38,16 @@ This should be replaced with parameters relevant to the system that is being stu library("EpiNow2") options(mc.cores = 4) reported_cases <- example_confirmed[1:60] -reporting_delay <- LogNormal(mean = 2, sd = 1, max = 10) +reporting_delay <- LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(1), + max = 10 +) delay <- example_incubation_period + reporting_delay -rt_prior <- LogNormal(mean = 2, sd = 0.1) +rt_prior <- LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(0.1) +) ``` We can then run the `epinow()` function with the same arguments as `estimate_infections()`. diff --git a/vignettes/estimate_infections_options.Rmd.orig b/vignettes/estimate_infections_options.Rmd.orig index 25706703e..08067ca2d 100644 --- a/vignettes/estimate_infections_options.Rmd.orig +++ b/vignettes/estimate_infections_options.Rmd.orig @@ -73,7 +73,11 @@ For the reporting delay, we use a lognormal distribution with mean of 2 days and Note that the mean and standard deviation must be converted to the log scale, which can be done using the `convert_log_logmean()` function. ```{r reporting_delay} -reporting_delay <- LogNormal(mean = 2, sd = 1, max = 10) +reporting_delay <- LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(1), + max = 10 +) reporting_delay ``` @@ -97,7 +101,10 @@ example_generation_time Lastly we need to choose a prior for the initial value of the reproduction number. This is assumed by the model to be normally distributed and we can set the mean and the standard deviation. We decide to set the mean to 2 and the standard deviation to 1. ```{r initial_r} -rt_prior <- LogNormal(mean = 2, sd = 0.1) +rt_prior <- LogNormal( + meanlog = Fixed(2), + sdlog = Fixed(0.1) +) ``` # Running the model @@ -172,8 +179,8 @@ Here, instead of doing so we assume that we know about truncation with mean of 1 ```{r define_truncation} trunc_dist <- LogNormal( - mean = Normal(0.5, 0.1), - sd = Normal(0.5, 0.1), + meanlog = Normal(0.5, 0.1), + sdlog = Normal(0.5, 0.1), max = 3 ) trunc_dist diff --git a/vignettes/estimate_infections_workflow.Rmd.orig b/vignettes/estimate_infections_workflow.Rmd.orig index 2c8f48a19..59485840a 100644 --- a/vignettes/estimate_infections_workflow.Rmd.orig +++ b/vignettes/estimate_infections_workflow.Rmd.orig @@ -79,7 +79,7 @@ In all cases, the distributions given can be *fixed* (i.e. have no uncertainty) For example, to define a fixed gamma distribution with mean 3, standard deviation (sd) 1 and maximum value 10, you would write ```{r} -fixed_gamma <- Gamma(mean = 3, sd = 1, max = 10) +fixed_gamma <- Gamma(shape = 3, rate = 1, max = 10) fixed_gamma ``` @@ -93,7 +93,7 @@ If distributions are variable, the values with uncertainty are treated as [prior For example, to define a variable gamma distribution where uncertainty in the mean is given by a normal distribution with mean 3 and sd 2, and uncertainty in the standard deviation is given by a normal distribution with mean 1 and sd 0.1, with a maximum value 10, you would write ```{r} -uncertain_gamma <- Gamma(mean = Normal(3, 2), sd = Normal(1, 0.1), max = 10) +uncertain_gamma <- Gamma(shape = Normal(3, 2), rate = Normal(1, 0.1), max = 10) uncertain_gamma ``` @@ -209,7 +209,7 @@ It can be changed using the `rt_opts()` function. For example, if the user believes that at the very start of the data the reproduction number was 2, with uncertainty in this belief represented by a standard deviation of 1, they would use ```{r results = 'hide'} -rt_prior <- LogNormal(mean = 2, sd = 1) +rt_prior <- LogNormal(meanlog = Fixed(2), sdlog = Fixed(1)) rt_opts(prior = rt_prior) ```