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

improve handling of seeding time in simulate_infections() #627

Merged
merged 9 commits into from
Mar 28, 2024
Merged

Conversation

sbfnk
Copy link
Contributor

@sbfnk sbfnk commented Mar 25, 2024

Description

This PR closes #626.

It adds a seeding_time argument, adjusts the initial number of infections, and improves the documentation.

Using the example from the linked issue now yields:

library("EpiNow2")
#> 
#> Attaching package: 'EpiNow2'
#> The following object is masked from 'package:stats':
#> 
#>     Gamma

R <- data.frame(
  date = seq.Date(as.Date("2023-01-01"), length.out = 5, by = "day"),
  R = c(rep(1.2, 5))
)

sim <- simulate_infections(
  R = R,
  initial_infections = 100,
  generation_time = generation_time_opts(
    fix_dist(example_generation_time)
  ),
  delays = delay_opts(fix_dist(example_reporting_delay)),
  obs = obs_opts(family = "poisson")
)

sim[variable == "infections"]
#>      variable       date    value
#>        <char>     <Date>    <num>
#> 1: infections 2023-01-01 103.7012
#> 2: infections 2023-01-02 109.0943
#> 3: infections 2023-01-03 114.6880
#> 4: infections 2023-01-04 120.5479
#> 5: infections 2023-01-05 126.6988

Created on 2024-03-26 with reprex v2.1.0

It starts with 100 infections as expected and the first data point shown is the number of infections occurring on the following day.

Initial submission checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have tested my changes locally (using devtools::test() and devtools::check()).
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required and rebuilt docs if yes (using devtools::document()).
  • I have followed the established coding standards (and checked using lintr::lint_package()).
  • I have added a news item linked to this PR.

After the initial Pull Request

  • I have reviewed Checks for this PR and addressed any issues as far as I am able.

@sbfnk
Copy link
Contributor Author

sbfnk commented Mar 26, 2024

windows test currently no longer failing due to what looks like an unrelated issue

@sbfnk sbfnk requested a review from jamesmbaazam March 26, 2024 14:15
NEWS.md Outdated Show resolved Hide resolved
@sbfnk sbfnk enabled auto-merge (squash) March 27, 2024 12:57
@sbfnk sbfnk requested a review from jamesmbaazam March 27, 2024 12:57
@jamesmbaazam
Copy link
Contributor

Sorry, I'm yet to review the part when seeding_time is applied. I'm in a workshop today so have limited capacity.

Copy link
Contributor

@jamesmbaazam jamesmbaazam left a comment

Choose a reason for hiding this comment

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

LGTM.

@sbfnk sbfnk merged commit 920b3cb into main Mar 28, 2024
10 of 11 checks passed
@sbfnk sbfnk deleted the seeding-time branch March 28, 2024 16:15
@jamesmbaazam
Copy link
Contributor

Oopsie! I was reviewing it at the same time as you were merging.

@sbfnk
Copy link
Contributor Author

sbfnk commented Mar 28, 2024

Oopsie! I was reviewing it at the same time as you were merging.

That was the merge queue automatically merging as soon as you approved.

@jamesmbaazam
Copy link
Contributor

Oh, cool! It happened so fast, I thought there was a clash.

sbfnk added a commit that referenced this pull request May 3, 2024
* add `seeding_time` arg to `simulate_inections()`

* adjust initial infections to exp growth

* add news item

* update snapshot

* update other snapshot

* test seeding time setting

* update snapshot

* Apply suggestions from code review

Co-authored-by: James Azam <james.azam@lshtm.ac.uk>

* re-generate documentation

---------

Co-authored-by: James Azam <james.azam@lshtm.ac.uk>
sbfnk added a commit that referenced this pull request May 3, 2024
* add `seeding_time` arg to `simulate_inections()`

* adjust initial infections to exp growth

* add news item

* update snapshot

* update other snapshot

* test seeding time setting

* update snapshot

* Apply suggestions from code review

Co-authored-by: James Azam <james.azam@lshtm.ac.uk>

* re-generate documentation

---------

Co-authored-by: James Azam <james.azam@lshtm.ac.uk>
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.

results of simulate_infections starts with unexpected number of infections
2 participants