diff --git a/dev/CONTRIBUTING.html b/dev/CONTRIBUTING.html index 955073434..08a016144 100644 --- a/dev/CONTRIBUTING.html +++ b/dev/CONTRIBUTING.html @@ -83,7 +83,7 @@
Make your changes, commit to git, and then create a PR by running usethis::pr_push()
, and following the prompts in your browser. The title of your PR should briefly describe the change. The body of your PR should contain Fixes #issue-number
.
Make your changes, commit to git, and then create a PR by running usethis::pr_push()
, and following the prompts in your browser. The title of your PR should briefly describe the change. The body of your PR should contain Fixes #issue-number
.
For user-facing changes, add a bullet to the top of NEWS.md
(i.e. just below the first header). Follow the style described in https://style.tidyverse.org/news.html.
head(summary(estimates, type = "parameters", params = "R"))
#> date variable strat type median mean sd lower_90
-#> 1: 2020-02-22 R NA estimate 2.140044 2.142893 0.13818099 1.937615
-#> 2: 2020-02-23 R NA estimate 2.105628 2.106892 0.11415164 1.936612
-#> 3: 2020-02-24 R NA estimate 2.068985 2.069442 0.09420757 1.921287
-#> 4: 2020-02-25 R NA estimate 2.031434 2.030725 0.07830576 1.907767
-#> 5: 2020-02-26 R NA estimate 1.991226 1.990969 0.06634858 1.884688
-#> 6: 2020-02-27 R NA estimate 1.950962 1.950427 0.05807390 1.856440
+#> 1: 2020-02-22 R NA estimate 2.132829 2.137525 0.13485496 1.922173
+#> 2: 2020-02-23 R NA estimate 2.098537 2.101913 0.11121883 1.924287
+#> 3: 2020-02-24 R NA estimate 2.064197 2.064871 0.09229141 1.917506
+#> 4: 2020-02-25 R NA estimate 2.025665 2.026552 0.07781861 1.900920
+#> 5: 2020-02-26 R NA estimate 1.985770 1.987160 0.06736735 1.878103
+#> 6: 2020-02-27 R NA estimate 1.946217 1.946932 0.06027737 1.849663
#> lower_50 lower_20 upper_20 upper_50 upper_90
-#> 1: 2.046299 2.104219 2.174057 2.232616 2.370781
-#> 2: 2.025782 2.075403 2.132810 2.182697 2.294095
-#> 3: 2.003747 2.044222 2.090967 2.131610 2.225019
-#> 4: 1.977390 2.010528 2.048636 2.082264 2.163819
-#> 5: 1.944677 1.974170 2.008207 2.035011 2.103163
-#> 6: 1.910567 1.935790 1.965265 1.988672 2.046538
Reported cases are returned in a separate data frame in order to streamline the reporting of forecasts and for model evaluation.
head(summary(estimates, output = "estimated_reported_cases"))
#> date type median mean sd lower_90 lower_50 lower_20
-#> 1: 2020-02-22 gp_rt 65.5 67.2870 18.83096 40 54 61
-#> 2: 2020-02-23 gp_rt 78.0 78.8395 21.73755 47 63 72
-#> 3: 2020-02-24 gp_rt 77.0 78.8920 21.59142 47 64 72
-#> 4: 2020-02-25 gp_rt 73.0 75.0705 20.82804 45 61 68
-#> 5: 2020-02-26 gp_rt 78.0 79.8325 22.03166 47 65 73
-#> 6: 2020-02-27 gp_rt 110.0 112.9160 28.92359 71 92 103
+#> 1: 2020-02-22 gp_rt 61 62.9225 16.90344 39.00 51 57.0
+#> 2: 2020-02-23 gp_rt 76 77.0560 20.88159 46.00 62 70.6
+#> 3: 2020-02-24 gp_rt 77 79.0875 21.69463 48.95 64 72.0
+#> 4: 2020-02-25 gp_rt 75 76.1825 20.03599 46.00 62 70.0
+#> 5: 2020-02-26 gp_rt 79 81.1295 22.38634 49.00 65 74.0
+#> 6: 2020-02-27 gp_rt 113 115.4200 28.91020 71.00 95 106.0
#> upper_20 upper_50 upper_90
-#> 1: 70 79.00 101
-#> 2: 83 92.00 117
-#> 3: 82 92.00 116
-#> 4: 78 87.00 115
-#> 5: 83 91.25 120
-#> 6: 118 130.00 165
A range of plots are returned (with the single summary plot shown below). These plots can also be generated using the following plot
method.
plot(estimates)
Results from each region are stored in a regional
list with across region summary measures and plots stored in a summary
list. All results can be set to be internally saved by setting the target_folder
and summary_dir
arguments. Each region can be estimated in parallel using the future package (when in most scenarios cores
should be set to 1). For routine use each MCMC chain can also be run in parallel (with future
= TRUE) with a time out (max_execution_time
) allowing for partial results to be returned if a subset of chains is running longer than expected. See the documentation for the future package for details on nested futures.
Summary measures that are returned include a table formatted for reporting (along with raw results for further processing). Futures updated will extend the S3 methods used above to smooth access to this output.
@@ -341,19 +344,19 @@
realland -2176 (1192 – 4065) +2150 (1109 – 4062) Likely decreasing -0.87 (0.65 – 1.1) --0.032 (-0.096 – 0.03) --22 (23 – -7.2) +0.86 (0.64 – 1.1) +-0.033 (-0.098 – 0.029) +-21 (24 – -7.1) diff --git a/dev/news/index.html b/dev/news/index.html index 050435393..08435028b 100644 --- a/dev/news/index.html +++ b/dev/news/index.html @@ -61,6 +61,10 @@ testland -2217 (1150 – 4155) +2149 (1182 – 4040) Likely decreasing -0.87 (0.64 – 1.2) --0.031 (-0.099 – 0.036) --23 (19 – -7) +0.87 (0.66 – 1.2) +-0.031 (-0.093 – 0.035) +-22 (20 – -7.4) EpiNow2 1.4.0
CRAN release: 2023-09-26
diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index 0259910cc..85a1028b9 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -7,7 +7,7 @@ articles: estimate_secondary: estimate_secondary.html estimate_truncation: estimate_truncation.html gaussian_process_implementation_details: gaussian_process_implementation_details.html -last_built: 2023-09-27T17:02Z +last_built: 2023-10-03T09:53Z urls: reference: epiforecasts.io/EpiNow2/reference article: epiforecasts.io/EpiNow2/articles diff --git a/dev/reference/Rplot002.png b/dev/reference/Rplot002.png index 6f2409f5e..733407b51 100644 Binary files a/dev/reference/Rplot002.png and b/dev/reference/Rplot002.png differ diff --git a/dev/reference/Rplot003.png b/dev/reference/Rplot003.png index 099f44a16..70c392df7 100644 Binary files a/dev/reference/Rplot003.png and b/dev/reference/Rplot003.png differ diff --git a/dev/reference/Rplot004.png b/dev/reference/Rplot004.png index 6a586cb68..8adce7296 100644 Binary files a/dev/reference/Rplot004.png and b/dev/reference/Rplot004.png differ diff --git a/dev/reference/Rplot005.png b/dev/reference/Rplot005.png index 4d67da014..afc56dc5e 100644 Binary files a/dev/reference/Rplot005.png and b/dev/reference/Rplot005.png differ diff --git a/dev/reference/Rplot006.png b/dev/reference/Rplot006.png index 96b7a9b2e..75f016df9 100644 Binary files a/dev/reference/Rplot006.png and b/dev/reference/Rplot006.png differ diff --git a/dev/reference/Rplot007.png b/dev/reference/Rplot007.png index 25fb0a44b..747a543b4 100644 Binary files a/dev/reference/Rplot007.png and b/dev/reference/Rplot007.png differ diff --git a/dev/reference/Rplot008.png b/dev/reference/Rplot008.png index 1793e835a..82740d2cf 100644 Binary files a/dev/reference/Rplot008.png and b/dev/reference/Rplot008.png differ diff --git a/dev/reference/Rplot009.png b/dev/reference/Rplot009.png index 854c70588..edd408050 100644 Binary files a/dev/reference/Rplot009.png and b/dev/reference/Rplot009.png differ diff --git a/dev/reference/adjust_infection_to_report.html b/dev/reference/adjust_infection_to_report.html index d0aa172aa..39a39e35a 100644 --- a/dev/reference/adjust_infection_to_report.html +++ b/dev/reference/adjust_infection_to_report.html @@ -158,17 +158,17 @@Examples) print(report) #> date cases -#> 1: 2020-02-24 1 -#> 2: 2020-02-25 3 -#> 3: 2020-02-26 3 -#> 4: 2020-02-27 7 -#> 5: 2020-02-28 19 +#> 1: 2020-02-24 2 +#> 2: 2020-02-25 6 +#> 3: 2020-02-26 12 +#> 4: 2020-02-27 23 +#> 5: 2020-02-28 28 #> --- -#> 124: 2020-06-26 298 -#> 125: 2020-06-27 238 -#> 126: 2020-06-28 222 -#> 127: 2020-06-29 241 -#> 128: 2020-06-30 279 +#> 124: 2020-06-26 216 +#> 125: 2020-06-27 230 +#> 126: 2020-06-28 231 +#> 127: 2020-06-29 243 +#> 128: 2020-06-30 238 # mapping with a weekly reporting effect report_weekly <- adjust_infection_to_report( @@ -178,17 +178,17 @@
Examples) print(report_weekly) #> date cases -#> 1: 2020-02-25 2 -#> 2: 2020-02-26 3 -#> 3: 2020-02-27 8 -#> 4: 2020-02-28 12 -#> 5: 2020-02-29 22 +#> 1: 2020-02-25 5 +#> 2: 2020-02-26 8 +#> 3: 2020-02-27 24 +#> 4: 2020-02-28 23 +#> 5: 2020-02-29 39 #> --- -#> 123: 2020-06-26 250 -#> 124: 2020-06-27 229 -#> 125: 2020-06-28 219 -#> 126: 2020-06-29 259 -#> 127: 2020-06-30 265 +#> 123: 2020-06-26 219 +#> 124: 2020-06-27 181 +#> 125: 2020-06-28 251 +#> 126: 2020-06-29 277 +#> 127: 2020-06-30 242 # map using a deterministic median shift for both delays report_median <- adjust_infection_to_report(cases, @@ -197,17 +197,17 @@
Examples) print(report_median) #> date confirm cases -#> 1: 2020-03-02 14 14 -#> 2: 2020-03-03 62 62 -#> 3: 2020-03-04 53 53 -#> 4: 2020-03-05 97 97 -#> 5: 2020-03-06 93 93 +#> 1: 2020-02-29 14 14 +#> 2: 2020-03-01 62 62 +#> 3: 2020-03-02 53 53 +#> 4: 2020-03-03 97 97 +#> 5: 2020-03-04 93 93 #> --- -#> 126: 2020-07-05 296 296 -#> 127: 2020-07-06 255 255 -#> 128: 2020-07-07 175 175 -#> 129: 2020-07-08 174 174 -#> 130: 2020-07-09 126 126 +#> 126: 2020-07-03 296 296 +#> 127: 2020-07-04 255 255 +#> 128: 2020-07-05 175 175 +#> 129: 2020-07-06 174 174 +#> 130: 2020-07-07 126 126 # map with a weekly reporting effect and stochastic reporting model report_stochastic <- adjust_infection_to_report( @@ -221,17 +221,17 @@
Examples) print(report_stochastic) #> date cases -#> 1: 2020-02-25 3 -#> 2: 2020-02-26 0 -#> 3: 2020-02-27 4 -#> 4: 2020-02-28 26 -#> 5: 2020-02-29 41 +#> 1: 2020-02-24 1 +#> 2: 2020-02-25 3 +#> 3: 2020-02-26 22 +#> 4: 2020-02-27 10 +#> 5: 2020-02-28 42 #> --- -#> 123: 2020-06-26 273 -#> 124: 2020-06-27 201 -#> 125: 2020-06-28 232 -#> 126: 2020-06-29 263 -#> 127: 2020-06-30 259 +#> 124: 2020-06-26 190 +#> 125: 2020-06-27 187 +#> 126: 2020-06-28 230 +#> 127: 2020-06-29 279 +#> 128: 2020-06-30 264 # }
# \donttest{
-# construct example distributions
-generation_time <- get_generation_time(
- disease = "SARS-CoV-2", source = "ganyani"
-)
-incubation_period <- get_incubation_period(
- disease = "SARS-CoV-2", source = "lauer"
-)
-reporting_delay <- estimate_delay(rlnorm(100, log(6), 1), max_value = 10)
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-
-# example case vector
-cases <- example_confirmed[1:30]
-cases <- data.table::rbindlist(list(
- data.table::copy(cases)[, region := "testland"],
- cases[, region := "realland"]
+ # get example multiregion estimates
+regional_out <- readRDS(system.file(
+ package = "EpiNow2", "extdata", "example_regional_epinow.rds"
))
-# save results to tmp folder
-dir <- file.path(tempdir(check = TRUE), "results")
-# run multiregion estimates
-regional_out <- regional_epinow(
- reported_cases = cases,
- generation_time = generation_time_opts(generation_time),
- delays = delay_opts(incubation_period + reporting_delay),
- rt = rt_opts(rw = 7), gp = NULL,
- output = c("regions", "latest"),
- target_folder = dir,
- return_output = TRUE
-)
-#> INFO [2023-09-27 17:31:36] Producing following optional outputs: regions, latest
-#> Logging threshold set at INFO for the EpiNow2 logger
-#> Writing EpiNow2 logs to the console and: /tmp/RtmpYkZBel/regional-epinow/2020-03-22.log
-#> Logging threshold set at INFO for the EpiNow2.epinow logger
-#> Writing EpiNow2.epinow logs to: /tmp/RtmpYkZBel/epinow/2020-03-22.log
-#> INFO [2023-09-27 17:31:36] Reporting estimates using data up to: 2020-03-22
-#> INFO [2023-09-27 17:31:36] Saving estimates to : /tmp/RtmpYkZBel/results
-#> INFO [2023-09-27 17:31:36] Producing estimates for: testland, realland
-#> INFO [2023-09-27 17:31:36] Regions excluded: none
-#> INFO [2023-09-27 17:32:05] Completed estimates for: testland
-#> INFO [2023-09-27 17:32:30] Completed estimates for: realland
-#> INFO [2023-09-27 17:32:30] Completed regional estimates
-#> INFO [2023-09-27 17:32:30] Regions with estimates: 2
-#> INFO [2023-09-27 17:32:30] Regions with runtime errors: 0
-#> INFO [2023-09-27 17:32:30] Saving timings information to : /tmp/RtmpYkZBel/results
# from output
results <- get_regional_results(regional_out$regional, samples = FALSE)
-names(results)
-#> [1] "estimates"
-
-# from a folder
-folder_results <- get_regional_results(results_dir = dir, samples = FALSE)
-names(folder_results)
-#> [1] "estimates"
-# }
# \donttest{
-# define example cases
-cases <- example_confirmed[1:40]
+ # get example model results
+out <- readRDS(system.file(
+ package = "EpiNow2", "extdata", "example_estimate_infections.rds"
+))
-# set up example delays
-generation_time <- get_generation_time(
- disease = "SARS-CoV-2", source = "ganyani"
-)
-incubation_period <- get_incubation_period(
- disease = "SARS-CoV-2", source = "lauer"
-)
-reporting_delay <- estimate_delay(rlnorm(100, log(6), 1), max_value = 10)
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally.
-
-# run model
-out <- estimate_infections(cases,
- generation_time = generation_time_opts(generation_time),
- delays = delay_opts(incubation_period + reporting_delay)
-)
-#> Warning: There were 10 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.
-#> Warning: Examine the pairs() plot to diagnose sampling problems
# plot infections
plot_estimates(
estimate = out$summarised[variable == "infections"],
- reported = cases,
+ reported = out$observations,
ylab = "Cases", max_plot = 2
) + ggplot2::facet_wrap(~type, scales = "free_y")
@@ -178,7 +151,7 @@ Examples# plot reported cases estimated via Rt
plot_estimates(
estimate = out$summarised[variable == "reported_cases"],
- reported = cases,
+ reported = out$observations,
ylab = "Cases"
)
@@ -198,7 +171,6 @@ Examples hline = 1, estimate_type = "Estimate"
)
-# }