Skip to content
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

Fix bug with pev min_wait #264

Merged
merged 1 commit into from
Nov 3, 2023
Merged

Fix bug with pev min_wait #264

merged 1 commit into from
Nov 3, 2023

Conversation

giovannic
Copy link
Member

This PR addresses an issue where min_wait is apparently ignored. It is easiest to see when you have two mass_pev campaigns close to each other (example below). But would likely affect other combinations of pev interventions (including those using EPI).

library(malariasimulation)

p <- get_parameters(overrides = list(human_population = 10000,
                                     model_seasonality = TRUE,
                                     individual_mosquitoes = FALSE))

p <- set_mass_pev(
  parameters = p,
  profile = rtss_profile,
  timesteps = c(20, 100),
  coverages = c(1, 1),
  min_ages = 0,
  max_ages = 100*365,
  min_wait = 500,
  booster_timestep = 100, # timesteps following initial vaccination
  booster_profile = list(rtss_booster_profile),
  booster_coverage = 1
)

o <- run_simulation(timesteps = 365,
                    parameters = p)

print(sum(o$n_pev_mass_dose_1))
print(o$n_pev_mass_dose_1)

The problem was that we were sampling pev populations based on the 3rd dose instead of the 1st. This PR corrects that while maintaining the previous behaviour wrt vaccine efficacy.

-- Changes --

Fix bug with pev min_wait:

  • Update pev-epi min_wait test to directly check sample population
  • Update pe-epi min_wait test to check that pev_timestep is being updated on the first dose
  • Copy pev-epi min_wait test to mass pev
  • Update pev and epi processes to calculate targets based on time of first dose
  • Update infection immunity function to calculate pev immunity only after 3rd dose

Copy link
Contributor

@kellymccain28 kellymccain28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Thanks for fixing this Giovanni!

I tested with multiple mass vaccination campaigns and with a combination of EPI and mass campaigns - all seemed to work as expected.

@pwinskill
Copy link
Member

pwinskill commented Sep 19, 2023

Thanks @giovannic!

I'm being slow and stuggling to follow the logic through all the way. Can I check that this change still has efficacy starting at the third dose (whist changin min_wait to respect time since first dose)?

I'm wondering if it would be clearer to implement with an additional variable(s) instead of the resetting of variables. Something like:

variables$doses = ...
variables$time_of_first_dose = ...
variables$time_of_third_dose = ...

Is that overkill?

@giovannic
Copy link
Member Author

Thanks @giovannic!

I'm being slow and stuggling to follow the logic through all the way. Can I check that this change still has efficacy starting at the third dose (whist changin min_wait to respect time since first dose)?

I'm wondering if it would be clearer to implement with an additional variable(s) instead of the resetting of variables. Something like:

variables$doses = ... variables$time_of_first_dose = ... variables$time_of_third_dose = ...

Is that overkill?

Not resetting pev_profile is a good point. Not that anyone is modelling this now, but this change would lead to weird behaviour if there were two mass_pev campaigns in a simulation. Efficacy for the first campaign would be reset on enrollment to the second campaign.


I'm not against your alternative.

Would the events change too? If the events remain the same, there'd be a lot of redundancy between the variables and the events. Currently, pev events fire on every dose so variables$doses and variables$time_of_third_dose would not be needed.

Also, how would we deal with booster timesteps?


Perhaps a clearer way would be to have:

variables$last_pev_timestep, variables$last_efficacious_pev_timestep and variables$pev_efficacy_profile?

Then we could set variables$last_pev_timestep on the first dose; and then all three of the variables on the third dose and boosters.

@pwinskill
Copy link
Member

Thanks Giovanni - that sounds sensible to me. I can certaintly see the sitation with multiple mass pev campaigns arising so think we should be robust to that.

 * Update pev-epi min_wait test to directly check sample population
 * Update pe-epi  min_wait test to check that pev_timestep is being updated
   on the first dose
 * Copy pev-epi min_wait test to mass pev
 * Update pev and epi processes to calculate targets based on time of first dose
 * Update infection immunity function to calculate pev immunity only
   after 3rd dose
@giovannic
Copy link
Member Author

@pwinskill I've updated this PR to have an explicit tracking of (non-)efficacious doses. I've updated the existing tests to check the new behaviour and that seems to be enough, but let me know if we should add some more!

Copy link
Member

@pwinskill pwinskill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much @giovannic. I can follow the logic much more clearly now - much appreciated 🙏

@giovannic giovannic merged commit 8e0e76e into dev Nov 3, 2023
4 checks passed
@giovannic giovannic deleted the bug/min_wait branch November 3, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants