-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #408: Fit the susceptible population #904
base: main
Are you sure you want to change the base?
Conversation
I am minded not to do any of these unless you feel strongly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice!
- This doesn't address if we should be reporting the susceptibility adjusted or unadjusted Rt.
We already have a gen_R
in generated quantities (for the nonmechanistic model) - so we could in principle model unadj_R
and then always generate R in generated quantities?
I don't feel strongly - not quite sure what's best to report anyway. Probably worth a new Issue though as we might be calling stuff R when it's not actually R. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This is how benchmark results would change (along with a 95% confidence interval in relative change) if bafef0b is merged into main:
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 6184ab9 is merged into main:
|
#' Note that with "forecast", Rt estimates are unadjusted for susceptible | ||
#' depletion but posterior predictions are adjusted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#' Note that with "forecast", Rt estimates are unadjusted for susceptible | |
#' depletion but posterior predictions are adjusted. | |
#' Note that with "all", Rt estimates are unadjusted for susceptible | |
#' depletion but posterior predictions of infections and reports are | |
#' adjusted. |
@@ -125,7 +125,7 @@ simulate_infections <- function(estimates, R, initial_infections, | |||
initial_infections = array(log_initial_infections, dim = c(1, 1)), | |||
initial_growth = array(initial_growth, dim = c(1, length(initial_growth))), | |||
R = array(R$R, dim = c(1, nrow(R))), | |||
pop = pop | |||
use_pop = as.integer(pop != Fixed(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be a future issue but I think we want to be able to have susceptible depletion across full simulations, too.
@@ -5,5 +5,5 @@ | |||
array[t - seeding_time] int breakpoints; // when do breakpoints occur | |||
int future_fixed; // is underlying future Rt assumed to be fixed | |||
int fixed_from; // Reference date for when Rt estimation should be fixed | |||
int pop; // Initial susceptible population | |||
int use_pop; // use population size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int use_pop; // use population size | |
int use_pop; // use population size (0 = no; 1 = forecasts; 2 = all) |
@@ -2,6 +2,6 @@ | |||
array[n, seeding_time > 1 ? 1 : 0] real initial_growth; //initial growth | |||
|
|||
matrix[n, t - seeding_time] R; // reproduction number | |||
int pop; // susceptible population | |||
int use_pop; // use population size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int use_pop; // use population size | |
int use_pop; // use population size (0 = no; 1 = forecasts) |
cum_infections[1] = sum(infections[1:uot]); | ||
} | ||
// iteratively update infections | ||
for (s in 1:ot) { | ||
infectiousness[s] = update_infectiousness(infections, gt_rev_pmf, uot, s); | ||
if (pop && s > nht) { | ||
if (use_pop == 1 || (use_pop == 2 && s <= nht)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm not still getting the logic. We have:
use_pop == 1
: only adjust in forecast
use_pop == 2
: adjust across all
So shouldn't this be
if (use_pop == 1 || (use_pop == 2 && s <= nht)) { | |
if ((use_pop == 1 && s > nht) || use_pop == 2)) { |
expect_warning( | ||
rt_opts(pop = 1000), | ||
"The `pop` argument of `rt_opts()` must be a `<dist_spec>` as of EpiNow2 1.7.0." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect_warning( | |
rt_opts(pop = 1000), | |
"The `pop` argument of `rt_opts()` must be a `<dist_spec>` as of EpiNow2 1.7.0." | |
) | |
lifecycle::expect_deprecated( | |
rt_opts(pop = 1000), | |
"The `pop` argument of `rt_opts\\(\\)` must be a `<dist_spec>` as of EpiNow2 1.7.0." | |
) |
cum_infections[1] = sum(infections[1:uot]); | ||
} | ||
// iteratively update infections | ||
for (s in 1:ot) { | ||
infectiousness[s] = update_infectiousness(infections, gt_rev_pmf, uot, s); | ||
if (pop && s > nht) { | ||
if (use_pop == 1 || (use_pop == 2 && s <= nht)) { | ||
exp_adj_Rt = exp(-R[s] * infectiousness[s] / (pop - cum_infections[nht])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exp_adj_Rt = exp(-R[s] * infectiousness[s] / (pop - cum_infections[nht])); | |
exp_adj_Rt = exp(-R[s] * infectiousness[s] / (pop - cum_infections[s])); |
Description
This PR closes #408 by allowing for fitting the susceptible population using the new distribution interface.
Maybe to do:
Initial submission checklist
devtools::test()
anddevtools::check()
).devtools::document()
).lintr::lint_package()
).After the initial Pull Request