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

Add time-varying case fatality risk to simulation #101

Merged
merged 37 commits into from
Apr 25, 2024
Merged

Conversation

joshwlambert
Copy link
Member

This PR addresses a feature request made in #36 for time-varying case fatality risk (cfr).

The create_config() function is updated to return a $time_varying_death_risk element in the config list. This element by default is NA which corresponds to a time-constant death risk (specified by hosp_death_risk and non_hosp_death_risk arguments).

An internal function, time_varying_risk() is added inside .add_outcome() to apply the time-varying case fatality risk to both population-wide death risks or age-stratified death risks. time_varying_risk() is called from within apply_death_risk() (which is also defined within .add_outcome()). The config argument is added to .add_outcome() function.

A new vignette (time-varying-cfr.Rmd) on using the time-varying case fatality risk feature in {simulist} is added. The documentation of hosp_death_risk and non_hosp_death_risk argument have also been updated to make clear the interpretation of the risk when using constant or time-varying risks.

A bullet point is added to the design principles (design-principles.Rmd) vignette on input checking on the config list inside the simulation functions instead of within create_config().

Tests for create_config(), sim_linelist() and checkers are updated.

@joshwlambert joshwlambert added the enhancement New feature or request label Apr 16, 2024
Copy link

This pull request:

  • Adds 4 new dependencies (direct and indirect)
  • Adds 2 new system dependencies
  • Removes 0 existing dependencies (direct and indirect)
  • Removes 0 existing system dependencies

(Note that results may be inacurrate if you branched from an outdated version of the target branch.)

Copy link

@pratikunterwegs pratikunterwegs left a comment

Choose a reason for hiding this comment

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

The functionality looks good @joshwlambert - I only have a few questions and suggestions. My main one would be to add inline comments explaining internal functions a bit more so that other devs can also contribute in future.

I've run the vignette examples which work well. My main suggestion for the time-dependent CFR vignette would be to show cumulative incidence curves rather than daily incidence as this would show the differences between different time-dependent CFR functions more clearly. A small issue, possibly specific to my system, is that the website rendering causes the logo and the first callout to clash (see screenshot).

Screenshot 2024-04-17 at 15 31 35

I'll leave other user comments to @CarmenTamayo or others; Carmen it would be great if you could check whether this and the previous PR meet the requirements of the linked issue.

R/add_cols.R Show resolved Hide resolved
R/add_cols.R Outdated Show resolved Hide resolved
R/add_cols.R Show resolved Hide resolved
R/checkers.R Show resolved Hide resolved
R/utils.R Outdated Show resolved Hide resolved
R/create_config.R Outdated Show resolved Hide resolved
R/add_cols.R Outdated Show resolved Hide resolved
R/add_cols.R Outdated Show resolved Hide resolved
R/add_cols.R Outdated Show resolved Hide resolved
vignettes/time-varying-cfr.Rmd Outdated Show resolved Hide resolved
Copy link

This pull request:

  • Adds 4 new dependencies (direct and indirect)
  • Adds 2 new system dependencies
  • Removes 0 existing dependencies (direct and indirect)
  • Removes 0 existing system dependencies

(Note that results may be inacurrate if you branched from an outdated version of the target branch.)

1 similar comment
Copy link

This pull request:

  • Adds 4 new dependencies (direct and indirect)
  • Adds 2 new system dependencies
  • Removes 0 existing dependencies (direct and indirect)
  • Removes 0 existing system dependencies

(Note that results may be inacurrate if you branched from an outdated version of the target branch.)

@joshwlambert
Copy link
Member Author

@pratikunterwegs thanks for all the comments.

A small issue, possibly specific to my system, is that the website rendering causes the logo and the first callout to clash

I'd seen this also before making the PR and was unsure how to fix it. Do you know a way to solve this without changing the length of the vignette title?

Copy link

This pull request:

  • Adds 4 new dependencies (direct and indirect)
  • Adds 2 new system dependencies
  • Removes 0 existing dependencies (direct and indirect)
  • Removes 0 existing system dependencies

(Note that results may be inacurrate if you branched from an outdated version of the target branch.)

@pratikunterwegs
Copy link

@pratikunterwegs thanks for all the comments.

A small issue, possibly specific to my system, is that the website rendering causes the logo and the first callout to clash

I'd seen this also before making the PR and was unsure how to fix it. Do you know a way to solve this without changing the length of the vignette title?

Not really, other than adding text above the callout box.

Copy link

This pull request:

  • Adds 4 new dependencies (direct and indirect)
  • Adds 2 new system dependencies
  • Removes 0 existing dependencies (direct and indirect)
  • Removes 0 existing system dependencies

(Note that results may be inacurrate if you branched from an outdated version of the target branch.)

@pratikunterwegs
Copy link

Hi @joshwlambert I saw there had been changes to this PR - shall I take another look today or do you want to push more edits?

@joshwlambert
Copy link
Member Author

@pratikunterwegs I am finishing off the PR and will re-request a review once the changes are finalised later today.

@pratikunterwegs
Copy link

Great, just let me know.

@joshwlambert
Copy link
Member Author

The last 5 commits on this branch have updated the way the user specifies the time-varying death risk and how it is calculated in the .add_outcome() (specifically apply_death_risk()) function. The user now has to supply a two argument anonymous function to create_config(time_varying_death_risk = <FUNC>) in order for the simulation to use the appropriate death risk (hosp_death_risk or non_hosp_death_risk) and the time of infection.

The updates are demonstrated in the time-varying-cfr.Rmd vignette.

Copy link

@pratikunterwegs pratikunterwegs left a comment

Choose a reason for hiding this comment

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

Thanks @joshwlambert - looks good! I've just added a comment on .add_outcome() which might help to vectorise it and reduce the code some more, hope it helps. Feel free to merge if/once you get feedback on suitability as a fix for the linked issue.

R/add_cols.R Outdated Show resolved Hide resolved
R/add_cols.R Outdated Show resolved Hide resolved
vignettes/vis-linelist.Rmd Outdated Show resolved Hide resolved
Copy link

This pull request:

  • Adds 4 new dependencies (direct and indirect)
  • Adds 2 new system dependencies
  • Removes 0 existing dependencies (direct and indirect)
  • Removes 0 existing system dependencies

(Note that results may be inacurrate if you branched from an outdated version of the target branch.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants