From 217792028e3fa480133bc7a141d42a309c58ac9c Mon Sep 17 00:00:00 2001 From: Kaitlyn Johnson Date: Sun, 29 Sep 2024 14:20:30 -0400 Subject: [PATCH 1/6] show example of non-parametric specification of GI and delay --- vignettes/EpiNow2.Rmd | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/vignettes/EpiNow2.Rmd b/vignettes/EpiNow2.Rmd index e3350e134..1eb271b17 100644 --- a/vignettes/EpiNow2.Rmd +++ b/vignettes/EpiNow2.Rmd @@ -26,7 +26,7 @@ library(EpiNow2) ### Reporting delays, incubation period and generation time -Distributions can be supplied in two ways. First, one can supplying delay data to `estimate_delay()`, where a subsampled bootstrapped lognormal will be fit to account for uncertainty in the observed data without being biased by changes in incidence (see `?EpiNow2::estimate_delay()`). +Distributions can be supplied in two ways. First, one can supply delay data to `estimate_delay()`, where a subsampled bootstrapped lognormal will be fit to account for uncertainty in the observed data without being biased by changes in incidence (see `?EpiNow2::estimate_delay()`). Second, one can specify predetermined delays with uncertainty using the distribution functions such as `Gamma` or `Lognormal`. An arbitrary number of delay distributions are supported in `dist_spec()` with a common use case being an incubation period followed by a reporting delay. For more information on specifying distributions see (see `?EpiNow2::Distributions`). @@ -87,6 +87,23 @@ example_incubation_period #> 0.069 ``` +Users can also pass a non-parametric delay distribution vector using the `NonParametric` option +for both the generation interval and the reporting delays. It is important to note that if doing so, +the generation interval vector is indexed starting at day 1, as the renewal approach assumes +there is 0 probability of onward infection on the day an individual is infected, whereas +the reporting delay vectors should be indexed starting at day 0, as for example there can be +some probability of showing symptoms or being reported on day 0 of an individual's infection. +```r +#Example 1-indexed generation interval +example_non_parametric_gi <- NonParametric(pmf = c(0.3, 0.5, 0.2)) +# Example 0-indexed delay from infection to reporting +example_non_parametric_delay <- NonParametric(pmf = c(0.01, 0.1, 0.5, 0.3, 0.09)) +``` +These distributions are passed to downstream functions in the same way that the +parametric distributions are. The difference in the `NonParametric` cases is that +these will be treated as fixed rather thann estimated with the specified parametric priors. + + Now, to the functions. ### [epinow()](https://epiforecasts.io/EpiNow2/reference/epinow.html) @@ -129,7 +146,6 @@ names(estimates) Both summary measures and posterior samples are returned for all parameters in an easily explored format which can be accessed using `summary`. The default is to return a summary table of estimates for key parameters at the latest date partially supported by data. - ```r knitr::kable(summary(estimates)) ``` From 75f663c05bd503cacdb8574fbdaa90694f2386e4 Mon Sep 17 00:00:00 2001 From: Kaitlyn Johnson Date: Sun, 29 Sep 2024 14:42:15 -0400 Subject: [PATCH 2/6] remove comments on indexing in code --- vignettes/EpiNow2.Rmd | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/vignettes/EpiNow2.Rmd b/vignettes/EpiNow2.Rmd index 1eb271b17..f509f603f 100644 --- a/vignettes/EpiNow2.Rmd +++ b/vignettes/EpiNow2.Rmd @@ -89,19 +89,16 @@ example_incubation_period Users can also pass a non-parametric delay distribution vector using the `NonParametric` option for both the generation interval and the reporting delays. It is important to note that if doing so, -the generation interval vector is indexed starting at day 1, as the renewal approach assumes -there is 0 probability of onward infection on the day an individual is infected, whereas -the reporting delay vectors should be indexed starting at day 0, as for example there can be -some probability of showing symptoms or being reported on day 0 of an individual's infection. +the generation interval vector is indexed starting at day 1 of an individual's infection, as the renewal approach assumes there is 0 probability of onward infection on the day an individual is +infected, whereas the reporting delay vectors should be indexed starting at day 0, as for example there can be some probability of showing symptoms or being reported on day 0 of an individual's infection. ```r -#Example 1-indexed generation interval example_non_parametric_gi <- NonParametric(pmf = c(0.3, 0.5, 0.2)) -# Example 0-indexed delay from infection to reporting + example_non_parametric_delay <- NonParametric(pmf = c(0.01, 0.1, 0.5, 0.3, 0.09)) ``` These distributions are passed to downstream functions in the same way that the -parametric distributions are. The difference in the `NonParametric` cases is that -these will be treated as fixed rather thann estimated with the specified parametric priors. +parametric distributions are. The difference in the `NonParametric` case is that +these will be treated as fixed rather than estimated with the specified parametric priors. Now, to the functions. From 2b29030ffae3b86bbf26ce372d3fef8c613e909a Mon Sep 17 00:00:00 2001 From: Kaitlyn Johnson Date: Tue, 1 Oct 2024 07:04:51 -0400 Subject: [PATCH 3/6] update vignette to explain GI should be zero indexed with first element 0 --- vignettes/EpiNow2.Rmd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vignettes/EpiNow2.Rmd b/vignettes/EpiNow2.Rmd index f509f603f..75ff7dad7 100644 --- a/vignettes/EpiNow2.Rmd +++ b/vignettes/EpiNow2.Rmd @@ -88,11 +88,13 @@ example_incubation_period ``` Users can also pass a non-parametric delay distribution vector using the `NonParametric` option -for both the generation interval and the reporting delays. It is important to note that if doing so, -the generation interval vector is indexed starting at day 1 of an individual's infection, as the renewal approach assumes there is 0 probability of onward infection on the day an individual is -infected, whereas the reporting delay vectors should be indexed starting at day 0, as for example there can be some probability of showing symptoms or being reported on day 0 of an individual's infection. +for both the generation interval and reporting delays. It is important to note that if doing so, +both delay distributions are 0-indexed, meaning the first element corresponds to the probability mass +at day 0 of an individual's infection. Because the discretised renewal equation doesn't support mass on day 0, the generation interval should be passed in as a 0-indexed vector with a mass of zero on day 0. +If this is not the case, a warning will indicate that the vector is being left-truncated and renormalized. + ```r -example_non_parametric_gi <- NonParametric(pmf = c(0.3, 0.5, 0.2)) +example_non_parametric_gi <- NonParametric(pmf = c(0, 0.3, 0.5, 0.2)) example_non_parametric_delay <- NonParametric(pmf = c(0.01, 0.1, 0.5, 0.3, 0.09)) ``` From 376835eed0f6b79620c2b64bb470532763f395ab Mon Sep 17 00:00:00 2001 From: Kaitlyn Johnson <94390107+kaitejohnson@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:36:47 -0400 Subject: [PATCH 4/6] Update vignettes/EpiNow2.Rmd Co-authored-by: Sebastian Funk --- vignettes/EpiNow2.Rmd | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vignettes/EpiNow2.Rmd b/vignettes/EpiNow2.Rmd index 75ff7dad7..2674cb311 100644 --- a/vignettes/EpiNow2.Rmd +++ b/vignettes/EpiNow2.Rmd @@ -99,9 +99,7 @@ example_non_parametric_gi <- NonParametric(pmf = c(0, 0.3, 0.5, 0.2)) example_non_parametric_delay <- NonParametric(pmf = c(0.01, 0.1, 0.5, 0.3, 0.09)) ``` These distributions are passed to downstream functions in the same way that the -parametric distributions are. The difference in the `NonParametric` case is that -these will be treated as fixed rather than estimated with the specified parametric priors. - +parametric distributions are. Now, to the functions. From 3c0d6aec2ea45f3549416f2e9a21ae96f3e98c1a Mon Sep 17 00:00:00 2001 From: Kaitlyn Johnson Date: Tue, 1 Oct 2024 12:41:53 +0000 Subject: [PATCH 5/6] move changes to Rmd.orig --- vignettes/EpiNow2.Rmd.orig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/vignettes/EpiNow2.Rmd.orig b/vignettes/EpiNow2.Rmd.orig index bbac82e46..0ca67f71f 100644 --- a/vignettes/EpiNow2.Rmd.orig +++ b/vignettes/EpiNow2.Rmd.orig @@ -34,7 +34,7 @@ library(EpiNow2) ### Reporting delays, incubation period and generation time -Distributions can be supplied in two ways. First, one can supplying delay data to `estimate_delay()`, where a subsampled bootstrapped lognormal will be fit to account for uncertainty in the observed data without being biased by changes in incidence (see `?EpiNow2::estimate_delay()`). +Distributions can be supplied in two ways. First, one can supply delay data to `estimate_delay()`, where a subsampled bootstrapped lognormal will be fit to account for uncertainty in the observed data without being biased by changes in incidence (see `?EpiNow2::estimate_delay()`). Second, one can specify predetermined delays with uncertainty using the distribution functions such as `Gamma` or `Lognormal`. An arbitrary number of delay distributions are supported in `dist_spec()` with a common use case being an incubation period followed by a reporting delay. For more information on specifying distributions see (see `?EpiNow2::Distributions`). @@ -61,6 +61,20 @@ example_generation_time example_incubation_period ``` +Users can also pass a non-parametric delay distribution vector using the `NonParametric` option +for both the generation interval and reporting delays. It is important to note that if doing so, +both delay distributions are 0-indexed, meaning the first element corresponds to the probability mass +at day 0 of an individual's infection. Because the discretised renewal equation doesn't support mass on day 0, the generation interval should be passed in as a 0-indexed vector with a mass of zero on day 0. +If this is not the case, a warning will indicate that the vector is being left-truncated and renormalized. + +```{r} +example_non_parametric_gi <- NonParametric(pmf = c(0, 0.3, 0.5, 0.2)) + +example_non_parametric_delay <- NonParametric(pmf = c(0.01, 0.1, 0.5, 0.3, 0.09)) +``` +These distributions are passed to downstream functions in the same way that the +parametric distributions are. + Now, to the functions. ### [epinow()](https://epiforecasts.io/EpiNow2/reference/epinow.html) From 87a823486bbc64a482faf8996b024377f1203c4d Mon Sep 17 00:00:00 2001 From: Kaitlyn Johnson Date: Tue, 1 Oct 2024 12:43:38 +0000 Subject: [PATCH 6/6] add to DESCRIPTION --- DESCRIPTION | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 9c2db9237..0d71a9cd8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -76,6 +76,11 @@ Authors@R: family = "Johnson", role = "ctb", email = "andrew.johnson@arjohnsonau.com"), + person(given = "Kaitlyn", + family = "Johnson", + role = "ctb", + email = "johnsonkaitlyne9@gmail.com", + comment = c(ORCID = "0000-0001-8011-0012")), person(given = "EpiForecasts", role = "aut"), person(given = "Sebastian",