Skip to content

Commit

Permalink
Merge branch 'main' into vignettes-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk authored Jan 30, 2025
2 parents 575adc3 + 4b9c821 commit b8b6aa8
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 22 deletions.
43 changes: 39 additions & 4 deletions .github/workflows/synthetic-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ on:
workflow_dispatch:

jobs:
synthetic-valiation:
synthetic-validation:
runs-on: macos-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@master

- uses: r-lib/actions/setup-r@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2

- name: Setup pandoc
uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r-dependencies@v2
with:
Expand All @@ -30,12 +34,17 @@ jobs:
here
scoringutils
loo
data.table
rstan
any::rmarkdown
matrixStats
local::.
- name: Run synthetic validation
run: |
source("inst/dev/recover-synthetic/rt.R")
shell: Rscript {0}
Rscript -e '
source("inst/dev/recover-synthetic/rt.R")
source("inst/dev/recover-synthetic/eval_rt.R")
'
- name: Upload validation figures
uses: actions/upload-artifact@v4
Expand All @@ -50,3 +59,29 @@ jobs:
name: fits
retention-days: 5
path: synthetic.rds

- name: Render synthetic recovery md
run: |
rmarkdown::render("inst/dev/synthetic_recovery.md")
shell: Rscript {0}

- name: Upload markdown
uses: actions/upload-artifact@v4
with:
name: synthetic_recovery
retention-days: 5
path: inst/dev/synthetic_recovery.html

- name: Post the artifact
uses: CDCgov/cfa-actions/post-artifact@main
if: ${{ github.event_name == 'pull_request' }}
with:
artifact-name: synthetic_recovery
gh-token: ${{ secrets.GITHUB_TOKEN }}
message: 'Thank you for your contribution ${{ github.actor }} :rocket:! Your { artifact-name } markdown is ready for download :point_right: [here]({ artifact-url }) :point_left:!'






1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- The `...` argument in `estimate_secondary()` has been removed because it was not used. By @jamesmbaazam in #894 and reviewed by @.
- All examples now use the natural parameters of distributions rather than the mean and standard deviation when specifying uncertain distributions. This is to eliminate warnings and encourage best practice. By @jamesmbaazam in #893 and reviewed by @sbfnk.
- Updated the methodology vignettes, By @sbfnk in #919 and reviewed by @seabbs and @jamesmbaazam.
- The ways that `dist_spec()` with certain/uncertain parameters can be constrained has been clarified. By @sbfnk in #940 and reviewed by @jamesmbaazam.

# EpiNow2 1.6.1

Expand Down
5 changes: 3 additions & 2 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ check_stan_delay <- function(dist) {
if (any(is.infinite(max(dist))) && !(attr(dist, "cdf_cutoff") > 0)) {
cli_abort(
c(
"i" = "All distribution passed to the model need to have a
"i" = "All distributions passed to the model need to have a
{col_blue(\"finite maximum\")}, which can be achieved either by
setting {.var max} or non-zero {.var cdf_cutoff}."
setting {.var max} or, if using a distribution with fixed parameters,
non-zero {.var cdf_cutoff}."
)
)
}
Expand Down
4 changes: 2 additions & 2 deletions R/dist_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ plot.dist_spec <- function(x, samples = 50L, res = 1, cumulative = TRUE, ...) {
c(
"!" = "All distributions in {.var x} must have a finite
maximum value.",
"i" = "You can set a finite maximum either as an
argument to {.fn plot} or when defining the distribution."
"i" = "You can set a finite maximum or CDF cutoff
when defining the distribution."
)
)
}
Expand Down
3 changes: 2 additions & 1 deletion R/opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,8 @@ filter_opts <- function(opts, region) {
#' @param dist A <dist_spec>
#' @param default_cdf_cutoff Numeric; default CDF cutoff to be used if an
#' unconstrained distribution is passed as `dist`. If `dist` is already
#' constrained by having a maximum or CDF cutoff this is ignored.
#' constrained by having a maximum or CDF cutoff this is ignored. Note that
#' this can only be done for <dist_spec> objects with fixed parameters.
#' @param cdf_cutoff_set Logical; whether the default CDF cutoff has been set by
#' the user; if yes and `dist` is constrained a warning is issued
#' @importFrom cli cli_inform cli_warn
Expand Down
11 changes: 7 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ you can file an issue [here](https://github.com/epiforecasts/EpiNow2/issues). We
## Contributors



<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->

All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [all-contributors](https://allcontributors.org) specification. Contributions of any kind are welcome!
All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [allcontributors](https://allcontributors.org) specification. Contributions of any kind are welcome!

### Code

Expand All @@ -181,16 +182,17 @@ All contributions to this project are gratefully acknowledged using the [`allcon
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=actions-user">actions-user</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=ellisp">ellisp</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=jdmunday">jdmunday</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=kaitejohnson">kaitejohnson</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=pearsonca">pearsonca</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=JAllen42">JAllen42</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=kaitejohnson">kaitejohnson</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=adamkucharski">adamkucharski</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=andrjohns">andrjohns</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=Bisaloo">Bisaloo</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=LloydChapman">LloydChapman</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=medewitt">medewitt</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=nikosbosse">nikosbosse</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=sophiemeakin">sophiemeakin</a>
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=sophiemeakin">sophiemeakin</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=zsusswein">zsusswein</a>



Expand Down Expand Up @@ -231,7 +233,7 @@ All contributions to this project are gratefully acknowledged using the [`allcon
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Anlinton">nlinton</a>,
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Amartinamcm">martinamcm</a>,
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Aadrian-lison">adrian-lison</a>,
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Azsusswein">zsusswein</a>
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Amicahwiesner67">micahwiesner67</a>



Expand All @@ -250,3 +252,4 @@ All contributions to this project are gratefully acknowledged using the [`allcon
<!-- ALL-CONTRIBUTORS-LIST:END -->



9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ guide](https://github.com/epiforecasts/EpiNow2/blob/main/.github/CONTRIBUTING.md

All contributions to this project are gratefully acknowledged using the
[`allcontributors` package](https://github.com/ropensci/allcontributors)
following the [all-contributors](https://allcontributors.org)
following the [allcontributors](https://allcontributors.org)
specification. Contributions of any kind are welcome!

### Code
Expand All @@ -271,16 +271,17 @@ specification. Contributions of any kind are welcome!
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=actions-user">actions-user</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=ellisp">ellisp</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=jdmunday">jdmunday</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=kaitejohnson">kaitejohnson</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=pearsonca">pearsonca</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=JAllen42">JAllen42</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=kaitejohnson">kaitejohnson</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=adamkucharski">adamkucharski</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=andrjohns">andrjohns</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=Bisaloo">Bisaloo</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=LloydChapman">LloydChapman</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=medewitt">medewitt</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=nikosbosse">nikosbosse</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=sophiemeakin">sophiemeakin</a>
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=sophiemeakin">sophiemeakin</a>,
<a href="https://github.com/epiforecasts/EpiNow2/commits?author=zsusswein">zsusswein</a>

### Issue Authors

Expand Down Expand Up @@ -318,7 +319,7 @@ specification. Contributions of any kind are welcome!
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Anlinton">nlinton</a>,
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Amartinamcm">martinamcm</a>,
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Aadrian-lison">adrian-lison</a>,
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Azsusswein">zsusswein</a>
<a href="https://github.com/epiforecasts/EpiNow2/issues?q=is%3Aissue+author%3Amicahwiesner67">micahwiesner67</a>

### Issue Contributors

Expand Down
Binary file removed inst/dev/figs/rt_backcalc_nuts.png
Binary file not shown.
Binary file removed inst/dev/figs/rt_gp_nuts.png
Binary file not shown.
Binary file removed inst/dev/figs/rt_gp_rw_nuts.png
Binary file not shown.
Binary file removed inst/dev/figs/rt_weekly_rw_nuts.png
Binary file not shown.
3 changes: 2 additions & 1 deletion inst/dev/recover-synthetic/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ save_ggplot <- function(plot, name, prefix = "") {
ggplot2::ggsave(
here::here("inst", "dev", "figs", paste0(prefix, name, ".png")),
plot,
dpi = 300, width = 9, height = 6
dpi = 300, width = 9, height = 6,
create.dir = TRUE
)
}

Expand Down
32 changes: 32 additions & 0 deletions inst/dev/synthetic_recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Synthetic Recovery visual results

This file combines the figures generated in `rt.R` into a single file, used to
confirm that the fits to synthetic data with different EpiNow2
specifications work as expected.

In all figures, the black dots indicate the ground truth R(t) estimate, used to
generate the synthetic data used for model fitting.

### Estimate from the default Gaussian Process settings using the No-U-Turn (NUTS) sampler
![](./figs/rt_gp_nuts.png)
![](./figs/inf_gp_nuts.png)

### Estimate from back-calculation
![](./figs/rt_backcalc_nuts.png)
![](./figs/inf_backcalc_nuts.png)

### Estimate from a weekly random walk, with no Gaussian process
![](./figs/rt_weekly_rw_nuts.png)
![](./figs/inf_weekly_rw_nuts.png)

### Estimate from a monthly random walk + a stationary Gaussian process
![](./figs/rt_gp_rw_nuts.png)
![](./figs/inf_gp_rw_nuts.png)


### Comparison of different model specs
CRPS over time evaluated against known R(t)
![](./figs/rt_crps.png)
CRPS over time evaluated against infections
![](./figs/inf_crps.png)

3 changes: 2 additions & 1 deletion man/apply_default_cdf_cutoff.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/delay_opts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/generation_time_opts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/trunc_opts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b8b6aa8

Please sign in to comment.