Skip to content

Commit

Permalink
change over opts and create interface
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Dec 19, 2024
1 parent dbb6536 commit b5063cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/create.R
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ create_rt_data <- function(rt = rt_opts(), breakpoints = NULL,
breakpoints = breakpoints,
future_fixed = as.numeric(future_rt$fixed),
fixed_from = future_rt$from,
pop = rt$pop,
pop = as.integer(rt$pop != Fixed(0)),
stationary = as.numeric(rt$gp_on == "R0"),
future_time = horizon - future_rt$from
)
Expand Down
22 changes: 16 additions & 6 deletions R/opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ trunc_opts <- function(dist = Fixed(0), default_cdf_cutoff = 0.001,
#' conservative estimate of break point changes (alter this by setting
#' `gp = NULL`).
#'
#' @param pop Integer, defaults to 0. Susceptible population initially present.
#' Used to adjust Rt estimates when otherwise fixed based on the proportion of
#' the population that is susceptible. When set to 0 no population adjustment
#' @param pop A `<dist_spec>` giving the initial susceptible population size.
#' Used to adjust Rt estimates based on the proportion of the population that
#' is susceptible. Defaults to `Fixed(0)` which means no population adjustment
#' is done.
#'
#' @param gp_on Character string, defaulting to "R_t-1". Indicates how the
Expand Down Expand Up @@ -354,13 +354,12 @@ rt_opts <- function(prior = LogNormal(mean = 1, sd = 1),
use_breakpoints = TRUE,
future = "latest",
gp_on = c("R_t-1", "R0"),
pop = 0) {
pop = Fixed(0)) {
rt <- list(
use_rt = use_rt,
rw = rw,
use_breakpoints = use_breakpoints,
future = future,
pop = pop,
gp_on = arg_match(gp_on)
)

Expand Down Expand Up @@ -388,6 +387,17 @@ rt_opts <- function(prior = LogNormal(mean = 1, sd = 1),
prior <- LogNormal(mean = prior$mean, sd = prior$sd)
}

if (is.numeric(pop)) {
cli_warn(
c(
"!" = "Specifying {.var pop} as a numeric value is deprecated.",
"i" = "Use a {.cls dist_spec} instead, e.g. Fixed({pop})."
)
)
pop <- Fixed(pop)
}
rt$pop <- pop

if (rt$use_rt) {
rt$prior <- prior
} else {
Expand Down Expand Up @@ -698,7 +708,7 @@ obs_opts <- function(family = c("negbin", "poisson"),
cli_abort(
c(
"!" = "Specifying {.var phi} as a vector of length 2 is deprecated.",
"i" = "Mean and SD should be given as list elements."
"i" = "Use a {.cls dist_spec} instead, e.g. Normal(mean = {phi[1]}, sd = {phi[2]})."
)
)
}
Expand Down

0 comments on commit b5063cb

Please sign in to comment.