Skip to content

Commit

Permalink
Automatic readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user authored and sbfnk committed Oct 19, 2023
1 parent 21e0695 commit c09fd9d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 63 deletions.
136 changes: 73 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,33 @@ runtimes*),

``` r
reporting_delay <- dist_spec(
mean = convert_to_logmean(2, 1), sd = convert_to_logsd(2, 1), max = 10,
mean = convert_to_logmean(2, 1),
sd = convert_to_logsd(2, 1),
max = 10,
dist = "lognormal"
)
#> Warning: The meaning of the 'max' argument has changed compared to previous versions. It now indicates the maximum of a distribution rather than the length of the probability mass function (including 0) that it represented previously. To replicate previous behaviour reduce max by 1.
#> This warning is displayed once every 8 hours.
reporting_delay
#>
#> Fixed distribution with PMF [0.11 0.48 0.27 0.093 0.029 0.0096 0.0033 0.0012 0.00045 0.00018 7.4e-05]
```

Here we define the incubation period and generation time based on
literature estimates for Covid-19 (see
We use example literature estimates for the incubation period and
generation time of Covid-19 (see
[here](https://github.com/epiforecasts/EpiNow2/tree/main/data-raw) for
the code that generates these estimates). *Note that these distributions
may not be applicable for your use case and that we have not included
uncertainty here to reduce the runtime of this example but in most
settings this is not recommended.*
the code that generates these estimates). *These distributions are
unlikely to be applicable for your use case and do not have uncertainty
associated with them. We strongly recommend investigating what might be
the best distributions to use in any given use case.*

``` r
generation_time <- get_generation_time(
disease = "SARS-CoV-2", source = "ganyani", max = 10, fixed = TRUE
)
incubation_period <- get_incubation_period(
disease = "SARS-CoV-2", source = "lauer", max = 10, fixed = TRUE
)
example_generation_time
#>
#> Uncertain gamma distribution with (untruncated) mean 3.6 (SD 0.71) and SD 3.1 (SD 0.77)
example_incubation_period
#>
#> Uncertain lognormal distribution with (untruncated) logmean 1.6 (SD 0.064) and logSD 0.42 (SD 0.069)
```

### [epinow()](https://epiforecasts.io/EpiNow2/reference/epinow.html)
Expand Down Expand Up @@ -239,12 +244,17 @@ For other formulations see the documentation for
``` r
estimates <- epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
rt = rt_opts(prior = list(mean = 2, sd = 0.2)),
stan = stan_opts(cores = 4, control = list(adapt_delta = 0.99)),
verbose = interactive()
)
#> WARN [2023-10-19 14:58:02] epinow: There were 1 divergent transitions after warmup. See
#> https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> to find out why this is a problem and how to eliminate them. -
#> WARN [2023-10-19 14:58:02] epinow: Examine the pairs() plot to diagnose sampling problems
#> -
names(estimates)
#> [1] "estimates" "estimated_reported_cases"
#> [3] "summary" "plots"
Expand All @@ -260,33 +270,33 @@ parameters at the latest date partially supported by data.
knitr::kable(summary(estimates))
```

| measure | estimate |
|:--------------------------------------|:-----------------------|
| New confirmed cases by infection date | 2250 (11294224) |
| Expected change in daily cases | Likely decreasing |
| Effective reproduction no. | 0.88 (0.61 – 1.2) |
| Rate of growth | -0.028 (-0.11 – 0.036) |
| Doubling/halving time (days) | -25 (19 – -6.6) |
| measure | estimate |
|:--------------------------------------|:----------------------|
| New confirmed cases by infection date | 2243 (11104278) |
| Expected change in daily cases | Likely decreasing |
| Effective reproduction no. | 0.87 (0.6 – 1.2) |
| Rate of growth | -0.029 (-0.1 – 0.034) |
| Doubling/halving time (days) | -24 (20 – -6.9) |

Summarised parameter estimates can also easily be returned, either
filtered for a single parameter or for all parameters.

``` r
head(summary(estimates, type = "parameters", params = "R"))
#> date variable strat type median mean sd lower_90
#> 1: 2020-02-22 R NA estimate 2.165168 2.172162 0.14593854 1.941092
#> 2: 2020-02-23 R NA estimate 2.131549 2.136040 0.11998939 1.941084
#> 3: 2020-02-24 R NA estimate 2.097955 2.098431 0.09900182 1.935873
#> 4: 2020-02-25 R NA estimate 2.060349 2.059484 0.08271136 1.925641
#> 5: 2020-02-26 R NA estimate 2.020232 2.019406 0.07061650 1.907712
#> 6: 2020-02-27 R NA estimate 1.978571 1.978434 0.06200852 1.876838
#> 1: 2020-02-22 R <NA> estimate 2.207822 2.213146 0.14734173 1.982468
#> 2: 2020-02-23 R <NA> estimate 2.179067 2.181507 0.12272435 1.987549
#> 3: 2020-02-24 R <NA> estimate 2.147290 2.147666 0.10254391 1.981929
#> 4: 2020-02-25 R <NA> estimate 2.112323 2.111719 0.08673504 1.968592
#> 5: 2020-02-26 R <NA> estimate 2.072160 2.073838 0.07503794 1.949350
#> 6: 2020-02-27 R <NA> estimate 2.035407 2.034248 0.06694049 1.923140
#> lower_50 lower_20 upper_20 upper_50 upper_90
#> 1: 2.072901 2.130679 2.202326 2.268532 2.422487
#> 2: 2.053218 2.102913 2.163595 2.215637 2.339445
#> 3: 2.030270 2.072284 2.121847 2.164987 2.260809
#> 4: 2.003278 2.036221 2.081113 2.114809 2.195010
#> 5: 1.971672 2.001096 2.038018 2.067643 2.136014
#> 6: 1.935102 1.961685 1.995176 2.019346 2.079872
#> 1: 2.109908 2.171465 2.243879 2.306067 2.472346
#> 2: 2.095397 2.147798 2.208251 2.260460 2.388300
#> 3: 2.075982 2.119774 2.171586 2.214484 2.318126
#> 4: 2.052561 2.088110 2.134212 2.171005 2.255303
#> 5: 2.022640 2.053441 2.094597 2.125451 2.194531
#> 6: 1.990618 2.018223 2.051017 2.078120 2.141441
```

Reported cases are returned in a separate data frame in order to
Expand All @@ -295,19 +305,19 @@ streamline the reporting of forecasts and for model evaluation.
``` r
head(summary(estimates, output = "estimated_reported_cases"))
#> date type median mean sd lower_90 lower_50 lower_20
#> 1: 2020-02-22 gp_rt 64 65.8305 17.79986 41 53 60
#> 2: 2020-02-23 gp_rt 77 78.5915 21.24272 47 64 72
#> 3: 2020-02-24 gp_rt 76 77.9760 21.13539 47 63 71
#> 4: 2020-02-25 gp_rt 74 75.8540 20.46272 47 61 69
#> 5: 2020-02-26 gp_rt 79 80.8435 20.94625 50 66 74
#> 6: 2020-02-27 gp_rt 113 115.5645 29.60269 72 96 105
#> 1: 2020-02-22 gp_rt 66 68.3755 18.89108 41 56 62
#> 2: 2020-02-23 gp_rt 78 79.6170 21.79236 47 65 73
#> 3: 2020-02-24 gp_rt 76 78.1660 21.42169 47 62 71
#> 4: 2020-02-25 gp_rt 73 75.1355 20.95688 44 60 68
#> 5: 2020-02-26 gp_rt 79 80.2145 22.30202 48 64 73
#> 6: 2020-02-27 gp_rt 110 112.6800 29.78451 70 91 103
#> upper_20 upper_50 upper_90
#> 1: 68 76 98.00
#> 2: 82 91 115.00
#> 3: 82 91 116.00
#> 4: 79 89 112.00
#> 5: 84 94 118.00
#> 6: 120 134 167.05
#> 1: 71 80.00 102.00
#> 2: 83 92.25 118.05
#> 3: 82 92.00 115.00
#> 4: 79 88.00 113.00
#> 5: 84 94.00 119.00
#> 6: 118 131.00 164.00
```

A range of plots are returned (with the single summary plot shown
Expand Down Expand Up @@ -350,25 +360,25 @@ us piecewise constant estimates by week.
``` r
estimates <- regional_epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
delays = delay_opts(incubation_period + reporting_delay),
generation_time = generation_time_opts(example_generation_time),
delays = delay_opts(example_incubation_period + reporting_delay),
rt = rt_opts(prior = list(mean = 2, sd = 0.2), rw = 7),
gp = NULL,
stan = stan_opts(cores = 4, warmup = 250, samples = 1000)
)
#> INFO [2023-10-12 13:04:43] Producing following optional outputs: regions, summary, samples, plots, latest
#> INFO [2023-10-12 13:04:43] Reporting estimates using data up to: 2020-04-21
#> INFO [2023-10-12 13:04:43] No target directory specified so returning output
#> INFO [2023-10-12 13:04:43] Producing estimates for: testland, realland
#> INFO [2023-10-12 13:04:43] Regions excluded: none
#> INFO [2023-10-12 13:05:08] Completed estimates for: testland
#> INFO [2023-10-12 13:05:31] Completed estimates for: realland
#> INFO [2023-10-12 13:05:31] Completed regional estimates
#> INFO [2023-10-12 13:05:31] Regions with estimates: 2
#> INFO [2023-10-12 13:05:31] Regions with runtime errors: 0
#> INFO [2023-10-12 13:05:31] Producing summary
#> INFO [2023-10-12 13:05:31] No summary directory specified so returning summary output
#> INFO [2023-10-12 13:05:32] No target directory specified so returning timings
#> INFO [2023-10-19 14:58:09] Producing following optional outputs: regions, summary, samples, plots, latest
#> INFO [2023-10-19 14:58:09] Reporting estimates using data up to: 2020-04-21
#> INFO [2023-10-19 14:58:09] No target directory specified so returning output
#> INFO [2023-10-19 14:58:09] Producing estimates for: testland, realland
#> INFO [2023-10-19 14:58:09] Regions excluded: none
#> INFO [2023-10-19 14:58:46] Completed estimates for: testland
#> INFO [2023-10-19 14:59:22] Completed estimates for: realland
#> INFO [2023-10-19 14:59:22] Completed regional estimates
#> INFO [2023-10-19 14:59:22] Regions with estimates: 2
#> INFO [2023-10-19 14:59:22] Regions with runtime errors: 0
#> INFO [2023-10-19 14:59:23] Producing summary
#> INFO [2023-10-19 14:59:23] No summary directory specified so returning summary output
#> INFO [2023-10-19 14:59:23] No target directory specified so returning timings
```

Results from each region are stored in a `regional` list with across
Expand All @@ -393,8 +403,8 @@ knitr::kable(estimates$summary$summarised_results$table)

| Region | New confirmed cases by infection date | Expected change in daily cases | Effective reproduction no. | Rate of growth | Doubling/halving time (days) |
|:---------|:--------------------------------------|:-------------------------------|:---------------------------|:------------------------|:-----------------------------|
| realland | 2128 (11434078) | Likely decreasing | 0.87 (0.64 – 1.2) | -0.032 (-0.095 – 0.033) | -22 (21 – -7.3) |
| testland | 2155 (11334435) | Likely decreasing | 0.87 (0.64 – 1.2) | -0.032 (-0.097 – 0.038) | -22 (18 – -7.2) |
| realland | 2147 (11014113) | Likely decreasing | 0.86 (0.63 – 1.1) | -0.032 (-0.094 – 0.029) | -22 (24 – -7.4) |
| testland | 2184 (12484345) | Likely decreasing | 0.86 (0.66 – 1.2) | -0.031 (-0.082 – 0.036) | -22 (19 – -8.5) |

A range of plots are again returned (with the single summary plot shown
below).
Expand Down
Binary file modified man/figures/unnamed-chunk-15-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/unnamed-chunk-19-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c09fd9d

Please sign in to comment.