Skip to content

Commit

Permalink
update max in defaults/examples/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed Oct 4, 2023
1 parent 9065ab4 commit 6b1573c
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 59 deletions.
8 changes: 4 additions & 4 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ get_regional_results <- function(regional_output,
#'
#' @param source A character string indicating the source of interest.
#'
#' @param max_value Numeric, the maximum value to allow. Defaults to 15 days.
#' @param max_value Numeric, the maximum value to allow. Defaults to 14 days.
#'
#' @param fixed Logical, defaults to `FALSE`. Should distributions be supplied
#' as fixed values (vs with uncertainty)?
Expand All @@ -182,7 +182,7 @@ get_regional_results <- function(regional_output,
#' get_dist(
#' EpiNow2::generation_times, disease = "SARS-CoV-2", source = "ganyani"
#' )
get_dist <- function(data, disease, source, max_value = 15, fixed = FALSE) {
get_dist <- function(data, disease, source, max_value = 14, fixed = FALSE) {
target_disease <- disease
target_source <- source
data <- data[disease == target_disease][source == target_source]
Expand All @@ -204,7 +204,7 @@ get_dist <- function(data, disease, source, max_value = 15, fixed = FALSE) {
#' @author Sam Abbott
#' @examples
#' get_generation_time(disease = "SARS-CoV-2", source = "ganyani")
get_generation_time <- function(disease, source, max_value = 15,
get_generation_time <- function(disease, source, max_value = 14,
fixed = FALSE) {
dist <- get_dist(EpiNow2::generation_times,
disease = disease, source = source,
Expand All @@ -224,7 +224,7 @@ get_generation_time <- function(disease, source, max_value = 15,
#' @export
#' @examples
#' get_incubation_period(disease = "SARS-CoV-2", source = "lauer")
get_incubation_period <- function(disease, source, max_value = 15,
get_incubation_period <- function(disease, source, max_value = 14,
fixed = FALSE) {
dist <- get_dist(EpiNow2::incubation_periods,
disease = disease, source = source,
Expand Down
10 changes: 5 additions & 5 deletions R/opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
#' generation_time_opts()
#'
#' # A fixed gamma distributed generation time
#' generation_time_opts(dist_spec(mean = 3, sd = 2, max = 15))
#' generation_time_opts(dist_spec(mean = 3, sd = 2, max = 14))
#'
#' # An uncertain gamma distributed generation time
#' generation_time_opts(
#' dist_spec(mean = 3, sd = 2, mean_sd = 1, sd_sd = 0.5, max = 15)
#' dist_spec(mean = 3, sd = 2, mean_sd = 1, sd_sd = 0.5, max = 14)
#' )
#'
#' # A generation time sourced from the literature
#' dist <- get_generation_time(disease = "SARS-CoV-2", source = "ganyani")
#' generation_time_opts(dist)
generation_time_opts <- function(dist = dist_spec(mean = 1), ...,
disease, source, max = 15L, fixed = FALSE,
disease, source, max = 14, fixed = FALSE,
prior_weight) {
deprecated_options_given <- FALSE
dot_options <- list(...)
Expand Down Expand Up @@ -120,11 +120,11 @@ generation_time_opts <- function(dist = dist_spec(mean = 1), ...,
#' delay_opts()
#'
#' # A single delay that has uncertainty
#' delay <- dist_spec(mean = 1, mean_sd = 0.2, sd = 0.5, sd_sd = 0.1, max = 15)
#' delay <- dist_spec(mean = 1, mean_sd = 0.2, sd = 0.5, sd_sd = 0.1, max = 14)
#' delay_opts(delay)
#'
#' # A single delay without uncertainty
#' delay <- dist_spec(mean = 1, sd = 0.5, max = 15)
#' delay <- dist_spec(mean = 1, sd = 0.5, max = 14)
#' delay_opts(delay)
#'
#' # Multiple delays (in this case twice the same)
Expand Down
2 changes: 1 addition & 1 deletion R/simulate_infections.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#' )
#' 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
#' sd = convert_to_logsd(2, 1), sd_sd = 0.1, max = 14
#' )
#'
#' # fit model to data to recover Rt estimates
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ For example if data on the delay between onset and infection was available we co
```{r, eval = FALSE}
reporting_delay <- estimate_delay(
rlnorm(1000, log(2), 1),
max_value = 15, bootstraps = 1
max_value = 14, bootstraps = 1
)
```

Expand Down
4 changes: 2 additions & 2 deletions man/delay_opts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/generation_time_opts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/get_dist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/get_generation_time.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/get_incubation_period.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/simulate_infections.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/test-delays.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test_that("generation times can be specified in different ways", {
)
expect_equal(
round(test_stan_delays(
generation_time = generation_time_opts(dist_spec(mean = 3, sd = 1, max = 5)),
generation_time = generation_time_opts(dist_spec(mean = 3, sd = 1, max = 4)),
params = delay_params
), digits = 2),
c(0.02, 0.11, 0.22, 0.30, 0.35)
Expand All @@ -39,7 +39,7 @@ test_that("generation times can be specified in different ways", {
generation_time = generation_time_opts(
get_generation_time(
disease = "SARS-CoV-2", source = "ganyani",
max = 10, fixed = TRUE
max = 9, fixed = TRUE
)
),
params = delay_params
Expand Down Expand Up @@ -69,7 +69,7 @@ test_that("delay parameters can be specified in different ways", {
)
expect_equal(
tail(round(test_stan_delays(
delays = delay_opts(dist_spec(mean = 3, sd = 1, max = 5)),
delays = delay_opts(dist_spec(mean = 3, sd = 1, max = 4)),
params = delay_params
), digits = 2), n = -2),
c(0.02, 0.11, 0.22, 0.30, 0.35)
Expand All @@ -79,7 +79,7 @@ test_that("delay parameters can be specified in different ways", {
test_that("truncation parameters can be specified in different ways", {
expect_equal(
tail(round(test_stan_delays(
truncation = trunc_opts(dist = dist_spec(mean = 3, sd = 1, max = 5)),
truncation = trunc_opts(dist = dist_spec(mean = 3, sd = 1, max = 4)),
params = delay_params
), digits = 2), n = -2),
c(0.02, 0.11, 0.22, 0.30, 0.35)
Expand Down
Loading

0 comments on commit 6b1573c

Please sign in to comment.