Skip to contents

Estimation + Reporting

Functions that facilitate end-to-end analysis including imputing cases by infection, estimating Rt and reporting results.

as_forecast_sample(<estimate_infections>) as_forecast_sample(<epinow>) as_forecast_sample(<forecast_secondary>) as_forecast_sample(<estimate_truncation>) experimental
Convert EpiNow2 model output to a forecast_sample object
epinow()
Real-time Rt Estimation, Forecasting and Reporting
epinow2_cmdstan_model()
Load and compile an EpiNow2 cmdstanr model
get_parameters()
Get parameters from distributions or fitted models
get_samples()
Get posterior samples from a fitted model
print(<epinowfit>)
Print information about an object that has resulted from a model fit.
regional_epinow()
Real-time Rt Estimation, Forecasting and Reporting by Region
summary(<epinow>)
Summary output from epinow

Estimate, Simulate, and Forecast Parameters

Function to estimate, simulate and forecast parameters of interest.

estimate_infections()
Estimate Infections, the Time-Varying Reproduction Number and the Rate of Growth
forecast_infections()
Forecast infections from a given fit and trajectory of the time-varying reproduction number
estimate_secondary()
Estimate a Secondary Observation from a Primary Observation
forecast_secondary()
Forecast Secondary Observations Given a Fit from estimate_secondary
estimate_delay() deprecated
Estimate a Delay Distribution
estimate_dist() experimental
Estimate a delay distribution using primarycensored
estimate_truncation()
Estimate truncation of observed data

Specify Arguments

Functions used by estimate_infections

backcalc_opts()
Back Calculation Options
delay_opts()
Delay Distribution Options
filter_opts()
Filter Options for a Target Region
forecast_opts()
Forecast options
gt_opts() generation_time_opts()
Generation Time Distribution Options
gp_opts()
Approximate Gaussian Process Settings
obs_opts()
Observation Model Options
rt_opts()
Time-Varying Reproduction Number Options
secondary_opts()
Secondary Reports Options
stan_laplace_opts() experimental
Stan Laplace algorithm Options
stan_opts()
Stan Options
stan_pathfinder_opts() experimental
Stan pathfinder algorithm Options
stan_sampling_opts()
Stan Sampling Options
stan_vb_opts()
Stan Variational Bayes Options
trunc_opts()
Truncation Distribution Options
opts_list()
Forecast optiong

Preprocess Data

Functions used for preprocessing data

fill_missing()
Fill missing data in a data set to prepare it for use within the package
add_breakpoints()
Add breakpoints to certain dates in a data set.
filter_leading_zeros()
Filter leading zeros from a data set.
apply_zero_threshold()
Convert zero case counts to NA (missing) if the 7-day average is above a threshold.

Regional Analysis

Functions used for summarising across regions (designed for use with regional_epinow)

regional_summary()
Regional Summary Output
regional_runtimes()
Summarise Regional Runtimes
get_regional_results()
Get Combined Regional Results

Summarise Results

Functions for summarising results

summary(<epinow>)
Summary output from epinow
summary(<estimate_dist>) experimental
Summarise results from estimate_dist
summary(<estimate_infections>)
Summary output from estimate_infections
summary(<estimate_secondary>)
Summarise results from estimate_secondary
summary(<estimate_truncation>)
Summarise results from estimate_truncation
summary(<forecast_infections>)
Summary output from forecast_infections
backcalc_opts()
Back Calculation Options
calc_CrI()
Calculate Credible Interval
calc_CrIs()
Calculate Credible Intervals
calc_summary_measures()
Calculate All Summary Measures
calc_summary_stats()
Calculate Summary Statistics
make_conf()
Format Credible Intervals
map_prob_change()
Categorise the Probability of Change for Rt

Plot Results

Plot generated results

plot(<dist_spec>)
Plot PMF and CDF for a dist_spec object
plot(<estimate_infections>)
Plot method for estimate_infections
plot(<estimate_secondary>)
Plot method for estimate_secondary
plot(<estimate_truncation>)
Plot method for estimate_truncation
plot(<forecast_infections>)
Plot method for forecast_infections
plot(<forecast_secondary>)
Plot method for forecast_secondary objects
plot_CrIs()
Plot EpiNow2 Credible Intervals
plot_estimates()
Plot Estimates
plot_summary()
Plot a Summary of the Latest Results
report_plots() superseded
Report plots

Report Results

Functions to report results

report_plots() superseded
Report plots
report_summary() superseded
Provide Summary Statistics for Estimated Infections and Rt

Distribution Functions

Functions to define and parameterise distributions

LogNormal() Gamma() Normal() Exp() Weibull() NonParametric() Fixed() Dirichlet()
Probability distributions
c(<dist_spec>)
Combines multiple delay distributions for further processing
collapse(<dist_spec>)
Collapse nonparametric distributions in a <dist_spec>
discretise(<dist_spec>) discretize()
Discretise a <dist_spec>
`==`(<dist_spec>) `!=`(<dist_spec>)
Compares two delay distributions
fix_parameters(<dist_spec>)
Fix the parameters of a <dist_spec>
get_parameters()
Get parameters from distributions or fitted models
is_constrained(<dist_spec>)
Check if a <dist_spec> is constrained, i.e. has a finite maximum or nonzero CDF cutoff.
max(<dist_spec>)
Returns the maximum of one or more delay distribution
mean(<dist_spec>)
Returns the mean of one or more delay distribution
new_dist_spec()
Internal function for generating a dist_spec given parameters and a distribution.
plot(<dist_spec>)
Plot PMF and CDF for a dist_spec object
`+`(<dist_spec>)
Creates a delay distribution as the sum of two other delay distributions.
print(<dist_spec>)
Prints the parameters of one or more delay distributions
bound_dist()
Define bounds of a <dist_spec>
get_pmf()
Get the probability mass function of a nonparametric distribution
get_distribution()
Get the distribution of a <dist_spec>

Fit Delay Distributions

Functions to fit delay distributions

bootstrapped_dist_fit()
Fit a Subsampled Bootstrap to Integer Values and Summarise Distribution Parameters
dist_fit()
Fit an Integer Adjusted Exponential, Gamma or Lognormal distributions

Simulation

Functions to help with simulating data or mapping to reported cases

simulate_infections()
Simulate infections using the renewal equation
simulate_secondary()
Simulate secondary observations from primary observations
convolve_and_scale()
Convolve and scale a time series

Data

Package datasets that may be used to parameterise other functions or in examples

example_generation_time
Example generation time
example_incubation_period
Example incubation period
example_reporting_delay
Example reporting delay
example_confirmed
Example Confirmed Case Data Set
example_truncated
Example Case Data Set with Truncation

Data Access

Functions for extracting data from objects or getting data from sources

get_distribution()
Get the distribution of a <dist_spec>
get_parameters()
Get parameters from distributions or fitted models
get_pmf()
Get the probability mass function of a nonparametric distribution
get_predictions()
Get predictions from a fitted model
get_regional_results()
Get Combined Regional Results
get_samples()
Get posterior samples from a fitted model
extract_CrIs()
Extract Credible Intervals Present
extract_inits() experimental
Generate initial conditions from a Stan fit
extract_samples()
Extract all samples from a stan fit
extract_stan_param()
Extract a parameter summary from a Stan object

Data Cleaning

Functions for cleaning data

clean_nowcasts()
Clean Nowcasts for a Supplied Date
clean_regions()
Clean Regions

Setup

Functions used for setting up functionality

setup_default_logging()
Setup Default Logging
setup_future()
Set up Future Backend
setup_logging()
Setup Logging

Utilities

Utility functions

run_region()
Run epinow with Regional Processing Code
expose_stan_fns()
Expose internal package stan functions in R
convert_to_logmean()
Convert mean and sd to log mean for a log normal distribution
convert_to_logsd()
Convert mean and sd to log standard deviation for a log normal distribution
growth_to_R() superseded
Convert Growth Rates to Reproduction numbers.
R_to_growth() superseded
Convert Reproduction Numbers to Growth Rates
update_secondary_args()
Update estimate_secondary default priors

Internal

EpiNow2 EpiNow2-package
EpiNow2: Estimate and Forecast Real-Time Infection Dynamics
add_day_of_week()
Adds a day of the week vector
add_horizon()
Add missing values for future dates
allocate_delays()
Allocate Delays into Required Stan Format
allocate_empty()
Allocate Empty Parameters to a List
apply_default_cdf_cutoff()
Apply default CDF cutoff to a <dist_spec> if it is unconstrained
build_np_est_data()
Build Stan data for estimated nonparametric delays
`$`(<epinow>) deprecated
Extract elements from epinow objects with deprecation errors
`$`(<estimate_infections>) deprecated
Extract elements from estimate_infections objects with deprecation errors
`$`(<estimate_secondary>) deprecated
Extract elements from estimate_secondary objects with deprecation errors
check_generation_time()
Validate probability distribution for using as generation time
check_reports_valid()
Validate data input
check_simulation_input()
Validate simulation input data frame
check_sparse_pmf_tail()
Check that PMF tail is not sparse
check_stan_delay()
Validate probability distribution for passing to stan
check_truncation_length()
Check and warn if truncation distribution is longer than observed time
check_truncation_obs_opts()
Check that obs_opts settings unused by estimate_truncation are at defaults
combine_tv_and_static_params()
Combine time-varying and static parameters
construct_output()
Construct Output
convert_to_natural()
Internal function for converting parameters to natural parameters.
copy_results_to_latest()
Copy Results From Dated Folder to Latest
create_backcalc_data()
Create Back Calculation Data
create_delay_inits()
Create initial conditions for delays
create_future_rt()
Construct the Required Future Rt assumption
create_gp_data()
Create Gaussian Process Data
create_infection_summary()
Create summary output from infection estimation objects
create_initial_conditions()
Create Initial Conditions Generating Function
create_obs_model()
Create Observation Model Settings
create_rt_data()
Create Time-varying Reproduction Number Data
create_sampling_log_message()
Create sampling log message
create_shifted_cases()
Create Delay Shifted Cases
create_stan_args()
Create a List of Stan Arguments
create_stan_data()
Create Stan Data Required for estimate_infections
create_stan_delays()
Create delay variables for stan
create_stan_params()
Create parameters for stan
discrete_pmf()
Discretised probability mass function
dist_id_to_name()
Get distribution name from primarycensored Stan dist_id
.extract_to_dist_spec()
Extract parameters and convert to dist_spec
.get_dist_id()
Map distribution name to primarycensored ID
.get_param_names()
Map distribution name to parameter names
.prepare_linelist_data()
Prepare linelist data for delay estimation
epinow2_rstan_model()
Load an EpiNow2 rstan model.
epinow2_stan_model()
Return a stan model object for the appropriate backend
estimates_by_report_date()
Estimate Cases by Report Date
extract_delay_params()
Extract delay distributions from a fitted model
extract_delays()
Extract samples from all delay parameters
extract_latent_state()
Extract samples for a latent state from a Stan model
extract_parameters()
Extract samples from all parameters
extract_params()
Extract parameter names
extract_scalar_params()
Extract scalar parameters from a fitted model
extract_single_dist()
Extract a single element of a composite <dist_spec>
fit_model()
Fit a model using the chosen backend.
fit_model_approximate()
Fit a Stan Model using an approximate method
fit_model_with_nuts()
Fit a Stan Model using the NUTs sampler
format_fit()
Format Posterior Samples
format_quantile_predictions()
Format quantile predictions
format_sample_predictions()
Format sample predictions
format_samples_with_dates()
Format raw Stan samples with dates and metadata
format_simulation_output()
Format Simulation Output from Stan
get_accumulate()
Get accumulation flags from data
get_element()
Extracts an element of a <dist_spec>
get_raw_result()
Get a Single Raw Result
get_regions()
Get Folders with Results
get_regions_with_most_reports()
Get Regions with Most Reported Cases
get_seeding_time()
Estimate seeding time from delays and generation time
lapply_func()
Choose a parallel or sequential apply function
lower_bounds()
Get the lower bounds of the parameters of a distribution
make_init_priors()
Build the stan-side init-prior data block from a list of priors
make_param()
Internal function to create a parameter list
match_output_arguments()
Match User Supplied Arguments with Supported Options
merge_trunc_pred_obs()
Merge truncation predictions with observations for display
natural_params()
Get the names of the natural parameters of a distribution
ndist()
Calculate the number of distributions in a <dist_spec>
nonparametric_pmf_data()
Build PMF data for the nonparametric branch of plot.dist_spec
pack_init_prior()
Pack a dist_spec into stan-side init-prior fields
pad_reported_cases()
Pads reported cases with daily initial zeros
posterior_to_normal()
Create a Normal distribution from posterior samples
prepare_truncation_obs()
Prepare truncation observations for Stan
process_region()
Process regional estimate
process_regions()
Process all Region Estimates
rdirichlet()
Draw a single sample from a Dirichlet
reconstruct_delay()
Reconstruct a dist_spec from stored stan data and posterior
reconstruct_nonparametric()
Reconstruct a nonparametric delay distribution
reconstruct_parametric()
Reconstruct a parametric delay distribution
regional_runtimes()
Summarise Regional Runtimes
save_estimate_infections()
Save Estimated Infections
save_input()
Save Observed Data
sd(<dist_spec>)
Returns the standard deviation of one or more delay distribution
select_plots()
Internal helper function to select plots from those created by report_plots()
set_dt_single_thread()
Set to Single Threading
setup_dt()
Convert to Data Table
setup_target_folder()
Setup Target Folder for Saving
stable_convolve()
Numerically stable convolution function for two pmf vectors
`[[`(<epinow>) deprecated
Extract elements from epinow objects with bracket notation
`[[`(<estimate_infections>) deprecated
Extract elements from estimate_infections objects with bracket notation
`[[`(<estimate_secondary>) deprecated
Extract elements from estimate_secondary objects with bracket notation
summarise_key_measures()
Summarise rt and cases
summarise_results()
Summarise Real-time Results
update_horizon()
Updates Forecast Horizon Based on Input Data and Target