Skip to content

Commit

Permalink
Automatic readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 23, 2023
1 parent f618e77 commit 40ee5e2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 55 deletions.
112 changes: 57 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,31 +175,33 @@ reporting_delay <- estimate_delay(
```

If data was not available we could instead make an informed estimate of
the likely delay (*this is a synthetic example and not applicable to
real world use cases and we have not included uncertainty to decrease
runtimes*),
the likely delay. We choose a lognormal distribution with mean 2,
standard deviation 1 (both with some uncertainty) and maximum 10. *This
is just an example and unlikely to apply in any particular use case*.

``` r
reporting_delay <- dist_spec(
mean = convert_to_logmean(2, 1),
mean_sd = 1,
sd = convert_to_logsd(2, 1),
sd_sd = 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]
#> Uncertain lognormal distribution with (untruncated) logmean 0.58 (SD 1) and logSD 0.47 (SD 1)
```

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). *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.*
unlikely to be applicable for your use case. We strongly recommend
investigating what might be the best distributions to use in any given
use case.*

``` r
example_generation_time
Expand Down Expand Up @@ -250,10 +252,10 @@ estimates <- epinow(
stan = stan_opts(cores = 4, control = list(adapt_delta = 0.99)),
verbose = interactive()
)
#> WARN [2023-10-19 16:04:04] epinow: There were 1 divergent transitions after warmup. See
#> WARN [2023-10-23 09:19:28] epinow: There were 92 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 16:04:04] epinow: Examine the pairs() plot to diagnose sampling problems
#> WARN [2023-10-23 09:19:28] epinow: Examine the pairs() plot to diagnose sampling problems
#> -
names(estimates)
#> [1] "estimates" "estimated_reported_cases"
Expand All @@ -270,33 +272,33 @@ parameters at the latest date partially supported by data.
knitr::kable(summary(estimates))
```

| measure | estimate |
|:--------------------------------------|:---------------------|
| New confirmed cases by infection date | 2350 (11304477) |
| Expected change in daily cases | Likely decreasing |
| Effective reproduction no. | 0.9 (0.6 – 1.2) |
| Rate of growth | -0.023 (-0.1 – 0.04) |
| Doubling/halving time (days) | -30 (17 – -6.9) |
| measure | estimate |
|:--------------------------------------|:------------------------|
| New confirmed cases by infection date | 2289 (11654344) |
| Expected change in daily cases | Likely decreasing |
| Effective reproduction no. | 0.88 (0.62 – 1.2) |
| Rate of growth | -0.026 (-0.095 – 0.037) |
| Doubling/halving time (days) | -26 (19 – -7.3) |

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.217595 2.218885 0.14606212 1.982775
#> 2: 2020-02-23 R <NA> estimate 2.185359 2.185926 0.12200124 1.987882
#> 3: 2020-02-24 R <NA> estimate 2.150211 2.150894 0.10226123 1.986581
#> 4: 2020-02-25 R <NA> estimate 2.112969 2.113895 0.08666930 1.978768
#> 5: 2020-02-26 R <NA> estimate 2.074732 2.075113 0.07492886 1.957386
#> 6: 2020-02-27 R <NA> estimate 2.035741 2.034787 0.06655349 1.924951
#> 1: 2020-02-22 R <NA> estimate 2.221988 2.229941 0.14606211 2.004828
#> 2: 2020-02-23 R <NA> estimate 2.190383 2.195541 0.12206975 2.005895
#> 3: 2020-02-24 R <NA> estimate 2.157816 2.159273 0.10206869 1.998964
#> 4: 2020-02-25 R <NA> estimate 2.120045 2.121240 0.08613744 1.982275
#> 5: 2020-02-26 R <NA> estimate 2.081491 2.081605 0.07426126 1.961682
#> 6: 2020-02-27 R <NA> estimate 2.042279 2.040569 0.06615653 1.930667
#> lower_50 lower_20 upper_20 upper_50 upper_90
#> 1: 2.122934 2.184688 2.249354 2.304795 2.467738
#> 2: 2.104538 2.157958 2.212795 2.263763 2.387890
#> 3: 2.083589 2.126500 2.173202 2.218098 2.320740
#> 4: 2.056884 2.092975 2.133195 2.170198 2.256240
#> 5: 2.026021 2.057317 2.094662 2.124689 2.198660
#> 6: 1.989846 2.017762 2.052087 2.078759 2.142666
#> 1: 2.132457 2.186662 2.261165 2.320909 2.483093
#> 2: 2.112563 2.161796 2.222342 2.274127 2.398206
#> 3: 2.088188 2.129816 2.182531 2.225932 2.331594
#> 4: 2.061604 2.096706 2.142636 2.179251 2.263415
#> 5: 2.032263 2.061474 2.099552 2.132066 2.202612
#> 6: 1.996188 2.024689 2.058107 2.084556 2.146949
```

Reported cases are returned in a separate data frame in order to
Expand All @@ -305,19 +307,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 67 69.1480 19.54190 41 56 63
#> 2: 2020-02-23 gp_rt 77 79.0400 21.50515 48 64 72
#> 3: 2020-02-24 gp_rt 77 79.0030 21.19258 48 64 72
#> 4: 2020-02-25 gp_rt 75 76.2740 20.99367 45 62 69
#> 5: 2020-02-26 gp_rt 78 80.6325 22.15642 49 65 73
#> 6: 2020-02-27 gp_rt 110 113.5100 29.48314 70 92 103
#> 1: 2020-02-22 gp_rt 66 67.4990 18.79970 39 54 61.6
#> 2: 2020-02-23 gp_rt 77 78.2850 21.52902 46 63 71.0
#> 3: 2020-02-24 gp_rt 75 76.9040 21.31589 47 62 70.0
#> 4: 2020-02-25 gp_rt 72 74.0360 20.23167 45 59 67.0
#> 5: 2020-02-26 gp_rt 78 79.9930 21.79308 48 65 73.0
#> 6: 2020-02-27 gp_rt 110 112.9035 29.10011 69 92 103.0
#> upper_20 upper_50 upper_90
#> 1: 71.4 80 105.00
#> 2: 83.0 92 118.00
#> 3: 82.0 91 117.00
#> 4: 80.0 89 114.00
#> 5: 84.0 94 121.00
#> 6: 118.4 132 166.05
#> 1: 71 79 101
#> 2: 82 91 118
#> 3: 80 89 114
#> 4: 77 86 109
#> 5: 83 93 117
#> 6: 118 131 164
```

A range of plots are returned (with the single summary plot shown
Expand Down Expand Up @@ -366,19 +368,19 @@ estimates <- regional_epinow(
gp = NULL,
stan = stan_opts(cores = 4, warmup = 250, samples = 1000)
)
#> INFO [2023-10-19 16:04:14] Producing following optional outputs: regions, summary, samples, plots, latest
#> INFO [2023-10-19 16:04:14] Reporting estimates using data up to: 2020-04-21
#> INFO [2023-10-19 16:04:14] No target directory specified so returning output
#> INFO [2023-10-19 16:04:14] Producing estimates for: testland, realland
#> INFO [2023-10-19 16:04:14] Regions excluded: none
#> INFO [2023-10-19 16:05:07] Completed estimates for: testland
#> INFO [2023-10-19 16:05:57] Completed estimates for: realland
#> INFO [2023-10-19 16:05:57] Completed regional estimates
#> INFO [2023-10-19 16:05:57] Regions with estimates: 2
#> INFO [2023-10-19 16:05:57] Regions with runtime errors: 0
#> INFO [2023-10-19 16:05:57] Producing summary
#> INFO [2023-10-19 16:05:57] No summary directory specified so returning summary output
#> INFO [2023-10-19 16:05:57] No target directory specified so returning timings
#> INFO [2023-10-23 09:19:35] Producing following optional outputs: regions, summary, samples, plots, latest
#> INFO [2023-10-23 09:19:35] Reporting estimates using data up to: 2020-04-21
#> INFO [2023-10-23 09:19:35] No target directory specified so returning output
#> INFO [2023-10-23 09:19:35] Producing estimates for: testland, realland
#> INFO [2023-10-23 09:19:35] Regions excluded: none
#> INFO [2023-10-23 09:20:13] Completed estimates for: testland
#> INFO [2023-10-23 09:20:49] Completed estimates for: realland
#> INFO [2023-10-23 09:20:49] Completed regional estimates
#> INFO [2023-10-23 09:20:49] Regions with estimates: 2
#> INFO [2023-10-23 09:20:49] Regions with runtime errors: 0
#> INFO [2023-10-23 09:20:49] Producing summary
#> INFO [2023-10-23 09:20:49] No summary directory specified so returning summary output
#> INFO [2023-10-23 09:20:49] No target directory specified so returning timings
```

Results from each region are stored in a `regional` list with across
Expand All @@ -403,8 +405,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 | 2118 (11394127) | Likely decreasing | 0.85 (0.61 – 1.1) | -0.035 (-0.097 – 0.029) | -20 (24 – -7.1) |
| testland | 2140 (11703980) | Likely decreasing | 0.86 (0.63 – 1.1) | -0.032 (-0.092 – 0.027) | -22 (25 – -7.5) |
| realland | 2148 (11414237) | Likely decreasing | 0.85 (0.63 – 1.2) | -0.033 (-0.093 – 0.032) | -21 (22 – -7.4) |
| testland | 2153 (11504004) | Likely decreasing | 0.86 (0.63 – 1.1) | -0.032 (-0.091 – 0.027) | -22 (26 – -7.6) |

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 40ee5e2

Please sign in to comment.