diff --git a/dev/articles/epinow.html b/dev/articles/epinow.html new file mode 100644 index 000000000..53672f043 --- /dev/null +++ b/dev/articles/epinow.html @@ -0,0 +1,290 @@ + + + + + + + + +Using epinow() for running in production mode • EpiNow2 + + + + + + + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + +

The EpiNow2 package contains functionality to run +estimate_infections() in production mode, i.e. with full +logging and saving all relevant outputs and plots to dedicated folders +in the hard drive. This is done with the epinow() function, +that takes the same options as estimate_infections() with +some additional options that determine, for example, where output gets +stored and what output exactly. The function can be a useful option +when, e.g., running the model daily with updated data on a +high-performance computing server to feed into a dashboard. For more +detail on the various model options available, see the Examples vignette, for more +on the general modelling approach the Workflow, and for +theoretical background the Model +definitions vignette

+
+

Running the model on a single region +

+

To run the model in production mode for a single region, set the +parameters up in the same way as for estimate_infections() +(see the Workflow +vignette). Here we use the example delay and generation time +distributions that come with the package. This should be replaced with +parameters relevant to the system that is being studied.

+
+library("EpiNow2")
+options(mc.cores = 4)
+reported_cases <- example_confirmed[1:60]
+incubation_period <- get_incubation_period(
+  disease = "SARS-CoV-2", source = "lauer"
+)
+reporting_delay <- dist_spec(
+  mean = convert_to_logmean(2, 1), mean_sd = 0,
+  sd = convert_to_logsd(2, 1), sd_sd = 0, max = 10
+)
+delay <- incubation_period + reporting_delay
+generation_time <- get_generation_time(
+  disease = "SARS-CoV-2", source = "ganyani"
+)
+rt_prior <- list(mean = 2, sd = 0.1)
+

We can then run the epinow() function with the same +arguments as estimate_infections().

+
+res <- epinow(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(prior = rt_prior),
+  target_folder = "results"
+)
+#> Logging threshold set at INFO for the EpiNow2 logger
+#> Writing EpiNow2 logs to the console and: /var/folders/gd/x84kkjzd6bn9rlf3f2v830c00000gp/T//Rtmp2g83K0/regional-epinow/2020-04-21.log
+#> Logging threshold set at INFO for the EpiNow2.epinow logger
+#> Writing EpiNow2.epinow logs to the console and: /var/folders/gd/x84kkjzd6bn9rlf3f2v830c00000gp/T//Rtmp2g83K0/epinow/2020-04-21.log
+#> WARN [2023-10-02 20:01:50] epinow: There were 17 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-02 20:01:50] epinow: Examine the pairs() plot to diagnose sampling problems
+#>  -
+res$plots$R
+#> NULL
+

The initial messages here indicate where log files can be found, and +summarised results and plots are in the folder given by +target_folder (here: results/).

+
+
+

Running the model simultaneously on multiple regions +

+

The package also contains functionality to conduct inference +contemporaneously (if separately) in production mode on multiple time +series, e.g. to run the model on multiple regions. This is done with the +regional_epinow() function.

+

Say, for example, we construct a dataset containing two regions, +testland and realland (in this simple example +both containing the same case data).

+
+cases <- example_confirmed[1:60]
+cases <- data.table::rbindlist(list(
+  data.table::copy(cases)[, region := "testland"],
+  cases[, region := "realland"]
+ ))
+

To then run this on multiple regions using the default options above, +we could use

+
+region_rt <- regional_epinow(
+  reported_cases = cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(prior = rt_prior),
+)
+#> INFO [2023-10-02 20:01:56] Producing following optional outputs: regions, summary, samples, plots, latest
+#> Logging threshold set at INFO for the EpiNow2 logger
+#> Writing EpiNow2 logs to the console and: /var/folders/gd/x84kkjzd6bn9rlf3f2v830c00000gp/T//Rtmp2g83K0/regional-epinow/2020-04-21.log
+#> Logging threshold set at INFO for the EpiNow2.epinow logger
+#> Writing EpiNow2.epinow logs to: /var/folders/gd/x84kkjzd6bn9rlf3f2v830c00000gp/T//Rtmp2g83K0/epinow/2020-04-21.log
+#> INFO [2023-10-02 20:01:56] Reporting estimates using data up to: 2020-04-21
+#> INFO [2023-10-02 20:01:56] No target directory specified so returning output
+#> INFO [2023-10-02 20:01:56] Producing estimates for: testland, realland
+#> INFO [2023-10-02 20:01:56] Regions excluded: none
+#> INFO [2023-10-02 20:03:16] Completed estimates for: testland
+#> INFO [2023-10-02 20:04:44] Completed estimates for: realland
+#> INFO [2023-10-02 20:04:44] Completed regional estimates
+#> INFO [2023-10-02 20:04:44] Regions with estimates: 2
+#> INFO [2023-10-02 20:04:44] Regions with runtime errors: 0
+#> INFO [2023-10-02 20:04:44] Producing summary
+#> INFO [2023-10-02 20:04:44] No summary directory specified so returning summary output
+#> INFO [2023-10-02 20:04:45] No target directory specified so returning timings
+## summary
+region_rt$summary$summarised_results$table
+#>      Region New confirmed cases by infection date
+#> 1: realland                   2243 (1148 -- 4405)
+#> 2: testland                   2327 (1127 -- 4494)
+#>    Expected change in daily cases Effective reproduction no.
+#> 1:              Likely decreasing         0.88 (0.62 -- 1.2)
+#> 2:              Likely decreasing         0.89 (0.61 -- 1.2)
+#>              Rate of growth Doubling/halving time (days)
+#> 1: -0.028 (-0.095 -- 0.037)             -25 (19 -- -7.3)
+#> 2: -0.025 (-0.098 -- 0.042)             -27 (17 -- -7.1)
+## plot
+region_rt$summary$plots$R
+
+

plot of chunk regional_epinow

+
+

If instead, we wanted to use the Gaussian Process for +testland and a weekly random walk for realland +we could specify these separately using the opts_list() and +update_list() functions

+
+gp <- opts_list(gp_opts(), cases)
+gp <- update_list(gp, list(realland = NULL))
+rt <- opts_list(rt_opts(), cases, realland = rt_opts(rw = 7))
+region_separate_rt <- regional_epinow(
+  reported_cases = cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt, gp = gp,
+)
+#> INFO [2023-10-02 20:04:45] Producing following optional outputs: regions, summary, samples, plots, latest
+#> Logging threshold set at INFO for the EpiNow2 logger
+#> Writing EpiNow2 logs to the console and: /var/folders/gd/x84kkjzd6bn9rlf3f2v830c00000gp/T//Rtmp2g83K0/regional-epinow/2020-04-21.log
+#> Logging threshold set at INFO for the EpiNow2.epinow logger
+#> Writing EpiNow2.epinow logs to: /var/folders/gd/x84kkjzd6bn9rlf3f2v830c00000gp/T//Rtmp2g83K0/epinow/2020-04-21.log
+#> INFO [2023-10-02 20:04:45] Reporting estimates using data up to: 2020-04-21
+#> INFO [2023-10-02 20:04:45] No target directory specified so returning output
+#> INFO [2023-10-02 20:04:45] Producing estimates for: testland, realland
+#> INFO [2023-10-02 20:04:45] Regions excluded: none
+#> INFO [2023-10-02 20:06:46] Completed estimates for: testland
+#> INFO [2023-10-02 20:07:21] Completed estimates for: realland
+#> INFO [2023-10-02 20:07:21] Completed regional estimates
+#> INFO [2023-10-02 20:07:21] Regions with estimates: 2
+#> INFO [2023-10-02 20:07:21] Regions with runtime errors: 0
+#> INFO [2023-10-02 20:07:21] Producing summary
+#> INFO [2023-10-02 20:07:21] No summary directory specified so returning summary output
+#> INFO [2023-10-02 20:07:21] No target directory specified so returning timings
+## summary
+region_separate_rt$summary$summarised_results$table
+#>      Region New confirmed cases by infection date
+#> 1: realland                   2168 (1094 -- 4167)
+#> 2: testland                   2233 (1014 -- 4477)
+#>    Expected change in daily cases Effective reproduction no.
+#> 1:              Likely decreasing         0.86 (0.61 -- 1.2)
+#> 2:              Likely decreasing         0.88 (0.56 -- 1.2)
+#>              Rate of growth Doubling/halving time (days)
+#> 1: -0.032 (-0.096 -- 0.034)             -22 (20 -- -7.2)
+#> 2:  -0.028 (-0.11 -- 0.044)             -25 (16 -- -6.1)
+## plot
+region_separate_rt$summary$plots$R
+
+

plot of chunk regional_epinow_multiple

+
+
+
+
+ + + + +
+ + + + + + + diff --git a/dev/articles/estimate_infections_options.html b/dev/articles/estimate_infections_options.html new file mode 100644 index 000000000..9d9e51a27 --- /dev/null +++ b/dev/articles/estimate_infections_options.html @@ -0,0 +1,647 @@ + + + + + + + + +Examples: estimate_infections() • EpiNow2 + + + + + + + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + +

The estimate_infections() function encodes a range of +different model options. In this vignette we apply some of these to the +example data provided with the EpiNow2 package, highlighting +differences in inference results and run times. It is not meant as a +comprehensive exploration of all the functionality in the package, but +intended to give users a flavour of the kind of model options that exist +for reproduction number estimation and forecasting within the package, +and the differences in computational speed between them. For +mathematical detail on the model please consult the model definition vignette, and for a +more general description of the use of the function, the estimate_infections +workflow vignette.

+
+

Set up +

+

We first load the EpiNow2 package and also the +rstan package that we will use later to show the differences in +run times between different model options.

+
+library("EpiNow2")
+#> Loading required namespace: V8
+library("rstan")
+#> Loading required package: StanHeaders
+#> 
+#> rstan version 2.26.24 (Stan version 2.26.1)
+#> For execution on a local, multicore CPU with excess RAM we recommend calling
+#> options(mc.cores = parallel::detectCores()).
+#> To avoid recompilation of unchanged Stan programs, we recommend calling
+#> rstan_options(auto_write = TRUE)
+#> For within-chain threading using `reduce_sum()` or `map_rect()` Stan functions,
+#> change `threads_per_chain` option:
+#> rstan_options(threads_per_chain = 1)
+

In this examples we set the number of cores to use to 4 but the +optimal value here will depend on the computing resources available.

+
+options(mc.cores = 4)
+
+
+

Data +

+

We will use an example data set that is included in the package, +representing an outbreak of COVID-19 with an initial rapid increase +followed by decreasing incidence.

+
+library("ggplot2")
+reported_cases <- example_confirmed[1:60]
+ggplot(reported_cases, aes(x =  date, y = confirm)) +
+  geom_col() +
+  theme_minimal() +
+  xlab("Date") +
+  ylab("Cases")
+
+

plot of chunk data

+
+
+
+

Parameters +

+

Before running the model we need to decide on some parameter values, +in particular any delays, the generation time, and a prior on the +initial reproduction number.

+
+

Delays: incubation period and reporting delay +

+

Delays reflect the time that passes between infection and reporting, +if these exist. In this example, we assume two delays, an incubation +period (i.e. delay from infection to symptom onset) and a +reporting delay (i.e. the delay from symptom onset to being +recorded as a symptomatic case). These delays are usually not the same +for everyone and are instead characterised by a distribution. For the +incubation period we use an example from the literature that is included +in the package.

+
+incubation_period <- get_incubation_period(
+  disease = "SARS-CoV-2", source = "lauer"
+)
+incubation_period
+#> 
+#>   Uncertain lognormal distribution with (untruncated) logmean 1.6 (SD 0.064) and logSD 0.42 (SD 0.069)
+

For the reporting delay, we use a lognormal distribution with mean of +2 days and standard deviation of 1 day. Note that the mean and standard +deviation must be converted to the log scale, which can be done using +the convert_log_logmean() function.

+
+reporting_delay <- dist_spec(
+  mean = convert_to_logmean(2, 1), mean_sd = 0,
+  sd = convert_to_logsd(2, 1), sd_sd = 0, max = 10
+)
+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]
+

EpiNow2 provides a feature that allows us to combine these +delays into one by summing them up

+
+delay <- incubation_period + reporting_delay
+delay
+#> 
+#> Combination of delay distributions:
+#>   Uncertain lognormal distribution with (untruncated) logmean 1.6 (SD 0.064) and logSD 0.42 (SD 0.069)
+#>   Fixed distribution with PMF [0.11 0.48 0.27 0.093 0.029 0.0096 0.0033 0.0012 0.00045 0.00018]
+
+
+

Generation time +

+

If we want to estimate the reproduction number we need to provide a +distribution of generation times. Here again we use an example from the +literature that is included with the package.

+
+generation_time <- get_generation_time(
+  disease = "SARS-CoV-2", source = "ganyani"
+)
+generation_time
+#> 
+#>   Uncertain gamma distribution with (untruncated) mean 3.6 (SD 0.71) and SD 3.1 (SD 0.77)
+
+
+

Initial reproduction number +

+

Lastly we need to choose a prior for the initial value of the +reproduction number. This is assumed by the model to be normally +distributed and we can set the mean and the standard deviation. We +decide to set the mean to 2 and the standard deviation to 1.

+
+rt_prior <- list(mean = 2, sd = 0.1)
+
+
+
+

Running the model +

+

We are now ready to run the model and will in the following show a +number of possible options for doing so.

+
+

Default options +

+

By default the model uses a renewal equation for infections and a +Gaussian Process prior for the reproduction number. Putting all the data +and parameters together and tweaking the Gaussian Process to have a +shorter length scale prior than the default we run.

+
+def <- estimate_infections(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(prior = rt_prior)
+)
+#> Warning: There were 18 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
+# summarise results
+summary(def)
+#>                                  measure                 estimate
+#> 1: New confirmed cases by infection date      2248 (1143 -- 4365)
+#> 2:        Expected change in daily cases        Likely decreasing
+#> 3:            Effective reproduction no.       0.88 (0.62 -- 1.2)
+#> 4:                        Rate of growth -0.028 (-0.095 -- 0.037)
+#> 5:          Doubling/halving time (days)         -25 (19 -- -7.3)
+# elapsed time (in seconds)
+get_elapsed_time(def$fit)
+#>         warmup sample
+#> chain:1 47.203 35.025
+#> chain:2 44.973 36.144
+#> chain:3 55.958 31.756
+#> chain:4 42.884 35.091
+# summary plot
+plot(def)
+
+

plot of chunk default

+
+
+
+

Reducing the accuracy of the approximate Gaussian Process +

+

To speed up the calculation of the Gaussian Process we could decrease +its accuracy, e.g. decrease the proportion of time points to use as +basis functions from the default of 0.2 to 0.1.

+
+agp <- estimate_infections(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(prior = rt_prior),
+  gp = gp_opts(basis_prop = 0.1)
+)
+#> Warning: There were 9 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
+# summarise results
+summary(agp)
+#>                                  measure                 estimate
+#> 1: New confirmed cases by infection date      2321 (1229 -- 4588)
+#> 2:        Expected change in daily cases        Likely decreasing
+#> 3:            Effective reproduction no.       0.89 (0.65 -- 1.2)
+#> 4:                        Rate of growth -0.024 (-0.087 -- 0.041)
+#> 5:          Doubling/halving time (days)         -28 (17 -- -7.9)
+# elapsed time (in seconds)
+get_elapsed_time(agp$fit)
+#>         warmup sample
+#> chain:1 28.912 48.824
+#> chain:2 25.219 30.999
+#> chain:3 32.968 32.434
+#> chain:4 37.553 30.607
+# summary plot
+plot(agp)
+
+

plot of chunk lower_accuracy

+
+
+
+

Adjusting for future susceptible depletion +

+

We might want to adjust for future susceptible depletion. Here, we do +so by setting the population to 1000000 and projecting the reproduction +number from the latest estimate (rather than the default, which fixes +the reproduction number to an earlier time point based on the given +reporting delays). Note that this only affects the forecasts and is done +using a crude adjustment (see the model definition).

+
+dep <- estimate_infections(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(
+    prior = rt_prior,
+    pop = 1000000, future = "latest"
+  )
+)
+#> Warning: There were 3 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
+# summarise results
+summary(dep)
+#>                                  measure               estimate
+#> 1: New confirmed cases by infection date    2269 (1117 -- 4377)
+#> 2:        Expected change in daily cases      Likely decreasing
+#> 3:            Effective reproduction no.      0.88 (0.6 -- 1.2)
+#> 4:                        Rate of growth -0.027 (-0.1 -- 0.037)
+#> 5:          Doubling/halving time (days)       -26 (19 -- -6.9)
+# elapsed time (in seconds)
+get_elapsed_time(dep$fit)
+#>         warmup sample
+#> chain:1 44.156 39.473
+#> chain:2 48.509 61.754
+#> chain:3 49.279 47.867
+#> chain:4 53.546 38.343
+# summary plot
+plot(dep)
+
+

plot of chunk susceptible_depletion

+
+
+
+

Adjusting for truncation of the most recent data +

+

We might further want to adjust for right-truncation of recent data +estimated using the estimate_truncation model. Here, +instead of doing so we assume that we know about truncation with mean of +1/2 day, sd 1/2 day, following a lognormal distribution and with a +maximum of three days.

+
+trunc_dist <- dist_spec(
+  mean = convert_to_logmean(0.5, 0.5), mean_sd = 0.1,
+  sd = convert_to_logsd(0.5, 0.5), sd_sd = 0.1,
+  max = 3
+)
+

We can then use this in the esimtate_infections() +function using the truncation option.

+
+trunc <- estimate_infections(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  truncation = trunc_opts(trunc_dist),
+  rt = rt_opts(prior = rt_prior)
+)
+#> Warning: There were 2 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
+# summarise results
+summary(trunc)
+#>                                  measure                 estimate
+#> 1: New confirmed cases by infection date      2522 (1296 -- 4745)
+#> 2:        Expected change in daily cases        Likely decreasing
+#> 3:            Effective reproduction no.       0.92 (0.66 -- 1.2)
+#> 4:                        Rate of growth -0.018 (-0.085 -- 0.045)
+#> 5:          Doubling/halving time (days)         -38 (15 -- -8.2)
+# elapsed time (in seconds)
+get_elapsed_time(trunc$fit)
+#>         warmup sample
+#> chain:1 50.283 45.799
+#> chain:2 41.206 45.834
+#> chain:3 37.676 73.545
+#> chain:4 52.158 47.402
+# summary plot
+plot(trunc)
+
+

plot of chunk truncation

+
+
+
+

Projecting the reproduction number with the Gaussian Process +

+

Instead of keeping the reproduction number fixed from a certain time +point we might want to extrapolate the Gaussian Process into the future. +This will lead to wider uncertainty, and the researcher should check +whether this or fixing the reproduction number from an earlier is +desirable.

+
+project_rt <- estimate_infections(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(
+    prior = rt_prior, future = "project"
+  )
+)
+#> Warning: There were 8 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
+# summarise results
+summary(project_rt)
+#>                                  measure              estimate
+#> 1: New confirmed cases by infection date   2236 (1068 -- 4349)
+#> 2:        Expected change in daily cases     Likely decreasing
+#> 3:            Effective reproduction no.    0.87 (0.59 -- 1.2)
+#> 4:                        Rate of growth -0.028 (-0.1 -- 0.04)
+#> 5:          Doubling/halving time (days)      -25 (17 -- -6.7)
+# elapsed time (in seconds)
+get_elapsed_time(project_rt$fit)
+#>         warmup sample
+#> chain:1 31.483 37.108
+#> chain:2 35.041 36.827
+#> chain:3 35.983 41.154
+#> chain:4 37.730 56.884
+# summary plot
+plot(project_rt)
+
+

plot of chunk gp_projection

+
+
+
+

Fixed reproduction number +

+

We might want to estimate a fixed reproduction number, i.e. assume +that it does not change.

+
+fixed <- estimate_infections(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  gp = NULL
+)
+# summarise results
+summary(fixed)
+#>                                  measure              estimate
+#> 1: New confirmed cases by infection date 15823 (8907 -- 29156)
+#> 2:        Expected change in daily cases            Increasing
+#> 3:            Effective reproduction no.      1.2 (1.1 -- 1.3)
+#> 4:                        Rate of growth 0.038 (0.026 -- 0.05)
+#> 5:          Doubling/halving time (days)         18 (14 -- 26)
+# elapsed time (in seconds)
+get_elapsed_time(fixed$fit)
+#>         warmup sample
+#> chain:1  2.195  0.946
+#> chain:2  1.797  1.289
+#> chain:3  2.017  0.947
+#> chain:4  1.555  1.498
+# summary plot
+plot(fixed)
+
+

plot of chunk fixed

+
+
+
+

Breakpoints +

+

Instead of assuming the reproduction number varies freely or is +fixed, we can assume that it is fixed but with breakpoints. This can be +done by adding a breakpoint column to the reported case +data set. e.g. if we think that the reproduction number was constant but +would like to allow it to change on the 16th of March 2020 we would +define a new case data set using

+
+bp_cases <- data.table::copy(reported_cases)
+bp_cases <- bp_cases[,
+ breakpoint := ifelse(date == as.Date("2020-03-16"), 1, 0)
+]
+

We then use this instead of reported_cases in the +estimate_infections() function:

+
+bkp <- estimate_infections(bp_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(prior = rt_prior),
+  gp = NULL
+)
+# summarise results
+summary(bkp)
+#>                                  measure                 estimate
+#> 1: New confirmed cases by infection date      2465 (2051 -- 3002)
+#> 2:        Expected change in daily cases               Decreasing
+#> 3:            Effective reproduction no.      0.91 (0.88 -- 0.93)
+#> 4:                        Rate of growth -0.02 (-0.026 -- -0.015)
+#> 5:          Doubling/halving time (days)         -34 (-46 -- -26)
+# elapsed time (in seconds)
+get_elapsed_time(bkp$fit)
+#>         warmup sample
+#> chain:1  3.299  4.363
+#> chain:2  3.731  4.280
+#> chain:3  3.246  3.890
+#> chain:4  3.468  4.295
+# summary plot
+plot(bkp)
+
+

plot of chunk bp

+
+
+
+

Weekly random walk +

+

Instead of a smooth Gaussian Process we might want the reproduction +number to change step-wise, e.g. every week. This can be achieved using +the rw option which defines the length of the time step in +a random walk that the reproduction number is assumed to follow.

+
+rw <- estimate_infections(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(prior = rt_prior, rw = 7),
+  gp = NULL
+)
+# summarise results
+summary(rw)
+#>                                  measure                 estimate
+#> 1: New confirmed cases by infection date      2125 (1162 -- 3967)
+#> 2:        Expected change in daily cases        Likely decreasing
+#> 3:            Effective reproduction no.       0.86 (0.64 -- 1.1)
+#> 4:                        Rate of growth -0.032 (-0.088 -- 0.028)
+#> 5:          Doubling/halving time (days)         -22 (24 -- -7.8)
+# elapsed time (in seconds)
+get_elapsed_time(rw$fit)
+#>         warmup sample
+#> chain:1 10.352 12.955
+#> chain:2  9.689 14.484
+#> chain:3 10.946 14.684
+#> chain:4  8.797 10.092
+# summary plot
+plot(rw)
+
+

plot of chunk weekly_rw

+
+
+
+

No delays +

+

Whilst EpiNow2 allows the user to specify delays, it can +also run directly on the data as does e.g. the EpiEstim +package.

+
+no_delay <- estimate_infections(
+  reported_cases,
+  generation_time = generation_time_opts(generation_time)
+)
+#> Warning: There were 9 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
+# summarise results
+summary(no_delay)
+#>                                  measure                   estimate
+#> 1: New confirmed cases by infection date        2770 (2323 -- 3317)
+#> 2:        Expected change in daily cases                 Decreasing
+#> 3:            Effective reproduction no.        0.88 (0.77 -- 0.98)
+#> 4:                        Rate of growth -0.028 (-0.053 -- -0.0035)
+#> 5:          Doubling/halving time (days)          -25 (-200 -- -13)
+# elapsed time (in seconds)
+get_elapsed_time(no_delay$fit)
+#>         warmup sample
+#> chain:1 42.824 38.712
+#> chain:2 49.368 42.698
+#> chain:3 43.148 36.002
+#> chain:4 37.123 36.357
+# summary plot
+plot(no_delay)
+
+

plot of chunk no_delays

+
+
+
+

Non-parametric infection model +

+

The package also includes a non-parametric infection model. This runs +much faster but does not use the renewal equation to generate +infections. Because of this none of the options defining the behaviour +of the reproduction number are available in this case, limiting user +choice and model generality. It also means that the model is +questionable for forecasting, which is why were here set the predictive +horizon to 0.

+
+non_parametric <- estimate_infections(reported_cases,
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = NULL,
+  backcalc = backcalc_opts(),
+  horizon = 0
+)
+# summarise results
+summary(non_parametric)
+#>                                  measure                   estimate
+#> 1: New confirmed cases by infection date        2328 (1740 -- 3059)
+#> 2:        Expected change in daily cases                 Decreasing
+#> 3:            Effective reproduction no.        0.89 (0.78 -- 0.99)
+#> 4:                        Rate of growth -0.024 (-0.049 -- -0.0012)
+#> 5:          Doubling/halving time (days)          -29 (-590 -- -14)
+# elapsed time (in seconds)
+get_elapsed_time(non_parametric$fit)
+#>         warmup sample
+#> chain:1  4.597  1.014
+#> chain:2  3.146  1.074
+#> chain:3  3.497  1.129
+#> chain:4  3.992  0.992
+# summary plot
+plot(non_parametric)
+
+

plot of chunk nonparametric

+
+
+
+
+
+ + + + +
+ + + + + + + diff --git a/dev/articles/estimate_infections_workflow.html b/dev/articles/estimate_infections_workflow.html new file mode 100644 index 000000000..76fde5c11 --- /dev/null +++ b/dev/articles/estimate_infections_workflow.html @@ -0,0 +1,433 @@ + + + + + + + + +Workflow for Rt estimation and forecasting • EpiNow2 + + + + + + + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + +

This vignette describes the typical workflow for estimating +reproduction numbers and performing short-term forecasts for a disease +spreading in a given setting using EpiNow2. The vignette uses +the default non-stationary Gaussian process model included in the +package. See other vignettes for a more thorough exploration of alternative model variants +and theoretical background.

+
+

Data +

+

Obtaining a good and full understanding of the data being used is an +important first step in any inference procedure such as the one applied +here. EpiNow2 expects data in the format of a data frame with +two columns, date and confirm, where +confirm stands for the number of confirmed counts - +although in reality this can be applied to any data including suspected +cases and lab-confirmed outcomes. The user might already have the data +as such a time series provided, for example, on public dashboards or +directly from public health authorities. Alternatively, they can be +constructed from individual-level data, for example using the incidence2 +R package. An example data set called example_confirm is +included in the package:

+
+head(example_confirmed)
+#>          date confirm
+#> 1: 2020-02-22      14
+#> 2: 2020-02-23      62
+#> 3: 2020-02-24      53
+#> 4: 2020-02-25      97
+#> 5: 2020-02-26      93
+#> 6: 2020-02-27      78
+

Any estimation procedure is only as good as the data that feeds into +it. A thorough understanding of the data that is used for +EpiNow2 and its limitations is a prerequisite for its use. This +includes but is not limited to biases in the population groups that are +represented (EpiNow2 assumes a closed population with all +infections being caused by other infections in the same population), +reporting artefacts and delays, and completeness of reporting. Some of +these can be mitigated using the routines available in EpiNow2 +as described below, but others will cause biases in the results and need +to be carefully considered when interpreting the results.

+
+
+

Set up +

+

We first load the EpiNow2 package.

+ +

We then set the number of cores to use. We will want to run 4 MCMC +chains in parallel so we set this to 4.

+
+options(mc.cores = 4)
+

If we had fewer than 4 available or wanted to run fewer than 4 chains +(at the expense of some robustness), or had fewer than 4 computing cores +available we could set it to that. To find out the number of cores +available one can use the detectCores +function from the parallel package.

+
+
+

Parameters +

+

Once a data set has been identified, a number of relevant parameters +need to be considered before using EpiNow2. As these will +affect any results, it is worth spending some time investigating what +their values should be.

+
+

Delay distributions +

+

EpiNow2 works with different delays that apply to different +parts of the infection and observation process. They are defined using a +common interface with the dist_spec() function. For help +with this function, see its manual page

+
+?EpiNow2::dist_spec
+

In all cases, the distributions given can be fixed +(i.e. have no uncertainty) or variable (i.e. have associated +uncertainty). For example, to define a fixed gamma distribution with +mean 3, standard deviation (sd) 1 and maximum value 10, you would +write

+
+dist_spec(mean = 3, sd = 1, distribution = "gamma", max = 10)
+#> 
+#>   Fixed distribution with PMF [0.0038 0.15 0.39 0.3 0.12 0.03 0.006 0.00096 0.00013 1.6e-05]
+

If distributions are variable, the values with uncertainty are +treated as prior probability +densities in the Bayesian inference framework used by +EpiNow2, i.e. they are estimated as part of the inference. For +example, to define a variable gamma distribution where uncertainty in +the mean is given by a normal distribution with mean 3 and sd 2, and +uncertainty in the standard deviation is given by a normal distribution +with mean 1 and sd 0.1, with a maximum value 10, you would write

+
+dist_spec(
+  mean = 3, mean_sd = 2, sd = 1, sd_sd = 0.1, distribution = "gamma", max = 10
+)
+#> 
+#>   Uncertain gamma distribution with (untruncated) mean 3 (SD 2) and SD 1 (SD 0.1)
+

There are various ways the specific delay distributions mentioned +below might be obtained. Often, they will come directly from the +existing literature reviewed by the user and studies conducted +elsewhere. Sometimes it might be possible to obtain them from existing +databases, e.g. using the epiparameter R +package. Alternatively they might be obtainable from raw data, +e.g. linelists. The EpiNow2 package contains functionality for +estimating delay distributions from observed delays in the +estimate_delays() function. For a more comprehensive +treatment of delays and their estimation avoiding common biases one can +consider, for example, the dynamicaltruncation +R package and associated paper.

+
+

Generation intervals +

+

The generation interval is a delay distribution that describes the +amount of time that passes between an individual becoming infected and +infecting someone else. In EpiNow2, the generation time +distribution is defined by a call to +generation_time_opts(), a function that takes a single +argument defined as a dist_spec object (returned by +dist_spec()). For example, to define the generation time as +gamma distributed with uncertain mean centered on 3 (sd: 2) and sd +centered on 1 (sd: 0.1), a maximum value of 10 and weighted by the +number of case data points we would use

+
+generation_time <- dist_spec(
+  mean = 3, mean_sd = 2, sd = 1, sd_sd = 0.1, distribution = "gamma", max = 10
+)
+generation_time_opts(generation_time)
+
+
+

Reporting delays +

+

EpiNow2 calculates reproduction numbers based on the +trajectory of infection incidence. Usually this is not observed +directly. Instead, we calculate case counts based on, for example, onset +of symptoms, lab confirmations, hospitalisations, etc. In order to +estimate the trajectory of infection incidence from this we need to +either know or estimate the distribution of delays from infection to +count. Often, such counts are composed of multiple delays for which we +only have separate information, for example the incubation period (time +from infection to symptom onset) and reporting delay (time from symptom +onset to being a case in the data, e.g. via lab confirmation, if counts +are not by the date of symptom onset). In this case, we can combine +multiple delays defined using dist_spec() with the plus +(+) operator, e.g.

+
+incubation_period <- dist_spec(
+  mean = 1.6, mean_sd = 0.05, sd = 0.5, sd_sd = 0.05,
+  distribution = "lognormal", max = 14
+)
+reporting_delay <- dist_spec(
+  mean = 0.5, sd = 0.5, distribution = "lognormal", max = 10
+)
+incubation_period + reporting_delay
+#> 
+#> Combination of delay distributions:
+#>   Uncertain lognormal distribution with (untruncated) logmean 1.6 (SD 0.05) and logSD 0.5 (SD 0.05)
+#>   Fixed distribution with PMF [0.16 0.49 0.23 0.077 0.025 0.0084 0.003 0.0011 0.00045 0.00019]
+

In EpiNow2, the reporting delay distribution is defined by a +call to delay_opts(), a function that takes a single +argument defined as a dist_spec object (returned by +dist_spec()). For example, if our observations were by +symptom onset we would use

+
+delay_opts(incubation_period)
+

If they were by date of lab confirmation that happens with a delay +given by reporting_delay, we would use

+
+delay <- incubation_period + reporting_delay
+delay_opts(delay)
+
+
+

Truncation +

+

Besides the delay from infection to the event that is recorded in the +data, there can also be a delay from that event to being recorded in the +data. For example, data reported by symptom onset may only become part +of the dataset once lab confirmation has occurred, or even a day or two +after that confirmation. Statistically, this means our data is +right-truncated. In practice, it means that recent data will be unlikely +to be complete.

+

The amount of such truncation that exists in the data can be +estimated from multiple snapshots of the data, i.e. what the data looked +like at multiple past dates. One can then use methods that use the +amount of backfilling that occurred 1, 2, … days after data for a date +are first reported. In EpiNow2, this can be done using the +estimate_truncation() method which returns, amongst others, +posterior estimates of the truncation distribution. For more details on +the model used for this, see the estimate_truncation vignette.

+
+?estimate_truncation
+

In the estimate_infections() function, the truncation +distribution is defined by a call to trunc_opts(), a +function that takes a single argument defined as a +dist_spec (either defined by the user or obtained from a +call to estimate_truncation() or any other method for +estimating right truncation). This will then be used to correct for +right truncation in the data.

+

The separation of estimation of right truncation on the one hand and +estimation of the reproduction number on the other may be attractive for +practical purposes but is questionable statistically as it separates two +processes that are not strictly separable, potentially introducing a +bias. An alternative approach where these are estimated jointly is being +implemented in the epinowcast package, which is +being developed by the EpiNow2 developers with +collaborators.

+
+
+
+

Completeness of reporting +

+

Another issue affecting the progression from infections to reported +outcomes is underreporting, i.e. the fact that not all infections are +reported as cases. This varies both by pathogen and population (and +e.g. the proportion of infections that are asymptomatic) as well as the +specific outcome used as data and where it is located on the severity +pyramid (e.g. hospitalisations vs. community cases). In EpiNow2 +we can specify the proportion of infections that we expect to be +observed (with uncertainty assumed represented by a truncated normal +distribution with bounds at 0 and 1) using the scale +argument to the obs_opts() function. For example, if we +think that 40% (with standard deviation 1%) of infections end up in the +data as observations we could specify.

+
+obs_scale <- list(mean = 0.4, sd = 0.01)
+obs_opts(scale = obs_scale)
+
+
+

Initial reproduction number +

+

The default model that estimate_infections() uses to +estimate reproduction numbers requires specification of a prior +probability distribution for the initial reproduction number. This +represents the user’s initial belief of the value of the reproduction +number, where there is no data yet to inform its value. By default this +is assumed to be represented by a lognormal distribution with mean and +standard deviation of 1. It can be changed using the +rt_opts() function. For example, if the user believes that +at the very start of the data the reproduction number was 2, with +uncertainty in this belief represented by a standard deviation of 1, +they would use

+
+rt_prior <- list(mean =  2, sd = 1)
+rt_opts(prior = rt_prior)
+
+
+

Weighing delay priors +

+

When providing uncertain delay distributions one can end up in a +situation where the estimated means are shifted a long way from the +given distribution means, and possibly further than is deemed realistic +by the user. In that case, one could specify narrower prior +distributions (e.g., smaller mean_sd) in order to keep the +estimated means closer to the given mean, but this can be difficult to +do in a principled manner in practice. As a more straightforward +alternative, one can choose to weigh the generation time priors by the +number of data points in the case data set by setting +weigh_delay_priors = TRUE (the default).

+
+
+
+

Estimation and forecasting +

+

All the options are combined in a call to the +estimate_infections() function. For example, using some of +the options described above one could call

+
+def <- estimate_infections(
+  example_confirmed, 
+  generation_time = generation_time_opts(generation_time),
+  delays = delay_opts(delay),
+  rt = rt_opts(prior = rt_prior)
+)
+#> Warning: There were 3 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
+

Alternatively, for production environments, we recommend using the +epinow() function. It uses +estimate_infections() internally and provides functionality +for logging and saving results and plots in dedicated directories in the +user’s file system.

+
+

Forecasting secondary outcomes +

+

The estimate_infections() function works with a single +time series of outcomes such as cases by symptom onset or +hospitalisations. Sometimes one wants to further create forecasts of +other secondary outcomes such as deaths. The package contains +functionality to estimate the delay and scaling between multiple time +series with the estimate_secondary() function, as well as +for using this to make forecasts with the +forecast_secondary() function.

+
+
+
+

Interpretation +

+

To visualise the results one can use the plot() function +that comes with the package

+
+plot(def)
+
+

plot of chunk results

+
+

The results returned by the estimate_infections model +depend on the values assigned to all to parameters discussed in this +vignette, i.e. delays, scaling, and reproduction numbers, as well as the +model variant used and its parameters. Any interpretation of the results +will therefore need to bear these in mind, as well as any properties of +the data and/or the subpopulations that it represents. See the Model options vignette for +an illustration of the impact of model choice.

+
+
+
+ + + + +
+ + + + + + + diff --git a/dev/articles/figure/bp-1.png b/dev/articles/figure/bp-1.png new file mode 100644 index 000000000..3fd702fba Binary files /dev/null and b/dev/articles/figure/bp-1.png differ diff --git a/dev/articles/figure/data-1.png b/dev/articles/figure/data-1.png new file mode 100644 index 000000000..3a94d6db3 Binary files /dev/null and b/dev/articles/figure/data-1.png differ diff --git a/dev/articles/figure/default-1.png b/dev/articles/figure/default-1.png new file mode 100644 index 000000000..82686601a Binary files /dev/null and b/dev/articles/figure/default-1.png differ diff --git a/dev/articles/figure/fixed-1.png b/dev/articles/figure/fixed-1.png new file mode 100644 index 000000000..75fa86fa4 Binary files /dev/null and b/dev/articles/figure/fixed-1.png differ diff --git a/dev/articles/figure/gp_projection-1.png b/dev/articles/figure/gp_projection-1.png new file mode 100644 index 000000000..99c82de01 Binary files /dev/null and b/dev/articles/figure/gp_projection-1.png differ diff --git a/dev/articles/figure/lower_accuracy-1.png b/dev/articles/figure/lower_accuracy-1.png new file mode 100644 index 000000000..82407a8bc Binary files /dev/null and b/dev/articles/figure/lower_accuracy-1.png differ diff --git a/dev/articles/figure/no_delays-1.png b/dev/articles/figure/no_delays-1.png new file mode 100644 index 000000000..affd0032f Binary files /dev/null and b/dev/articles/figure/no_delays-1.png differ diff --git a/dev/articles/figure/nonparametric-1.png b/dev/articles/figure/nonparametric-1.png new file mode 100644 index 000000000..601709c09 Binary files /dev/null and b/dev/articles/figure/nonparametric-1.png differ diff --git a/dev/articles/figure/regional_epinow-1.png b/dev/articles/figure/regional_epinow-1.png new file mode 100644 index 000000000..e8cb4fdfd Binary files /dev/null and b/dev/articles/figure/regional_epinow-1.png differ diff --git a/dev/articles/figure/regional_epinow_multiple-1.png b/dev/articles/figure/regional_epinow_multiple-1.png new file mode 100644 index 000000000..127a672a2 Binary files /dev/null and b/dev/articles/figure/regional_epinow_multiple-1.png differ diff --git a/dev/articles/figure/susceptible_depletion-1.png b/dev/articles/figure/susceptible_depletion-1.png new file mode 100644 index 000000000..9c4691a5f Binary files /dev/null and b/dev/articles/figure/susceptible_depletion-1.png differ diff --git a/dev/articles/figure/truncation-1.png b/dev/articles/figure/truncation-1.png new file mode 100644 index 000000000..f9dd5d845 Binary files /dev/null and b/dev/articles/figure/truncation-1.png differ diff --git a/dev/articles/figure/weekly_rw-1.png b/dev/articles/figure/weekly_rw-1.png new file mode 100644 index 000000000..2d4387208 Binary files /dev/null and b/dev/articles/figure/weekly_rw-1.png differ diff --git a/dev/articles/index.html b/dev/articles/index.html index 1b0732040..5e99b2c64 100644 --- a/dev/articles/index.html +++ b/dev/articles/index.html @@ -63,9 +63,15 @@

All vignettes

Case studies and use in the literature
+
+
Using epinow() for running in production mode
Model definition: estimate_infections()
+
Examples: estimate_infections()
+
+
Workflow for Rt estimation and forecasting
+
Model definition: estimate_secondary()
Model definition: estimate_truncation()
diff --git a/dev/news/index.html b/dev/news/index.html index 08435028b..33cf53a12 100644 --- a/dev/news/index.html +++ b/dev/news/index.html @@ -62,8 +62,13 @@

EpiNow2 1.4.9000

+

Documentation

+
  • Two new vignettes have been added to cover the workflow and example uses. By @sbfnk in #458 and reviewed by @jamesmbaazam.
  • +
  • Removed references to the no longer existing forecast_infections function. By @sbfnk in #460 and reviewed by @seabbs.
  • +
+

Package

-
  • Reduced the number of long-running examples.
  • +
    • Reduced the number of long-running examples. By @sbfnk in #459 and reviewed by @seabbs.
diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index 85a1028b9..f5d555a33 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -3,11 +3,14 @@ pkgdown: 2.0.7 pkgdown_sha: ~ articles: case-studies: case-studies.html + epinow: epinow.html estimate_infections: estimate_infections.html + estimate_infections_options: estimate_infections_options.html + estimate_infections_workflow: estimate_infections_workflow.html estimate_secondary: estimate_secondary.html estimate_truncation: estimate_truncation.html gaussian_process_implementation_details: gaussian_process_implementation_details.html -last_built: 2023-10-03T09:53Z +last_built: 2023-10-03T13:21Z urls: reference: epiforecasts.io/EpiNow2/reference article: epiforecasts.io/EpiNow2/articles diff --git a/dev/reference/adjust_infection_to_report.html b/dev/reference/adjust_infection_to_report.html index 39a39e35a..92aa709a6 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 2 -#> 2: 2020-02-25 6 -#> 3: 2020-02-26 12 -#> 4: 2020-02-27 23 -#> 5: 2020-02-28 28 +#> 1: 2020-02-25 3 +#> 2: 2020-02-26 15 +#> 3: 2020-02-27 22 +#> 4: 2020-02-28 26 +#> 5: 2020-02-29 48 #> --- -#> 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 +#> 123: 2020-06-26 180 +#> 124: 2020-06-27 192 +#> 125: 2020-06-28 218 +#> 126: 2020-06-29 248 +#> 127: 2020-06-30 223 # 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 5 -#> 2: 2020-02-26 8 -#> 3: 2020-02-27 24 -#> 4: 2020-02-28 23 -#> 5: 2020-02-29 39 +#> 1: 2020-02-24 2 +#> 2: 2020-02-25 5 +#> 3: 2020-02-26 8 +#> 4: 2020-02-27 19 +#> 5: 2020-02-28 28 #> --- -#> 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 +#> 124: 2020-06-26 191 +#> 125: 2020-06-27 178 +#> 126: 2020-06-28 210 +#> 127: 2020-06-29 231 +#> 128: 2020-06-30 228 # map using a deterministic median shift for both delays report_median <- adjust_infection_to_report(cases, @@ -221,17 +221,17 @@

Examples) print(report_stochastic) #> date cases -#> 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 +#> 1: 2020-02-25 7 +#> 2: 2020-02-26 23 +#> 3: 2020-02-27 13 +#> 4: 2020-02-28 16 +#> 5: 2020-02-29 58 #> --- -#> 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 +#> 123: 2020-06-26 208 +#> 124: 2020-06-27 167 +#> 125: 2020-06-28 206 +#> 126: 2020-06-29 246 +#> 127: 2020-06-30 233 # }

diff --git a/dev/reference/bootstrapped_dist_fit.html b/dev/reference/bootstrapped_dist_fit.html index 24b7fd813..087306864 100644 --- a/dev/reference/bootstrapped_dist_fit.html +++ b/dev/reference/bootstrapped_dist_fit.html @@ -167,7 +167,7 @@

Examples#> Warning: `samples` must be at least 1000. Now setting it to 1000 internally. out #> -#> Uncertain lognormal distribution with (untruncated) logmean 1.5 (SD 0.11) and logSD 1.1 (SD 0.079) +#> Uncertain lognormal distribution with (untruncated) logmean 1.5 (SD 0.089) and logSD 1.1 (SD 0.072) #> # } diff --git a/dev/reference/create_stan_args.html b/dev/reference/create_stan_args.html index 89e76e391..fa3975e1d 100644 --- a/dev/reference/create_stan_args.html +++ b/dev/reference/create_stan_args.html @@ -964,7 +964,7 @@

Examples#> [1] FALSE #> #> $seed -#> [1] 24591502 +#> [1] 97403450 #> #> $future #> [1] FALSE @@ -1827,7 +1827,7 @@

Examples#> [1] FALSE #> #> $seed -#> [1] 521764 +#> [1] 62265541 #> #> $future #> [1] FALSE diff --git a/dev/reference/dist_fit.html b/dev/reference/dist_fit.html index 944c2aa22..b405dbe41 100644 --- a/dev/reference/dist_fit.html +++ b/dev/reference/dist_fit.html @@ -136,8 +136,8 @@

Examples#> #> SAMPLING FOR MODEL 'dist_fit' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 6.8e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.68 seconds. +#> Chain 1: Gradient evaluation took 0.000174 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 1.74 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -184,15 +184,15 @@

Examples#> Chain 1: Iteration: 1950 / 2000 [ 97%] (Sampling) #> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.229 seconds (Warm-up) +#> Chain 1: Elapsed Time: 0.199 seconds (Warm-up) #> Chain 1: 0.202 seconds (Sampling) -#> Chain 1: 0.431 seconds (Total) +#> Chain 1: 0.401 seconds (Total) #> Chain 1: #> #> SAMPLING FOR MODEL 'dist_fit' NOW (CHAIN 2). #> Chain 2: -#> Chain 2: Gradient evaluation took 6.6e-05 seconds -#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.66 seconds. +#> Chain 2: Gradient evaluation took 5.8e-05 seconds +#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.58 seconds. #> Chain 2: Adjust your expectations accordingly! #> Chain 2: #> Chain 2: @@ -239,19 +239,19 @@

Examples#> Chain 2: Iteration: 1950 / 2000 [ 97%] (Sampling) #> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 2: -#> Chain 2: Elapsed Time: 0.246 seconds (Warm-up) -#> Chain 2: 0.278 seconds (Sampling) -#> Chain 2: 0.524 seconds (Total) +#> Chain 2: Elapsed Time: 0.204 seconds (Warm-up) +#> Chain 2: 0.202 seconds (Sampling) +#> Chain 2: 0.406 seconds (Total) #> Chain 2: #> Inference for Stan model: dist_fit. #> 2 chains, each with iter=2000; warmup=1000; thin=1; #> post-warmup draws per chain=1000, total post-warmup draws=2000. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat -#> lambda[1] 2.57 0.01 0.41 1.85 2.27 2.54 2.84 3.45 781 1 -#> lp__ -14.92 0.03 0.70 -16.95 -15.06 -14.66 -14.48 -14.42 781 1 +#> lambda[1] 2.60 0.02 0.42 1.88 2.31 2.55 2.86 3.51 742 1 +#> lp__ -16.23 0.03 0.70 -18.20 -16.41 -15.94 -15.77 -15.72 748 1 #> -#> Samples were drawn using NUTS(diag_e) at Tue Oct 3 09:54:34 2023. +#> Samples were drawn using NUTS(diag_e) at Tue Oct 3 13:22:22 2023. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1). @@ -265,8 +265,8 @@

Examples#> #> SAMPLING FOR MODEL 'dist_fit' NOW (CHAIN 1). #> Chain 1: -#> Chain 1: Gradient evaluation took 0.000288 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 2.88 seconds. +#> Chain 1: Gradient evaluation took 0.000413 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 4.13 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -313,15 +313,15 @@

Examples#> Chain 1: Iteration: 1950 / 2000 [ 97%] (Sampling) #> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 2.124 seconds (Warm-up) -#> Chain 1: 2.868 seconds (Sampling) -#> Chain 1: 4.992 seconds (Total) +#> Chain 1: Elapsed Time: 2.248 seconds (Warm-up) +#> Chain 1: 2.372 seconds (Sampling) +#> Chain 1: 4.62 seconds (Total) #> Chain 1: #> #> SAMPLING FOR MODEL 'dist_fit' NOW (CHAIN 2). #> Chain 2: -#> Chain 2: Gradient evaluation took 0.000246 seconds -#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 2.46 seconds. +#> Chain 2: Gradient evaluation took 0.000268 seconds +#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 2.68 seconds. #> Chain 2: Adjust your expectations accordingly! #> Chain 2: #> Chain 2: @@ -368,22 +368,22 @@

Examples#> Chain 2: Iteration: 1950 / 2000 [ 97%] (Sampling) #> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 2: -#> Chain 2: Elapsed Time: 2.147 seconds (Warm-up) -#> Chain 2: 1.719 seconds (Sampling) -#> Chain 2: 3.866 seconds (Total) +#> Chain 2: Elapsed Time: 2.249 seconds (Warm-up) +#> Chain 2: 2.152 seconds (Sampling) +#> Chain 2: 4.401 seconds (Total) #> Chain 2: #> Inference for Stan model: dist_fit. #> 2 chains, each with iter=2000; warmup=1000; thin=1; #> post-warmup draws per chain=1000, total post-warmup draws=2000. #> -#> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat -#> alpha_raw[1] 0.84 0.03 0.55 0.05 0.41 0.76 1.20 2.10 268 1.01 -#> beta_raw[1] 1.07 0.04 0.58 0.11 0.66 1.03 1.45 2.26 262 1.01 -#> alpha[1] 6.17 0.03 0.55 5.38 5.74 6.09 6.53 7.43 268 1.01 -#> beta[1] 6.50 0.04 0.58 5.54 6.09 6.46 6.88 7.69 262 1.01 -#> lp__ -11.74 0.11 1.43 -15.48 -12.41 -11.27 -10.67 -10.24 173 1.02 +#> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat +#> alpha_raw[1] 0.79 0.02 0.52 0.05 0.37 0.70 1.11 1.99 471 1.00 +#> beta_raw[1] 0.91 0.03 0.54 0.06 0.50 0.86 1.28 2.05 427 1.01 +#> alpha[1] 6.63 0.02 0.52 5.89 6.22 6.54 6.95 7.83 471 1.00 +#> beta[1] 7.01 0.03 0.54 6.15 6.60 6.96 7.38 8.15 427 1.01 +#> lp__ -11.08 0.08 1.36 -14.57 -11.69 -10.66 -10.06 -9.67 296 1.01 #> -#> Samples were drawn using NUTS(diag_e) at Tue Oct 3 09:54:43 2023. +#> Samples were drawn using NUTS(diag_e) at Tue Oct 3 13:22:31 2023. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1). @@ -395,12 +395,9 @@

Examples) #> #> SAMPLING FOR MODEL 'dist_fit' NOW (CHAIN 1). -#> Chain 1: Rejecting initial value: -#> Chain 1: Log probability evaluates to log(0), i.e. negative infinity. -#> Chain 1: Stan can't start sampling from this initial value. #> Chain 1: -#> Chain 1: Gradient evaluation took 9.4e-05 seconds -#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.94 seconds. +#> Chain 1: Gradient evaluation took 7.5e-05 seconds +#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.75 seconds. #> Chain 1: Adjust your expectations accordingly! #> Chain 1: #> Chain 1: @@ -447,15 +444,15 @@

Examples#> Chain 1: Iteration: 1950 / 2000 [ 97%] (Sampling) #> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 1: -#> Chain 1: Elapsed Time: 0.5 seconds (Warm-up) -#> Chain 1: 0.454 seconds (Sampling) -#> Chain 1: 0.954 seconds (Total) +#> Chain 1: Elapsed Time: 0.392 seconds (Warm-up) +#> Chain 1: 0.377 seconds (Sampling) +#> Chain 1: 0.769 seconds (Total) #> Chain 1: #> #> SAMPLING FOR MODEL 'dist_fit' NOW (CHAIN 2). #> Chain 2: -#> Chain 2: Gradient evaluation took 9.1e-05 seconds -#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.91 seconds. +#> Chain 2: Gradient evaluation took 7.5e-05 seconds +#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.75 seconds. #> Chain 2: Adjust your expectations accordingly! #> Chain 2: #> Chain 2: @@ -502,20 +499,20 @@

Examples#> Chain 2: Iteration: 1950 / 2000 [ 97%] (Sampling) #> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 2: -#> Chain 2: Elapsed Time: 0.483 seconds (Warm-up) -#> Chain 2: 0.465 seconds (Sampling) -#> Chain 2: 0.948 seconds (Total) +#> Chain 2: Elapsed Time: 0.381 seconds (Warm-up) +#> Chain 2: 0.412 seconds (Sampling) +#> Chain 2: 0.793 seconds (Total) #> Chain 2: #> Inference for Stan model: dist_fit. #> 2 chains, each with iter=2000; warmup=1000; thin=1; #> post-warmup draws per chain=1000, total post-warmup draws=2000. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat -#> mu[1] 1.60 0.00 0.02 1.56 1.58 1.60 1.61 1.64 1227 1 -#> sigma[1] 0.15 0.00 0.02 0.12 0.14 0.15 0.16 0.19 1218 1 -#> lp__ -68.35 0.04 1.05 -71.22 -68.75 -68.01 -67.61 -67.34 843 1 +#> mu[1] 1.61 0.00 0.02 1.57 1.60 1.61 1.62 1.65 1391 1 +#> sigma[1] 0.15 0.00 0.02 0.12 0.14 0.15 0.16 0.18 1292 1 +#> lp__ -66.27 0.03 1.00 -68.96 -66.69 -65.96 -65.55 -65.28 891 1 #> -#> Samples were drawn using NUTS(diag_e) at Tue Oct 3 09:54:45 2023. +#> Samples were drawn using NUTS(diag_e) at Tue Oct 3 13:22:33 2023. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1). diff --git a/dev/reference/dist_skel.html b/dev/reference/dist_skel.html index 78d67797b..5fb758b1b 100644 --- a/dev/reference/dist_skel.html +++ b/dev/reference/dist_skel.html @@ -147,7 +147,7 @@

Examples## Exponential model # sample dist_skel(10, model = "exp", params = list(rate = 1)) -#> [1] 0 1 1 0 1 1 1 1 1 0 +#> [1] 0 0 0 1 0 1 1 1 1 0 # cumulative prob density dist_skel(1:10, model = "exp", dist = TRUE, params = list(rate = 1)) @@ -165,7 +165,7 @@

Examples## Gamma model # sample dist_skel(10, model = "gamma", params = list(shape = 1, scale = 2)) -#> [1] 0 1 0 0 0 0 0 0 1 0 +#> [1] 0 1 0 0 0 0 0 0 0 0 # cumulative prob density dist_skel(0:10, @@ -187,7 +187,7 @@

Examples## Log normal model # sample dist_skel(10, model = "lognormal", params = list(mean = log(5), sd = log(2))) -#> [1] 3 2 7 3 2 15 4 4 11 8 +#> [1] 1 1 4 4 5 4 9 5 7 3 # cumulative prob density dist_skel(0:10, diff --git a/dev/reference/epinow-1.png b/dev/reference/epinow-1.png index 56d30f8f0..157caf427 100644 Binary files a/dev/reference/epinow-1.png and b/dev/reference/epinow-1.png differ diff --git a/dev/reference/epinow.html b/dev/reference/epinow.html index 834252d62..29217f0d0 100644 --- a/dev/reference/epinow.html +++ b/dev/reference/epinow.html @@ -1,21 +1,17 @@ -Real-time Rt Estimation, Forecasting and Reporting — epinow • EpiNow2Real-time Rt Estimation, Forecasting and Reporting — epinow • EpiNow2 @@ -77,15 +73,13 @@
-

[Maturing] -This function wraps the functionality of estimate_infections() and -forecast_infections() in order to estimate Rt and cases by date of -infection, forecast into these infections into the future. It also contains -additional functionality to convert forecasts to date of report and produce -summary output useful for reporting results and interpreting them. See -here for -an example of using epinow to estimate Rt for Covid-19 in a country from -the ECDC data source.

+

[Maturing] This function wraps the +functionality of estimate_infections() in order to estimate Rt and cases +by date of infection and forecast these infections into the future. In +addition to the functionality of estimate_infections() it produces +additional summary output useful for reporting results and interpreting +them as well as error catching and reporting, making it particularly useful +for production use e.g. running at set intervals on a deidcated server.

@@ -242,12 +236,12 @@

ArgumentsValue

-

A list of output from estimate_infections, forecast_infections, -report_cases, and report_summary.

+

A list of output from estimate_infections with additional elements +summarising results and reporting errors if they have occurred.

See also

-

estimate_infections simulate_infections forecast_infections

+

estimate_infections simulate_infections

regional_epinow

@@ -287,22 +281,22 @@

Examples delays = delay_opts(incubation_period + reporting_delay) ) #> Logging threshold set at INFO for the EpiNow2 logger -#> Writing EpiNow2 logs to the console and: /tmp/RtmpwVkgrx/regional-epinow/2020-04-01.log +#> Writing EpiNow2 logs to the console and: /tmp/Rtmp5Ar639/regional-epinow/2020-04-01.log #> Logging threshold set at INFO for the EpiNow2.epinow logger -#> Writing EpiNow2.epinow logs to the console and: /tmp/RtmpwVkgrx/epinow/2020-04-01.log -#> WARN [2023-10-03 09:56:19] epinow: There were 24 divergent transitions after warmup. See +#> Writing EpiNow2.epinow logs to the console and: /tmp/Rtmp5Ar639/epinow/2020-04-01.log +#> WARN [2023-10-03 13:24:06] epinow: 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. - -#> WARN [2023-10-03 09:56:19] epinow: Examine the pairs() plot to diagnose sampling problems +#> WARN [2023-10-03 13:24:06] epinow: Examine the pairs() plot to diagnose sampling problems #> - # summary of the latest estimates summary(out) -#> measure estimate -#> 1: New confirmed cases by infection date 3267 (1418 -- 7613) -#> 2: Expected change in daily cases Likely decreasing -#> 3: Effective reproduction no. 0.77 (0.51 -- 1.1) -#> 4: Rate of growth -0.053 (-0.13 -- 0.024) -#> 5: Doubling/halving time (days) -13 (29 -- -5.3) +#> measure estimate +#> 1: New confirmed cases by infection date 3344 (1399 -- 7915) +#> 2: Expected change in daily cases Likely decreasing +#> 3: Effective reproduction no. 0.79 (0.51 -- 1.1) +#> 4: Rate of growth -0.05 (-0.13 -- 0.026) +#> 5: Doubling/halving time (days) -14 (26 -- -5.4) # plot estimates plot(out) @@ -310,151 +304,151 @@

Examples# summary of R estimates summary(out, type = "parameters", params = "R") #> date variable strat type median -#> 1: 2020-02-22 R <NA> estimate 2.0665663 -#> 2: 2020-02-23 R <NA> estimate 2.0572481 -#> 3: 2020-02-24 R <NA> estimate 2.0453332 -#> 4: 2020-02-25 R <NA> estimate 2.0291015 -#> 5: 2020-02-26 R <NA> estimate 2.0099345 -#> 6: 2020-02-27 R <NA> estimate 1.9861627 -#> 7: 2020-02-28 R <NA> estimate 1.9593040 -#> 8: 2020-02-29 R <NA> estimate 1.9297156 -#> 9: 2020-03-01 R <NA> estimate 1.8968719 -#> 10: 2020-03-02 R <NA> estimate 1.8620086 -#> 11: 2020-03-03 R <NA> estimate 1.8245663 -#> 12: 2020-03-04 R <NA> estimate 1.7856377 -#> 13: 2020-03-05 R <NA> estimate 1.7450311 -#> 14: 2020-03-06 R <NA> estimate 1.7016611 -#> 15: 2020-03-07 R <NA> estimate 1.6563836 -#> 16: 2020-03-08 R <NA> estimate 1.6122470 -#> 17: 2020-03-09 R <NA> estimate 1.5660727 -#> 18: 2020-03-10 R <NA> estimate 1.5187449 -#> 19: 2020-03-11 R <NA> estimate 1.4725610 -#> 20: 2020-03-12 R <NA> estimate 1.4268102 -#> 21: 2020-03-13 R <NA> estimate 1.3806179 -#> 22: 2020-03-14 R <NA> estimate 1.3345526 -#> 23: 2020-03-15 R <NA> estimate 1.2893035 -#> 24: 2020-03-16 R <NA> estimate 1.2437824 -#> 25: 2020-03-17 R <NA> estimate 1.2002469 -#> 26: 2020-03-18 R <NA> estimate 1.1573501 -#> 27: 2020-03-19 R <NA> estimate 1.1161739 -#> 28: 2020-03-20 R <NA> estimate based on partial data 1.0766134 -#> 29: 2020-03-21 R <NA> estimate based on partial data 1.0397432 -#> 30: 2020-03-22 R <NA> estimate based on partial data 1.0046027 -#> 31: 2020-03-23 R <NA> estimate based on partial data 0.9720808 -#> 32: 2020-03-24 R <NA> estimate based on partial data 0.9421734 -#> 33: 2020-03-25 R <NA> estimate based on partial data 0.9146241 -#> 34: 2020-03-26 R <NA> estimate based on partial data 0.8882882 -#> 35: 2020-03-27 R <NA> estimate based on partial data 0.8637211 -#> 36: 2020-03-28 R <NA> estimate based on partial data 0.8432459 -#> 37: 2020-03-29 R <NA> estimate based on partial data 0.8233689 -#> 38: 2020-03-30 R <NA> estimate based on partial data 0.8040429 -#> 39: 2020-03-31 R <NA> estimate based on partial data 0.7875137 -#> 40: 2020-04-01 R <NA> estimate based on partial data 0.7737082 -#> 41: 2020-04-02 R <NA> forecast 0.7737082 -#> 42: 2020-04-03 R <NA> forecast 0.7737082 -#> 43: 2020-04-04 R <NA> forecast 0.7737082 -#> 44: 2020-04-05 R <NA> forecast 0.7737082 -#> 45: 2020-04-06 R <NA> forecast 0.7737082 -#> 46: 2020-04-07 R <NA> forecast 0.7737082 -#> 47: 2020-04-08 R <NA> forecast 0.7737082 +#> 1: 2020-02-22 R <NA> estimate 2.0638060 +#> 2: 2020-02-23 R <NA> estimate 2.0538517 +#> 3: 2020-02-24 R <NA> estimate 2.0428331 +#> 4: 2020-02-25 R <NA> estimate 2.0276535 +#> 5: 2020-02-26 R <NA> estimate 2.0089606 +#> 6: 2020-02-27 R <NA> estimate 1.9857105 +#> 7: 2020-02-28 R <NA> estimate 1.9589699 +#> 8: 2020-02-29 R <NA> estimate 1.9295101 +#> 9: 2020-03-01 R <NA> estimate 1.8971184 +#> 10: 2020-03-02 R <NA> estimate 1.8621131 +#> 11: 2020-03-03 R <NA> estimate 1.8249032 +#> 12: 2020-03-04 R <NA> estimate 1.7855392 +#> 13: 2020-03-05 R <NA> estimate 1.7440713 +#> 14: 2020-03-06 R <NA> estimate 1.7011417 +#> 15: 2020-03-07 R <NA> estimate 1.6565885 +#> 16: 2020-03-08 R <NA> estimate 1.6119864 +#> 17: 2020-03-09 R <NA> estimate 1.5654385 +#> 18: 2020-03-10 R <NA> estimate 1.5186453 +#> 19: 2020-03-11 R <NA> estimate 1.4716114 +#> 20: 2020-03-12 R <NA> estimate 1.4246117 +#> 21: 2020-03-13 R <NA> estimate 1.3784550 +#> 22: 2020-03-14 R <NA> estimate 1.3316267 +#> 23: 2020-03-15 R <NA> estimate 1.2859061 +#> 24: 2020-03-16 R <NA> estimate 1.2406563 +#> 25: 2020-03-17 R <NA> estimate 1.1966719 +#> 26: 2020-03-18 R <NA> estimate 1.1545342 +#> 27: 2020-03-19 R <NA> estimate 1.1146595 +#> 28: 2020-03-20 R <NA> estimate based on partial data 1.0757296 +#> 29: 2020-03-21 R <NA> estimate based on partial data 1.0393591 +#> 30: 2020-03-22 R <NA> estimate based on partial data 1.0058011 +#> 31: 2020-03-23 R <NA> estimate based on partial data 0.9734129 +#> 32: 2020-03-24 R <NA> estimate based on partial data 0.9441435 +#> 33: 2020-03-25 R <NA> estimate based on partial data 0.9170478 +#> 34: 2020-03-26 R <NA> estimate based on partial data 0.8928547 +#> 35: 2020-03-27 R <NA> estimate based on partial data 0.8692964 +#> 36: 2020-03-28 R <NA> estimate based on partial data 0.8473108 +#> 37: 2020-03-29 R <NA> estimate based on partial data 0.8287966 +#> 38: 2020-03-30 R <NA> estimate based on partial data 0.8130211 +#> 39: 2020-03-31 R <NA> estimate based on partial data 0.7984050 +#> 40: 2020-04-01 R <NA> estimate based on partial data 0.7854864 +#> 41: 2020-04-02 R <NA> forecast 0.7854864 +#> 42: 2020-04-03 R <NA> forecast 0.7854864 +#> 43: 2020-04-04 R <NA> forecast 0.7854864 +#> 44: 2020-04-05 R <NA> forecast 0.7854864 +#> 45: 2020-04-06 R <NA> forecast 0.7854864 +#> 46: 2020-04-07 R <NA> forecast 0.7854864 +#> 47: 2020-04-08 R <NA> forecast 0.7854864 #> date variable strat type median #> mean sd lower_90 lower_50 lower_20 upper_20 upper_50 -#> 1: 2.0675992 0.09321586 1.9200772 2.0020907 2.0418754 2.0913262 2.1279903 -#> 2: 2.0580873 0.08265899 1.9256702 2.0003472 2.0368055 2.0765106 2.1114986 -#> 3: 2.0457177 0.07776500 1.9232081 1.9917157 2.0255956 2.0642544 2.0937309 -#> 4: 2.0301204 0.07655432 1.9092095 1.9785126 2.0098879 2.0480723 2.0783659 -#> 5: 2.0110487 0.07671004 1.8943839 1.9594731 1.9906786 2.0268263 2.0580830 -#> 6: 1.9883960 0.07657572 1.8693509 1.9358609 1.9679766 2.0041800 2.0355304 -#> 7: 1.9621961 0.07538180 1.8439932 1.9112285 1.9420285 1.9773355 2.0076980 -#> 8: 1.9326079 0.07304591 1.8180598 1.8836862 1.9116599 1.9475577 1.9779922 -#> 9: 1.8998901 0.06990064 1.7915296 1.8543763 1.8799528 1.9146614 1.9434036 -#> 10: 1.8643683 0.06645585 1.7624156 1.8200211 1.8457151 1.8781120 1.9062110 -#> 11: 1.8264026 0.06320783 1.7283402 1.7838776 1.8091214 1.8398913 1.8665988 -#> 12: 1.7863597 0.06050377 1.6893963 1.7463969 1.7700015 1.8000902 1.8242854 -#> 13: 1.7445913 0.05848122 1.6505095 1.7047233 1.7296612 1.7583197 1.7816244 -#> 14: 1.7014209 0.05708947 1.6087531 1.6628035 1.6881031 1.7147731 1.7375611 -#> 15: 1.6571377 0.05616611 1.5656264 1.6196018 1.6433582 1.6713940 1.6926185 -#> 16: 1.6119963 0.05552094 1.5212405 1.5745969 1.5983431 1.6257454 1.6471978 -#> 17: 1.5662210 0.05499117 1.4781976 1.5303195 1.5522478 1.5798505 1.6017974 -#> 18: 1.5200143 0.05446108 1.4320667 1.4847695 1.5063324 1.5336986 1.5542528 -#> 19: 1.4735659 0.05385879 1.3852717 1.4380756 1.4601230 1.4868331 1.5076272 -#> 20: 1.4270628 0.05314735 1.3421077 1.3923514 1.4142647 1.4394029 1.4600824 -#> 21: 1.3806978 0.05232109 1.2967022 1.3475073 1.3683833 1.3926720 1.4130233 -#> 22: 1.3346746 0.05140993 1.2517303 1.3024069 1.3228197 1.3467060 1.3661292 -#> 23: 1.2892110 0.05049159 1.2078625 1.2572549 1.2776300 1.3013117 1.3202908 -#> 24: 1.2445379 0.04971247 1.1650458 1.2120100 1.2316036 1.2559181 1.2751219 -#> 25: 1.2008969 0.04931451 1.1220326 1.1692435 1.1885228 1.2115402 1.2322867 -#> 26: 1.1585347 0.04964892 1.0787812 1.1264758 1.1463528 1.1686740 1.1908429 -#> 27: 1.1176967 0.05114163 1.0349831 1.0841377 1.1045945 1.1286412 1.1507694 -#> 28: 1.0786178 0.05419002 0.9900636 1.0438489 1.0646946 1.0906172 1.1136690 -#> 29: 1.0415139 0.05903373 0.9463847 1.0037804 1.0263286 1.0544926 1.0787054 -#> 30: 1.0065729 0.06569194 0.8996783 0.9645353 0.9893831 1.0205071 1.0498277 -#> 31: 0.9739497 0.07400918 0.8537320 0.9241620 0.9558316 0.9888470 1.0220276 -#> 32: 0.9437633 0.08375962 0.8093050 0.8880214 0.9214014 0.9605303 0.9979074 -#> 33: 0.9160978 0.09473853 0.7648559 0.8526487 0.8910609 0.9361275 0.9771412 -#> 34: 0.8910053 0.10680803 0.7207233 0.8210039 0.8604409 0.9145747 0.9600097 -#> 35: 0.8685081 0.11989808 0.6809183 0.7890024 0.8344334 0.8936418 0.9477999 -#> 36: 0.8485996 0.13397913 0.6421538 0.7606687 0.8109790 0.8736524 0.9341676 -#> 37: 0.8312435 0.14902846 0.6028938 0.7340772 0.7875024 0.8574421 0.9230531 -#> 38: 0.8163713 0.16500692 0.5709322 0.7090663 0.7684541 0.8454247 0.9140968 -#> 39: 0.8038812 0.18184986 0.5389194 0.6874220 0.7502059 0.8337178 0.9094884 -#> 40: 0.7936384 0.19946247 0.5067533 0.6684721 0.7315682 0.8188544 0.9065502 -#> 41: 0.7936384 0.19946247 0.5067533 0.6684721 0.7315682 0.8188544 0.9065502 -#> 42: 0.7936384 0.19946247 0.5067533 0.6684721 0.7315682 0.8188544 0.9065502 -#> 43: 0.7936384 0.19946247 0.5067533 0.6684721 0.7315682 0.8188544 0.9065502 -#> 44: 0.7936384 0.19946247 0.5067533 0.6684721 0.7315682 0.8188544 0.9065502 -#> 45: 0.7936384 0.19946247 0.5067533 0.6684721 0.7315682 0.8188544 0.9065502 -#> 46: 0.7936384 0.19946247 0.5067533 0.6684721 0.7315682 0.8188544 0.9065502 -#> 47: 0.7936384 0.19946247 0.5067533 0.6684721 0.7315682 0.8188544 0.9065502 +#> 1: 2.0666162 0.09664754 1.9156753 1.9970177 2.0400888 2.0887139 2.1333494 +#> 2: 2.0570750 0.08583082 1.9224649 1.9957453 2.0311280 2.0795878 2.1162338 +#> 3: 2.0448449 0.07975556 1.9171025 1.9880939 2.0206717 2.0635709 2.1024909 +#> 4: 2.0295150 0.07710486 1.9077461 1.9762578 2.0088078 2.0471109 2.0816039 +#> 5: 2.0107860 0.07607831 1.8908863 1.9600557 1.9906544 2.0258715 2.0603959 +#> 6: 1.9884990 0.07519931 1.8681119 1.9393698 1.9682355 2.0035476 2.0342364 +#> 7: 1.9626462 0.07369577 1.8442262 1.9148539 1.9435473 1.9769760 2.0059346 +#> 8: 1.9333612 0.07145588 1.8210464 1.8866937 1.9136566 1.9463354 1.9748683 +#> 9: 1.9008913 0.06878864 1.7916976 1.8566241 1.8815829 1.9133563 1.9421333 +#> 10: 1.8655594 0.06613695 1.7608537 1.8218169 1.8467792 1.8785080 1.9070416 +#> 11: 1.8277253 0.06383478 1.7270649 1.7841497 1.8099775 1.8393879 1.8677765 +#> 12: 1.7877516 0.06198638 1.6929746 1.7453081 1.7700414 1.8009095 1.8260772 +#> 13: 1.7459822 0.06049820 1.6523251 1.7050995 1.7291814 1.7595698 1.7850361 +#> 14: 1.7027298 0.05920847 1.6096168 1.6634745 1.6857853 1.7164981 1.7395053 +#> 15: 1.6582730 0.05801267 1.5682954 1.6187328 1.6427959 1.6713685 1.6950764 +#> 16: 1.6128592 0.05691385 1.5229174 1.5743770 1.5966107 1.6264816 1.6488002 +#> 17: 1.5667119 0.05598850 1.4781574 1.5285511 1.5519077 1.5793465 1.6008161 +#> 18: 1.5200409 0.05530252 1.4318309 1.4835378 1.5059252 1.5320307 1.5539189 +#> 19: 1.4730531 0.05483324 1.3867961 1.4380565 1.4588942 1.4836685 1.5074886 +#> 20: 1.4259642 0.05445019 1.3400498 1.3906198 1.4125082 1.4375981 1.4592343 +#> 21: 1.3790075 0.05397125 1.2951783 1.3445444 1.3652895 1.3905106 1.4108484 +#> 22: 1.3324380 0.05326090 1.2483813 1.2997389 1.3187106 1.3437767 1.3634517 +#> 23: 1.2865307 0.05231569 1.2016407 1.2538061 1.2736400 1.2976322 1.3176114 +#> 24: 1.2415729 0.05130302 1.1583391 1.2102940 1.2290490 1.2529717 1.2735220 +#> 25: 1.1978526 0.05055248 1.1179815 1.1664501 1.1856479 1.2088095 1.2291201 +#> 26: 1.1556451 0.05051125 1.0759468 1.1219755 1.1439019 1.1661307 1.1871706 +#> 27: 1.1152011 0.05166569 1.0350697 1.0808613 1.1010059 1.1264184 1.1467935 +#> 28: 1.0767373 0.05443220 0.9926204 1.0404964 1.0611640 1.0889153 1.1095452 +#> 29: 1.0404311 0.05905555 0.9489147 1.0006635 1.0252248 1.0541600 1.0752605 +#> 30: 1.0064188 0.06557533 0.9049680 0.9614209 0.9900921 1.0208117 1.0450942 +#> 31: 0.9747979 0.07387444 0.8581391 0.9250669 0.9566360 0.9910813 1.0206788 +#> 32: 0.9456316 0.08375971 0.8134482 0.8894619 0.9239827 0.9637957 0.9988876 +#> 33: 0.9189544 0.09502363 0.7655796 0.8540661 0.8943532 0.9406465 0.9792871 +#> 34: 0.8947773 0.10747295 0.7203270 0.8238694 0.8662797 0.9187447 0.9615644 +#> 35: 0.8730911 0.12093398 0.6767630 0.7942263 0.8395698 0.8984990 0.9466739 +#> 36: 0.8538674 0.13524784 0.6391341 0.7646956 0.8157164 0.8799516 0.9334555 +#> 37: 0.8370570 0.15026386 0.6042259 0.7389298 0.7935349 0.8623274 0.9267734 +#> 38: 0.8225886 0.16583357 0.5704574 0.7171228 0.7730476 0.8472362 0.9191389 +#> 39: 0.8103664 0.18180454 0.5396078 0.6963493 0.7556376 0.8349578 0.9139559 +#> 40: 0.8002698 0.19801198 0.5124699 0.6766839 0.7413499 0.8225764 0.9100473 +#> 41: 0.8002698 0.19801198 0.5124699 0.6766839 0.7413499 0.8225764 0.9100473 +#> 42: 0.8002698 0.19801198 0.5124699 0.6766839 0.7413499 0.8225764 0.9100473 +#> 43: 0.8002698 0.19801198 0.5124699 0.6766839 0.7413499 0.8225764 0.9100473 +#> 44: 0.8002698 0.19801198 0.5124699 0.6766839 0.7413499 0.8225764 0.9100473 +#> 45: 0.8002698 0.19801198 0.5124699 0.6766839 0.7413499 0.8225764 0.9100473 +#> 46: 0.8002698 0.19801198 0.5124699 0.6766839 0.7413499 0.8225764 0.9100473 +#> 47: 0.8002698 0.19801198 0.5124699 0.6766839 0.7413499 0.8225764 0.9100473 #> mean sd lower_90 lower_50 lower_20 upper_20 upper_50 #> upper_90 -#> 1: 2.223460 -#> 2: 2.198021 -#> 3: 2.175876 -#> 4: 2.159349 -#> 5: 2.135009 -#> 6: 2.113177 -#> 7: 2.086532 -#> 8: 2.054193 -#> 9: 2.017649 -#> 10: 1.976230 -#> 11: 1.931684 -#> 12: 1.890184 -#> 13: 1.845283 -#> 14: 1.796508 -#> 15: 1.751461 -#> 16: 1.703839 -#> 17: 1.658727 -#> 18: 1.609549 -#> 19: 1.559474 -#> 20: 1.510314 -#> 21: 1.463889 -#> 22: 1.416947 -#> 23: 1.372417 -#> 24: 1.326898 -#> 25: 1.281746 -#> 26: 1.240077 -#> 27: 1.202808 -#> 28: 1.169020 -#> 29: 1.139084 -#> 30: 1.116139 -#> 31: 1.099959 -#> 32: 1.089888 -#> 33: 1.075114 -#> 34: 1.067066 -#> 35: 1.067619 -#> 36: 1.075636 -#> 37: 1.086348 -#> 38: 1.096073 -#> 39: 1.105078 -#> 40: 1.117807 -#> 41: 1.117807 -#> 42: 1.117807 -#> 43: 1.117807 -#> 44: 1.117807 -#> 45: 1.117807 -#> 46: 1.117807 -#> 47: 1.117807 +#> 1: 2.229177 +#> 2: 2.199573 +#> 3: 2.177230 +#> 4: 2.154246 +#> 5: 2.137987 +#> 6: 2.115425 +#> 7: 2.086159 +#> 8: 2.055293 +#> 9: 2.019754 +#> 10: 1.977005 +#> 11: 1.934675 +#> 12: 1.892689 +#> 13: 1.847855 +#> 14: 1.803635 +#> 15: 1.757661 +#> 16: 1.706567 +#> 17: 1.657780 +#> 18: 1.612764 +#> 19: 1.562712 +#> 20: 1.516288 +#> 21: 1.467066 +#> 22: 1.420103 +#> 23: 1.372812 +#> 24: 1.323629 +#> 25: 1.278841 +#> 26: 1.238124 +#> 27: 1.200365 +#> 28: 1.171670 +#> 29: 1.142702 +#> 30: 1.117283 +#> 31: 1.097717 +#> 32: 1.090149 +#> 33: 1.080434 +#> 34: 1.076943 +#> 35: 1.075244 +#> 36: 1.080198 +#> 37: 1.093796 +#> 38: 1.102787 +#> 39: 1.113402 +#> 40: 1.128817 +#> 41: 1.128817 +#> 42: 1.128817 +#> 43: 1.128817 +#> 44: 1.128817 +#> 45: 1.128817 +#> 46: 1.128817 +#> 47: 1.128817 #> upper_90 options(old_opts) diff --git a/dev/reference/estimate_delay.html b/dev/reference/estimate_delay.html index 8fd92f86f..e7f51f920 100644 --- a/dev/reference/estimate_delay.html +++ b/dev/reference/estimate_delay.html @@ -116,7 +116,7 @@

Examples#> 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. #> -#> Uncertain lognormal distribution with (untruncated) logmean 1.4 (SD 0.11) and logSD 1.1 (SD 0.067) +#> Uncertain lognormal distribution with (untruncated) logmean 1.4 (SD 0.081) and logSD 1.1 (SD 0.086) #> # }

diff --git a/dev/reference/estimate_infections-1.png b/dev/reference/estimate_infections-1.png index d25d6c92f..dcfb23d9e 100644 Binary files a/dev/reference/estimate_infections-1.png and b/dev/reference/estimate_infections-1.png differ diff --git a/dev/reference/estimate_infections.html b/dev/reference/estimate_infections.html index 19484090a..130a64603 100644 --- a/dev/reference/estimate_infections.html +++ b/dev/reference/estimate_infections.html @@ -236,7 +236,7 @@

Value

See also

-

epinow regional_epinow forecast_infections simulate_infections

+

epinow regional_epinow simulate_infections

Author

@@ -277,18 +277,18 @@

Examples rt = rt_opts(prior = list(mean = 2, sd = 0.1)), stan = stan_opts(control = list(adapt_delta = 0.95)) ) -#> Warning: There were 4 divergent transitions after warmup. See +#> Warning: There were 11 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 # real time estimates summary(def) #> measure estimate -#> 1: New confirmed cases by infection date 2243 (1105 -- 4457) +#> 1: New confirmed cases by infection date 2316 (1133 -- 4456) #> 2: Expected change in daily cases Likely decreasing -#> 3: Effective reproduction no. 0.87 (0.61 -- 1.2) -#> 4: Rate of growth -0.028 (-0.097 -- 0.038) -#> 5: Doubling/halving time (days) -25 (18 -- -7.2) +#> 3: Effective reproduction no. 0.89 (0.61 -- 1.2) +#> 4: Rate of growth -0.024 (-0.097 -- 0.039) +#> 5: Doubling/halving time (days) -29 (18 -- -7.1) # summary plot plot(def) diff --git a/dev/reference/estimate_secondary-1.png b/dev/reference/estimate_secondary-1.png index 9ce3258cc..bb8c8300a 100644 Binary files a/dev/reference/estimate_secondary-1.png and b/dev/reference/estimate_secondary-1.png differ diff --git a/dev/reference/estimate_secondary-2.png b/dev/reference/estimate_secondary-2.png index f04d2ffc8..cfb5ef912 100644 Binary files a/dev/reference/estimate_secondary-2.png and b/dev/reference/estimate_secondary-2.png differ diff --git a/dev/reference/estimate_secondary-3.png b/dev/reference/estimate_secondary-3.png index deccbbb0f..65e0da6c2 100644 Binary files a/dev/reference/estimate_secondary-3.png and b/dev/reference/estimate_secondary-3.png differ diff --git a/dev/reference/estimate_secondary-4.png b/dev/reference/estimate_secondary-4.png index d74092b7b..d7696f70b 100644 Binary files a/dev/reference/estimate_secondary-4.png and b/dev/reference/estimate_secondary-4.png differ diff --git a/dev/reference/regional_epinow.html b/dev/reference/regional_epinow.html index 17f1ab855..d67ccc2c1 100644 --- a/dev/reference/regional_epinow.html +++ b/dev/reference/regional_epinow.html @@ -264,7 +264,7 @@

Value

See also

-

epinow estimate_infections forecast_infections

+

epinow estimate_infections

setup_future regional_summary

@@ -310,23 +310,23 @@

Examples ), verbose = interactive() ) -#> INFO [2023-10-03 10:01:09] Producing following optional outputs: regions, summary, samples, plots, latest +#> INFO [2023-10-03 13:28:16] Producing following optional outputs: regions, summary, samples, plots, latest #> Logging threshold set at INFO for the EpiNow2 logger -#> Writing EpiNow2 logs to the console and: /tmp/RtmpwVkgrx/regional-epinow/2020-04-21.log +#> Writing EpiNow2 logs to the console and: /tmp/Rtmp5Ar639/regional-epinow/2020-04-21.log #> Logging threshold set at INFO for the EpiNow2.epinow logger -#> Writing EpiNow2.epinow logs to: /tmp/RtmpwVkgrx/epinow/2020-04-21.log -#> INFO [2023-10-03 10:01:09] Reporting estimates using data up to: 2020-04-21 -#> INFO [2023-10-03 10:01:09] No target directory specified so returning output -#> INFO [2023-10-03 10:01:09] Producing estimates for: testland, realland -#> INFO [2023-10-03 10:01:09] Regions excluded: none -#> INFO [2023-10-03 10:03:46] Completed estimates for: testland -#> INFO [2023-10-03 10:06:22] Completed estimates for: realland -#> INFO [2023-10-03 10:06:22] Completed regional estimates -#> INFO [2023-10-03 10:06:22] Regions with estimates: 2 -#> INFO [2023-10-03 10:06:22] Regions with runtime errors: 0 -#> INFO [2023-10-03 10:06:22] Producing summary -#> INFO [2023-10-03 10:06:22] No summary directory specified so returning summary output -#> INFO [2023-10-03 10:06:23] No target directory specified so returning timings +#> Writing EpiNow2.epinow logs to: /tmp/Rtmp5Ar639/epinow/2020-04-21.log +#> INFO [2023-10-03 13:28:16] Reporting estimates using data up to: 2020-04-21 +#> INFO [2023-10-03 13:28:16] No target directory specified so returning output +#> INFO [2023-10-03 13:28:16] Producing estimates for: testland, realland +#> INFO [2023-10-03 13:28:16] Regions excluded: none +#> INFO [2023-10-03 13:30:52] Completed estimates for: testland +#> INFO [2023-10-03 13:33:28] Completed estimates for: realland +#> INFO [2023-10-03 13:33:28] Completed regional estimates +#> INFO [2023-10-03 13:33:28] Regions with estimates: 2 +#> INFO [2023-10-03 13:33:28] Regions with runtime errors: 0 +#> INFO [2023-10-03 13:33:28] Producing summary +#> INFO [2023-10-03 13:33:28] No summary directory specified so returning summary output +#> INFO [2023-10-03 13:33:29] No target directory specified so returning timings options(old_opts) # }

diff --git a/dev/reference/regional_runtimes.html b/dev/reference/regional_runtimes.html index ee9b4cf3f..85752c27e 100644 --- a/dev/reference/regional_runtimes.html +++ b/dev/reference/regional_runtimes.html @@ -117,7 +117,7 @@

Examples package = "EpiNow2", "extdata", "example_regional_epinow.rds" )) regional_runtimes(regional_output = regional_out$regional) -#> INFO [2023-10-03 10:06:25] No target directory specified so returning timings +#> INFO [2023-10-03 13:33:30] No target directory specified so returning timings #> region time #> 1: testland 44.5 #> 2: realland 29.7 diff --git a/dev/reference/regional_summary.html b/dev/reference/regional_summary.html index ea14482c9..2f2d56032 100644 --- a/dev/reference/regional_summary.html +++ b/dev/reference/regional_summary.html @@ -167,7 +167,7 @@

Examples regional_output = regional_out$regional, reported_cases = regional_out$summary$reported_cases ) -#> INFO [2023-10-03 10:06:26] No summary directory specified so returning summary output +#> INFO [2023-10-03 13:33:31] No summary directory specified so returning summary output #> $latest_date #> [1] "2020-04-21" #> diff --git a/dev/reference/setup_default_logging.html b/dev/reference/setup_default_logging.html index bbb53808d..f1321ef6b 100644 --- a/dev/reference/setup_default_logging.html +++ b/dev/reference/setup_default_logging.html @@ -110,9 +110,9 @@

Value

Examples

setup_default_logging()
 #> Logging threshold set at INFO for the EpiNow2 logger
-#> Writing EpiNow2 logs to the console and: /tmp/RtmpwVkgrx/regional-epinow/latest.log
+#> Writing EpiNow2 logs to the console and: /tmp/Rtmp5Ar639/regional-epinow/latest.log
 #> Logging threshold set at INFO for the EpiNow2.epinow logger
-#> Writing EpiNow2.epinow logs to: /tmp/RtmpwVkgrx/epinow/latest.log
+#> Writing EpiNow2.epinow logs to: /tmp/Rtmp5Ar639/epinow/latest.log