Skip to content

EpiNow2

1.9.0Package record

Estimate and Forecast Real-Time Infection Dynamics

0packages dependsuggested by 1
10.3Kdownloads / year
70.0%test coverage
13/13flavors OK

Overview

About

Estimates the time-varying reproduction number, rate of spread, and doubling time using a renewal equation approach combined with Bayesian inference via Stan. Supports Gaussian process and random walk priors for modelling changes in transmission over time. Accounts for delays between infection and observation (incubation period, reporting delays), right-truncation in recent data, day-of-week effects, and observation overdispersion. Can estimate relationships between primary and secondary outcomes (e.g., cases to hospitalisations or deaths) and forecast both. Runs across multiple regions in parallel. Based on Abbott et al. (2020) doi:10.12688/wellcomeopenres.16006.1 and Gostic et al. (2020) doi:10.1101/2020.06.18.20134858.

Changes in 1.9.0

New features

  • Added support for all dist_spec delay families and obs_opts() observation model selection (Poisson or negative binomial) to estimate_truncation(). The existing observation model functions (report_lp, report_rng) are now reused internally.
  • Wired the likelihood and return_likelihood settings of obs_opts() through estimate_truncation() so that prior-only fits and loo-compatible log-likelihood output are available, matching estimate_infections() and estimate_secondary().
  • Added a noise argument to estimate_truncation() that takes a dist_spec controlling the additive noise term, replacing the previously hardcoded sigma ~ normal(0, 1) T[0,].
  • estimate_truncation() now warns via check_truncation_obs_opts() when obs_opts() settings unused by the truncation model (weight, week_effect, week_length, scale) are set to non-default values.
  • Added estimate_dist() for fitting delay distributions from interval-censored linelist data using Bayesian inference, with support for lognormal, gamma, normal, exponential, and Weibull distributions.
  • Added Exp(), Weibull(), and Normal() distribution constructors.
  • Added Dirichlet() and updated NonParametric() to support estimating nonparametric delay distributions using a Dirichlet prior, as an alternative to fixed NonParametric() or parametric distributions. This uses a gamma normalisation trick for efficient sampling with ragged simplex support in Stan.
  • Added a shared internal helper check_simulation_input() that bundles the repeated input data frame validation in simulate_infections() and simulate_secondary().
  • Added as_forecast_sample() S3 methods for epinow, estimate_infections, forecast_secondary, and estimate_truncation objects, allowing direct conversion to forecast_sample objects via scoringutils::as_forecast_sample() for evaluation.

Breaking changes

  • Removed deprecated arguments that have been erroring since v1.7.0/v1.8.0:
Show all changes in 1.9.0Hide the rest of the changes in 1.9.0
  • gp_opts(ls_mean, ls_sd, ls_min, ls_max): use ls instead
  • gp_opts(alpha_mean, alpha_sd): use alpha instead
  • obs_opts(phi): use dispersion instead
  • obs_opts(na): use fill_missing() instead
  • estimate_infections(filter_leading_zeros, zero_threshold, horizon)
  • estimate_secondary(filter_leading_zeros, zero_threshold)
  • epinow(filter_leading_zeros, zero_threshold, horizon)
  • regional_epinow(horizon)
  • format_fit(burn_in, start_date)
  • Removed the internal function default_fill_missing_obs().
  • The pop argument in rt_opts() and simulate_infections() now errors when passed a numeric value. Use Fixed(pop) instead.
  • Deprecated accessors on model objects now error instead of warning:
  • estimate_infections(): $samples, $summarised
  • estimate_secondary(): $predictions, $posterior, $data
  • estimate_truncation(): $dist, $obs, $data, $last_obs, $cmf
  • epinow(): $estimates, $estimated_reported_cases, $summary, $plots, $estimate_infections
  • summary.epinow(output) and summary.estimate_infections(type = 'samples') now error.
  • Removed internal function extract_parameter_samples(). Use format_simulation_output() instead.

Deprecations

  • estimate_delay() is soft-deprecated in favour of estimate_dist().

Model changes

  • Changed the non-stationary Gaussian process used to model Rt to sample in a mean-centred form internally, eliminating the (R0, drift) ridge in the joint posterior that caused stuck chains and catastrophic R-hat values on some seeds. The user-facing interpretation is unchanged: the prior argument in rt_opts() is still the prior on the initial Rt. Implemented by sampling the trajectory mean internally and applying the user prior to the derived initial Rt with the Jacobian-correct change of variables, so the joint prior matches the pre-change model.
  • Updated the breakpoint random walk to be centred over the observation window, removing the (R0, drift) ridge in the joint posterior alongside the equivalent fix for the non-stationary Gaussian process.
  • Delay distribution discretisation now properly accounts for primary event censoring during model fitting, matching the correction already applied on the R side since v1.8.0. This improves accuracy for short delays where the observation window is large relative to the delay.
  • Left truncation of delay distributions (e.g. excluding generation times of zero) is now handled analytically rather than by zeroing and renormalising, giving more accurate PMFs near the truncation point.
  • Refactored the Gaussian process, convolution, and observation model Stan functions for efficiency and readability, including a shared matern_indices() helper for the Matern spectral densities, outer-product basis function construction in PHI() and PHI_periodic(), and a shared reporting_phi() helper for the negative binomial overdispersion.

Bug fixes

  • Fixed a bug where the target_date argument to epinow() was silently ignored: the recomputed forecast horizon from update_horizon() was never propagated into the call to estimate_infections().
  • Fixed a bug in forecast_infections() where the summary call to extract dates was using modified args instead of the original fit dimensions, causing a date-dimension mismatch when extending the R trajectory beyond the original observation period.
  • Centralised the gating of dispersion on family in obs_opts(): dispersion is now NULL whenever family != "negbin", with a warning if the caller supplied one explicitly. As a result, reporting_overdispersion is no longer sampled from its prior in estimate_infections(), estimate_secondary(), simulate_infections() and estimate_truncation() when a Poisson observation model is used.
  • Fixed a bug where estimate_dist() would fail with a "model fitting timed out or failed" error when observed delays had near-zero variance. Scale parameters are now initialised from the prior when variance cannot be estimated from the data, and a warning is issued.
  • Fixed a bug where example_truncated was generated with the old discrete-CDF PMF while estimate_truncation() now uses the primarycensored-based PMF, causing biased parameter recovery. The dataset has been regenerated for consistency.
  • Fixed a bug where get_parameters() failed with $ operator not defined for this S4 class on a fit with an estimated nonparametric (Dirichlet) delay when using the rstan backend. Posterior draws are now extracted in a backend-agnostic way.
  • Fixed a bug where forecast_infections() errored when called on an estimate_infections object fitted with the cmdstanr backend (it was calling rstan::extract() directly on the CmdStanMCMC fit; now uses the backend-agnostic internal helper).
  • A bug was fixed where the trailing entries of imputed_reports in estimate_infections() output were undefined due to a size mismatch in the Stan generated quantities block.

Documentation

  • Added a vignette demonstrating delay distribution fitting workflows and posterior validation.
  • Added a model definition vignette for estimate_dist().
  • Added a model overview vignette with an architecture diagram showing how the package's models connect.
  • Added a model features vignette providing a quick reference to all modelling options with links to detailed documentation.
  • The delay distribution fitting vignette has been renamed from vignette("estimate-dist") to vignette("estimate_dist_workflow") for consistency with the other workflow vignettes; the model definition is at vignette("estimate_dist").
  • Added a cross-reference from the estimate_truncation() vignette to estimate_dist(), summarising when to use each.
  • Expanded the case studies vignette with additional literature references and public health surveillance examples.
  • The lower-accuracy GP example in the estimate_infections_options vignette now uses basis_prop = 0.15 instead of 0.1, which fits cleanly under the new centred parameterisation.

Package changes

  • The touchstone continuous benchmarks now also cover estimate_truncation(), estimate_secondary() and estimate_dist() alongside the existing epinow() configurations, giving a single standardised view of wall-clock performance across the main user-facing fitting functions.
  • Updated the vendored primarycensored Stan code to version 1.5.0 (CRAN release 2026-06-04).

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 35.6 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OK2026-08-22
  • ERROR12 OK, 1 ERROR2026-08-20
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK13 OK2026-07-29
Show 7 earlier changesHide 7 earlier changes
  • ERROR12 OK, 1 ERROR2026-07-27
  • OK12 OK2026-04-25
  • NOTE11 OK, 3 NOTE2026-04-22
  • ERROR10 OK, 3 NOTE, 1 ERROR2026-04-18
  • NOTE11 OK, 3 NOTE2026-03-18
  • WARNING11 OK, 2 NOTE, 1 WARNING2026-03-17
  • NOTE11 OK, 3 NOTE2026-03-10
Advisories

none known

Documentation

In release 1.9.0
READMEYes · 1,177 wordsVignettesYes · 16 · dynamicNEWSYes · 100% structured · mentions 1.9.0Citation fileNoWebsiteYes · pkgdown
Help pages
200 (99 internal)includes a package overview page
Examples that run
67%55 run in a plain check · 14 only when donttest examples are enabled (R CMD check --as-cran) · 13 never run
Exported functions with examples
84%
Documented parameters
95%
Return-value docs
100%
Help pages citing references
3%

Downloads

10.3K
CRAN downloads in the past year
Rank #3,779 · ~28/day · ~860/mo
Daily download trend is not available in this view yet.
91330 days
2.5K90 days
10.3K1 year
Compare downloads with other packages →
Also on509 r2u4 autocran56 c2d4u

Repository

140Stars
41Forks
91Open issues
31Open PRs
20Releases
1,941Commits
35Commit identities
backcalculationreproduction-numberopen-sourcerstatscovid-19stangaussian-processes
1,941 commits · Last activity 2026-10-05 · 0% stars, 30d · Default branch at 1.9.0.9000, ahead of CRAN 1.9.0 (checked 2026-10-22) · Discussions: 43 posts
Responsiveness
How these are sampled
PRs merged (all time)
73%
Median days to close, 50 most recently updated closed issues
26
Median days to close, 50 most recently updated closed PRs
2

Stars over time

2025-10-10 · 1302026-08-21 · 140
PracticesBeta

20 development-tooling and community-health practices detected across 10 families in the upstream repository

Checks run against github.com/epiforecasts/epinow2 on 2026-10-22.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Governance and community (4)
Code of conductContributing guideIssue templatesPR template
Docs source (4)
README.Rmdpkgdown

GitHub Pages site last deployed 2026-10-05 · The repository has a site deploy workflow

pkgdown site last built 2026-06-17

Coverage (1)
Coverage reporting (Codecov)
Show all practicesHide 6 practices
Reproducibility and dev environment (1)
data-raw/
CRAN release process (1)
cran-comments.md
Research and citation (1)
CITATION.cff
Automation and maintenance (2)
Dependabotpre-commit
Lint, format, editor (3)
lintrLint workflowRStudio project
Git structural (1)
.gitattributes
How this is detected·Detection ruleset v4 (2026-10-20)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2025-10-31
    Seen in the repository: CLAUDE.md
    Named in .Rbuildignore: .claude, CLAUDE.local.md, CLAUDE.md
    Named in .gitignore: .claude
    Pull request it wrote: opened by a project member
    Commits: 1 by its own account · at least 20 crediting it in the message
From outside contributors
  • Claude Code
    Pull requests: 3 from outside contributors, first on 2025-05-28
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
36 external dependencies (excludes base and recommended)

Installing EpiNow2 adds 63 packages (28 with compiled code, 56 MB of source tarballs). Heaviest: BH 14 MB, ggplot2 6.0 MB, data.table 5.7 MB.

Depends (1)
R >= 3.5.0
Enhances (0)
none
Reverse dependencies
0direct
0indirect
Suggested by 1
Suggests, most downloaded first

Datasets

People & History

People (21)
Author, Maintainer since 1.5.0 (2024)
Author · added in 1.3.4
Author · added in 1.4.0
Author · added in 1.2.1
Author · added in 1.2.1
Author · added in 1.8.0
Contributor
Contributor · added in 1.3.4
Contributor
Contributor · added in 1.8.0
Contributor · added in 1.4.0
Contributor · added in 1.6.0
Contributor
Contributor
Show 3 more contributorsHide 3 contributors
Contributor · added in 1.3.4
Contributor
Contributor

Previously maintained by Sam Abbott (1.1.0 to 1.4.0).

Listed in earlier versions (2)
EpiForecasts
no longer listed · 1.1.0 to 1.7.1
Sam
no longer listed · 1.2.1 to 1.3.2
Releases (16)

Pick two releases to compare their code metrics.

  • 1.9.0Latest
    record
    2026-06-16 · current release · diff ↗ ·
    added 4 exports
    Dirichlet, Exp, Weibull, estimate_dist
  • R
    R 4.6.0 released · 2026-04-24
  • 1.8.0
    record
    2026-02-05 · diff ↗ ·
    removed 3 exports
    apply_tolerance, dist_skel, fix_dist
    added 2 exports
    get_predictions, get_samples
  • R
    R 4.5.0 released · 2025-04-11
  • 1.7.1
    record
    2025-02-20 · diff ↗ ·
    removed 11 exports
    adjust_infection_to_report, gamma_dist_def, get_dist, get_generation_time, get_incubation_period, lognorm_dist_def, report_cases, rstan_opts, rstan_sampling_opts, rstan_vb_opts, sample_approx_dist
  • 1.7.0
    record
    2025-02-05 · diff ↗ ·
    added 4 exports
    add_breakpoints, fill_missing, filter_leading_zeros, forecast_opts
  • 1.6.1
    record
    2024-10-31 · diff ↗
  • 1.6.0
    record
    2024-10-02 · diff ↗ ·
    removed 1 export
    dist_spec
    added 5 exports
    bound_dist, epinow2_cmdstan_model, fix_parameters, gt_opts, is_constrained
  • 1.5.2
    record
    2024-05-17 · diff ↗
  • 1.5.1
    record
    2024-05-14 · diff ↗
  • 1.5.0
    record
    2024-05-10 · diff ↗ ·
    removed 25 exports
    add_day_of_week, construct_output, copy_results_to_latest, create_backcalc_data, create_clean_reported_cases, create_gp_data, create_initial_conditions, create_obs_model, create_rt_data, create_shifted_cases, create_stan_args, create_stan_data, estimates_by_report_date, get_raw_result, get_regions, get_regions_with_most_reports, save_estimate_infections, save_input, setup_dt, setup_target_folder, summarise_key_measures, summarise_results, tune_inv_gamma, update_horizon, update_list
    added 21 exports
    Fixed, Gamma, LogNormal, NonParametric, Normal, apply_tolerance, collapse, convolve_and_scale, discretise, discretize, extract_samples, fix_dist, forecast_infections, get_distribution, get_parameters, get_pmf, new_dist_spec, stan_laplace_opts, stan_pathfinder_opts, stan_sampling_opts, stan_vb_opts
  • R
    R 4.4.0 released · 2024-04-24
  • 1.4.0
    record
    2023-09-26 · diff ↗
  • unarchivedReturned to CRAN
    2023-04-27
  • 1.3.5
    record
    2023-04-27 · diff ↗
  • R
    R 4.3.0 released · 2023-04-21
Show 11 earlier eventsHide 11 earlier events
  • archivedRemoved from CRAN
    2023-03-02
    issues were not corrected in time
  • unarchivedReturned to CRAN
    2023-02-12
  • 1.3.4
    record
    2023-02-12 · diff ↗ ·
    removed 6 exports
    country_map, forecast_infections, global_map, save_forecast_infections, simulate_cases, theme_map
    added 6 exports
    add_day_of_week, dist_spec, generation_time_opts, set_dt_single_thread, simulate_secondary, update_secondary_args
  • archivedRemoved from CRAN
    2022-10-19
    issues were not corrected in time
  • R
    R 4.2.0 released · 2022-04-22
  • R
    R 4.1.0 released · 2021-05-18
  • 1.3.2
    record
    2020-12-14 · diff ↗ ·
    added 5 exports
    estimate_secondary, extract_inits, extract_stan_param, forecast_secondary, secondary_opts
  • 1.3.1
    record
    2020-11-22 · diff ↗ ·
    removed 1 export
    match_output_arguments
    added 22 exports
    backcalc_opts, convert_to_logmean, convert_to_logsd, create_backcalc_data, create_gp_data, create_obs_model, create_rt_data, delay_opts, estimate_delay, estimate_truncation, expose_stan_fns, gp_opts, obs_opts, opts_list, rstan_opts, rstan_sampling_opts, rstan_vb_opts, rt_opts, simulate_infections, stan_opts, trunc_opts, update_list
  • 1.2.1
    record
    2020-10-20 · diff ↗ ·
    added 29 exports
    calc_CrI, calc_CrIs, calc_summary_measures, calc_summary_stats, construct_output, copy_results_to_latest, create_clean_reported_cases, create_initial_conditions, create_shifted_cases, create_stan_args, create_stan_data, estimates_by_report_date, extract_CrIs, get_dist, get_generation_time, get_incubation_period, get_regions_with_most_reports, match_output_arguments, regional_runtimes, save_estimate_infections, save_forecast_infections, save_input, setup_default_logging, setup_dt, setup_future, setup_logging, setup_target_folder, tune_inv_gamma, update_horizon
  • 1.1.0
    record
    2020-09-01
  • R
    R 4.0.0 released · 2020-04-24

Package metadata

First published
2020-09-01
Total releases
16 / 6 yrs
License
MIT + file LICENSE OSI
Additional repositories
production.r-multiverse.org
Minimum R
≥ 3.5.0
Bundled data
2.4 KB / 5 files
Download size
6.6 MB
Appears in task views

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("EpiNow2")
Funk, S., Abbott, S., Azam, J. M., Badr, H. S., Bosse, N., Chapman, L., DeWitt, M., Ellis, P., Gostic, K., Hellewell, J., Hickson, J., Howes, A., Johnson, A., Johnson, K., Lison, A., Meakin, S., Mee, P., Monticone, P., Munday, J., Sherratt, K., & Thompson, R. (2026). EpiNow2: Estimate and Forecast Real-Time Infection Dynamics (Version 1.9.0) [Computer software]. https://doi.org/10.32614/CRAN.package.EpiNow2

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

The repository also keeps a CITATION.cff.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for EpiNow2 version 1.9.0 [Data set]. HJJB, LLC. Data release v2026-10-23. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-23, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy