# A Bayesian Framework for Real-time Infectious Disease Surveillance ## Summary A modular Bayesian framework for real-time infectious disease surveillance. Provides tools for nowcasting, reproduction number estimation, delay estimation, and forecasting from data subject to reporting delays, right-truncation, missing data, and incomplete ascertainment. Users can build models suited to their setting using a flexible formula interface supporting fixed effects, random effects, random walks, and time-varying parameters, with options including parametric and non-parametric delay distributions with optional modifiers (via discrete-time hazard models), renewal processes, observation models, missing data imputation, and stratified analyses with partial pooling. By jointly estimating disease dynamics and reporting patterns, our framework enables earlier and more reliable detection of trends. While designed with epidemiological applications in mind, the framework can be applied to any right-truncated time series count data. ## Important Note on Model Specification **The default lognormal reporting delay distribution may not suit all data.** It can fail with multimodal or complex delay patterns. Evaluate model fit and consider alternatives (e.g., non-parametric hazards) as needed. See the [package vignettes](https://package.epinowcast.org/articles) for guidance. ## Installation Installing the package You can install the latest released version using the normal `R` function, though you need to point to `r-universe` instead of CRAN: ``` r install.packages( "epinowcast", repos = "https://epinowcast.r-universe.dev" ) ``` Alternatively, you can use the [`remotes` package](https://remotes.r-lib.org/) to install the development version from Github (warning! this version may contain breaking changes and/or bugs): ``` r remotes::install_github( "epinowcast/epinowcast", dependencies = TRUE ) ``` Similarly, you can install historical versions by specifying the release tag (e.g. this installs [`0.2.0`](https://github.com/epinowcast/epinowcast/releases/tag/v0.2.0)): ``` r remotes::install_github( "epinowcast/epinowcast", dependencies = TRUE, ref = "v0.2.0" ) ``` *Note: You can also use that last approach to install a specific commit if needed, e.g. if you want to try out a specific unreleased feature, but not the absolute latest developmental version.* Installing cmdstanr and CmdStan If you wish to do model fitting and nowcasting, you will need to install [`cmdstanr`](https://mc-stan.org/cmdstanr/) and [CmdStan](https://mc-stan.org/users/interfaces/cmdstan), which also entails having a suitable C++ toolchain setup. `cmdstanr` is an optional dependency of `epinowcast` and is not installed automatically. The Stan team provides instructions in the [*Getting started with `cmdstanr`*](https://mc-stan.org/cmdstanr/articles/cmdstanr.html) vignette, with other details and support at the [package site](https://mc-stan.org/cmdstanr/) along with some key instructions available in the [Stan resources package vignette](https://package.epinowcast.org/articles/stan-help.html#toolchain), but the brief version is: ``` r # install cmdstanr install.packages( "cmdstanr", repos = c("https://stan-dev.r-universe.dev", getOption("repos")) ) # once cmdstanr is installed: cmdstanr::install_cmdstan() ``` *Note: You can speed up CmdStan installation using the `cores` argument. If you are installing a particular version of `epinowcast`, you may also need to install a past version of CmdStan, which you can do with the `version` argument.* Alternative: Docker We also provide a [Docker](https://www.docker.com/get-started/) image with [`epinowcast` and all dependencies installed](https://github.com/orgs/epinowcast/packages/container/package/epinowcast). You can use this image to run `epinowcast` without installing dependencies. ## Resources As you use the package, the documentation available via `?enw_` should be your first stop for troubleshooting. We also provide a range of other documentation, case studies, and community spaces to ask (and answer!) questions: Package Website The [`epinowcast` website](https://package.epinowcast.org/) includes a function reference, model outline, and case studies using the package. The site mainly concerns the release version, but you can also find documentation for [the latest development version](https://package.epinowcast.org/dev/). R Vignettes We have created [package vignettes](https://package.epinowcast.org/articles) to help you [get started nowcasting](https://package.epinowcast.org/articles/epinowcast.html), see a [quick reference to package capabilities](https://package.epinowcast.org/articles/features.html) (different timesteps, multi-stratification, mixed models, etc.), and [explore case studies](https://package.epinowcast.org/articles/germany-age-stratified-nowcasting.html). Organisation Website Our [organisation website](https://www.epinowcast.org/) includes links to other resources, [guest posts](https://www.epinowcast.org/blog.html), and [seminar schedule](https://www.epinowcast.org/seminars.html) for both upcoming and past recordings. Community Forum Our [community forum](https://community.epinowcast.org/) has areas for [question and answer](https://community.epinowcast.org/c/interface/15) and [considering new methods and tools](https://community.epinowcast.org/c/projects/11), among others. If you are generally interested in real-time analysis of infectious disease, you may find this useful even if do not use `epinowcast`. Package Analysis Scripts In addition to the vignettes, the package also comes with [example analyses](https://github.com/epinowcast/epinowcast/tree/main/inst/examples). These are not as polished as the vignettes, but we typically explore new features with these and they may help you if you are using a development version. After installing `epinowcast`, you can find them via: ``` r list.files( system.file("examples", package = "epinowcast"), full.names = TRUE ) ``` ## Contributing We welcome contributions and new contributors! We particularly appreciate help on [identifying and identified issues](https://github.com/epinowcast/epinowcast/issues). Please check and add to the issues, and/or add a [pull request](https://github.com/epinowcast/epinowcast/pulls) and see our [contributing guide](https://github.com/epinowcast/.github/blob/main/CONTRIBUTING.md) for more information. If you need a different underlying model for your work: `epinowcast` lets you pass your own models! If you do try new model parameterisations that expand the overall flexibility or improve the defaults, please let us know either here or on the [community forum](https://community.epinowcast.org/). We always like to hear about new use-cases, whether or not they are directed at the core `epinowcast` applications. ### How to make a bug report or feature request Please briefly describe your problem and what output you expect in an [issue](https://github.com/epinowcast/epinowcast/issues). If you have a question, please don’t open an issue. Instead, ask on our [Q and A page](https://github.com/epinowcast/epinowcast/discussions/categories/q-a). See our [contributing guide](https://github.com/epinowcast/.github/blob/main/CONTRIBUTING.md) for more information. ### Code of Conduct Please note that the `epinowcast` project is released with a [Contributor Code of Conduct](https://github.com/epinowcast/.github/blob/main/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms. ## Citation If making use of our methodology or the methodology on which ours is based, please cite the relevant papers from our [model outline](https://package.epinowcast.org/articles/model.html). If you use `epinowcast` in your work, please consider citing it with `citation("epinowcast")`. ## Contributors All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [allcontributors](https://allcontributors.org) specification. Contributions of any kind are welcome! ### Code [seabbs](https://github.com/epinowcast/epinowcast/commits?author=seabbs), [adrian-lison](https://github.com/epinowcast/epinowcast/commits?author=adrian-lison), [sbfnk](https://github.com/epinowcast/epinowcast/commits?author=sbfnk), [Bisaloo](https://github.com/epinowcast/epinowcast/commits?author=Bisaloo), [pearsonca](https://github.com/epinowcast/epinowcast/commits?author=pearsonca), [choi-hannah-old](https://github.com/epinowcast/epinowcast/commits?author=choi-hannah-old), [medewitt](https://github.com/epinowcast/epinowcast/commits?author=medewitt), [jamesmbaazam](https://github.com/epinowcast/epinowcast/commits?author=jamesmbaazam), [pitmonticone](https://github.com/epinowcast/epinowcast/commits?author=pitmonticone), [jessalynnsebastian](https://github.com/epinowcast/epinowcast/commits?author=jessalynnsebastian), [athowes](https://github.com/epinowcast/epinowcast/commits?author=athowes), [kathsherratt](https://github.com/epinowcast/epinowcast/commits?author=kathsherratt), [barbora-sobolova](https://github.com/epinowcast/epinowcast/commits?author=barbora-sobolova), [kaitejohnson](https://github.com/epinowcast/epinowcast/commits?author=kaitejohnson), [Lnrivas](https://github.com/epinowcast/epinowcast/commits?author=Lnrivas), [natemcintosh](https://github.com/epinowcast/epinowcast/commits?author=natemcintosh), [nikosbosse](https://github.com/epinowcast/epinowcast/commits?author=nikosbosse), [pratikunterwegs](https://github.com/epinowcast/epinowcast/commits?author=pratikunterwegs), [nicholasdavies](https://github.com/epinowcast/epinowcast/commits?author=nicholasdavies) ### Issue Authors [teojcryan](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Ateojcryan), [FelixGuenther](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3AFelixGuenther), [beansrowning](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Abeansrowning), [jbracher](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Ajbracher), [zsusswein](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Azsusswein), [christinesangphet](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Achristinesangphet), [rumackaaron](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Arumackaaron), [micahwiesner67](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Amicahwiesner67), [kylieainslie](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Akylieainslie), [maria-tang](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3Amaria-tang), [RodrigoZepeda](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+author%3ARodrigoZepeda) ### Issue Contributors [jhellewell14](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+commenter%3Ajhellewell14), [Gulfa](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+commenter%3AGulfa), [parksw3](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+commenter%3Aparksw3), [TimTaylor](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+commenter%3ATimTaylor), [WardBrian](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+commenter%3AWardBrian), [jimrothstein](https://github.com/epinowcast/epinowcast/issues?q=is%3Aissue+commenter%3Ajimrothstein) # Package index ## Nowcast Functions for nowcasting. - [`epinowcast()`](https://package.epinowcast.org/reference/epinowcast.md) : Nowcast using partially observed data - [`plot(`*``*`)`](https://package.epinowcast.org/reference/plot.enw_preprocess_data.md) : Plot method for enw_preprocess_data - [`plot(`*``*`)`](https://package.epinowcast.org/reference/plot.epinowcast.md) : Plot method for epinowcast - [`print(`*``*`)`](https://package.epinowcast.org/reference/print.enw_preprocess_data.md) : Print method for enw_preprocess_data - [`print(`*``*`)`](https://package.epinowcast.org/reference/print.epinowcast.md) : Print method for epinowcast - [`print(`*``*`)`](https://package.epinowcast.org/reference/print.summary.enw_preprocess_data.md) : Print method for summary.enw_preprocess_data - [`summary(`*``*`)`](https://package.epinowcast.org/reference/summary.enw_preprocess_data.md) : Summary method for enw_preprocess_data - [`summary(`*``*`)`](https://package.epinowcast.org/reference/summary.epinowcast.md) : Summary method for epinowcast ## Data converters Functions for converting between data formats - [`enw_add_cumulative()`](https://package.epinowcast.org/reference/enw_add_cumulative.md) : Calculate cumulative reported cases from incidence of new reports - [`enw_add_incidence()`](https://package.epinowcast.org/reference/enw_add_incidence.md) : Calculate incidence of new reports from cumulative reports - [`enw_aggregate_cumulative()`](https://package.epinowcast.org/reference/enw_aggregate_cumulative.md) : Aggregate observations over a given timestep for both report and reference dates. - [`enw_incidence_to_linelist()`](https://package.epinowcast.org/reference/enw_incidence_to_linelist.md) : Convert Aggregate Counts (Incidence) to a Line List - [`enw_linelist_to_incidence()`](https://package.epinowcast.org/reference/enw_linelist_to_incidence.md) : Convert a Line List to Aggregate Counts (Incidence) ## Preprocess Functions for preprocessing observations - [`enw_add_delay()`](https://package.epinowcast.org/reference/enw_add_delay.md) : Add a delay variable to the observations - [`enw_add_max_reported()`](https://package.epinowcast.org/reference/enw_add_max_reported.md) : Add the maximum number of reported cases for each `reference_date` - [`enw_add_metaobs_features()`](https://package.epinowcast.org/reference/enw_add_metaobs_features.md) : Add common metadata variables - [`enw_assign_group()`](https://package.epinowcast.org/reference/enw_assign_group.md) : Assign a group to each row of a data.table - [`enw_complete_dates()`](https://package.epinowcast.org/reference/enw_complete_dates.md) : Complete missing reference and report dates - [`enw_construct_data()`](https://package.epinowcast.org/reference/enw_construct_data.md) : Construct preprocessed data - [`enw_extend_date()`](https://package.epinowcast.org/reference/enw_extend_date.md) : Extend a time series with additional dates - [`enw_filter_delay()`](https://package.epinowcast.org/reference/enw_filter_delay.md) : Filter observations to have a consistent maximum delay period - [`enw_filter_reference_dates()`](https://package.epinowcast.org/reference/enw_filter_reference_dates.md) : Filter by reference dates - [`enw_filter_reference_dates_by_report_start()`](https://package.epinowcast.org/reference/enw_filter_reference_dates_by_report_start.md) : Filter reference dates that precede the earliest report date - [`enw_filter_report_dates()`](https://package.epinowcast.org/reference/enw_filter_report_dates.md) : Filter by report dates - [`enw_flag_observed_observations()`](https://package.epinowcast.org/reference/enw_flag_observed_observations.md) : Flag observed observations - [`enw_impute_na_observations()`](https://package.epinowcast.org/reference/enw_impute_na_observations.md) : Impute NA observations - [`enw_latest_data()`](https://package.epinowcast.org/reference/enw_latest_data.md) : Filter observations to the latest available reported - [`enw_metadata()`](https://package.epinowcast.org/reference/enw_metadata.md) : Extract metadata from raw data - [`enw_metadata_delay()`](https://package.epinowcast.org/reference/enw_metadata_delay.md) : Calculate reporting delay metadata for a given maximum delay - [`enw_missing_reference()`](https://package.epinowcast.org/reference/enw_missing_reference.md) : Extract reports with missing reference dates - [`enw_obs_at_delay()`](https://package.epinowcast.org/reference/enw_obs_at_delay.md) : Extract latest observations at a given maximum delay - [`enw_preprocess_data()`](https://package.epinowcast.org/reference/enw_preprocess_data.md) : Preprocess observations - [`enw_reporting_triangle()`](https://package.epinowcast.org/reference/enw_reporting_triangle.md) : Construct the reporting triangle - [`enw_reporting_triangle_to_long()`](https://package.epinowcast.org/reference/enw_reporting_triangle_to_long.md) : Recast the reporting triangle from wide to long format - [`enw_retrospective()`](https://package.epinowcast.org/reference/enw_retrospective.md) : Convert preprocessed data to retrospective format ## Model modules Modular model components - [`.expectation_is_minimal()`](https://package.epinowcast.org/reference/dot-expectation_is_minimal.md) : Is an expectation module minimal (intercept-only, no convolution)? - [`enw_expectation()`](https://package.epinowcast.org/reference/enw_expectation.md) : Expectation model module - [`enw_fit_opts()`](https://package.epinowcast.org/reference/enw_fit_opts.md) : Format model fitting options for use with stan - [`enw_missing()`](https://package.epinowcast.org/reference/enw_missing.md) : Missing reference data model module - [`enw_obs()`](https://package.epinowcast.org/reference/enw_obs.md) : Setup observation model and data - [`enw_reference()`](https://package.epinowcast.org/reference/enw_reference.md) : Reference date logit hazard reporting model module - [`enw_report()`](https://package.epinowcast.org/reference/enw_report.md) : Report date logit hazard reporting model module ## Helpers for defining model modules Functions that help with the setup of model modules and that may be specific to individual modules - [`add_max_observed_delay()`](https://package.epinowcast.org/reference/add_max_observed_delay.md) : Add maximum observed delay - [`add_pmfs()`](https://package.epinowcast.org/reference/add_pmfs.md) : Add probability mass functions - [`convolution_matrix()`](https://package.epinowcast.org/reference/convolution_matrix.md) : Construct a convolution matrix - [`delay_only_ltotal()`](https://package.epinowcast.org/reference/delay_only_ltotal.md) : Known per-reference-date totals for the delay-only model - [`delay_only_total()`](https://package.epinowcast.org/reference/delay_only_total.md) : Known integer totals per snapshot for the delay-only model - [`enw_dayofweek_structural_reporting()`](https://package.epinowcast.org/reference/enw_dayofweek_structural_reporting.md) : Create day-of-week structural reporting pattern - [`enw_reference_by_report()`](https://package.epinowcast.org/reference/enw_reference_by_report.md) : Construct a lookup of references dates by report - [`enw_reps_with_complete_refs()`](https://package.epinowcast.org/reference/enw_reps_with_complete_refs.md) : Identify report dates with complete (i.e up to the maximum delay) reference dates - [`enw_structural_reporting_metadata()`](https://package.epinowcast.org/reference/enw_structural_reporting_metadata.md) : Create structural reporting metadata grid - [`extract_obs_metadata()`](https://package.epinowcast.org/reference/extract_obs_metadata.md) : Extract observation metadata - [`extract_sparse_matrix()`](https://package.epinowcast.org/reference/extract_sparse_matrix.md) : Extract sparse matrix elements - [`latest_obs_as_matrix()`](https://package.epinowcast.org/reference/latest_obs_as_matrix.md) : Convert latest observed data to a matrix ## Model tools Generic functions that assist with combining and using modular models - [`enw_formula_as_data_list()`](https://package.epinowcast.org/reference/enw_formula_as_data_list.md) : Format formula data for use with stan - [`enw_get_cache()`](https://package.epinowcast.org/reference/enw_get_cache.md) : Retrieve Stan cache location - [`enw_model()`](https://package.epinowcast.org/reference/enw_model.md) : Load and compile the nowcasting model - [`enw_pathfinder()`](https://package.epinowcast.org/reference/enw_pathfinder.md) : Fit a CmdStan model using the pathfinder algorithm - [`enw_priors_as_data_list()`](https://package.epinowcast.org/reference/enw_priors_as_data_list.md) : Convert prior `data.frame` to list - [`enw_replace_priors()`](https://package.epinowcast.org/reference/enw_replace_priors.md) : Replace default priors with user specified priors - [`enw_sample()`](https://package.epinowcast.org/reference/enw_sample.md) : Fit a CmdStan model using NUTS - [`enw_set_cache()`](https://package.epinowcast.org/reference/enw_set_cache.md) : Set caching location for Stan models - [`enw_stan_to_r()`](https://package.epinowcast.org/reference/enw_stan_to_r.md) : Expose `epinowcast` stan functions in R - [`enw_unset_cache()`](https://package.epinowcast.org/reference/enw_unset_cache.md) : Unset Stan cache location - [`remove_profiling()`](https://package.epinowcast.org/reference/remove_profiling.md) : Remove profiling statements from a character vector representing stan code - [`write_stan_files_no_profile()`](https://package.epinowcast.org/reference/write_stan_files_no_profile.md) : Write copies of the .stan files of a Stan model and its \#include files with all profiling statements removed. ## Postprocess Functions for postprocessing model output - [`build_ord_obs()`](https://package.epinowcast.org/reference/build_ord_obs.md) : Build the ord_obs `data.table`. - [`.check_primarycensored()`](https://package.epinowcast.org/reference/dot-check_primarycensored.md) : Error if the primarycensored package is not installed - [`.delay_draw_columns()`](https://package.epinowcast.org/reference/dot-delay_draw_columns.md) : Extract the index-ordered draw columns for a delay vector parameter - [`.discretise_parametric_pmf()`](https://package.epinowcast.org/reference/dot-discretise_parametric_pmf.md) : Discretise a parametric delay distribution - [`enw_add_latest_obs_to_nowcast()`](https://package.epinowcast.org/reference/enw_add_latest_obs_to_nowcast.md) : Add latest observations to nowcast output - [`enw_nowcast_samples()`](https://package.epinowcast.org/reference/enw_nowcast_samples.md) : Extract posterior samples for the nowcast prediction - [`enw_nowcast_summary()`](https://package.epinowcast.org/reference/enw_nowcast_summary.md) : Summarise the posterior nowcast prediction - [`enw_posterior()`](https://package.epinowcast.org/reference/enw_posterior.md) : Summarise the posterior - [`enw_posterior_delay()`](https://package.epinowcast.org/reference/enw_posterior_delay.md) : Posterior samples of the parametric reporting-delay distribution - [`enw_pp_summary()`](https://package.epinowcast.org/reference/enw_pp_summary.md) : Posterior predictive summary - [`enw_quantiles_to_long()`](https://package.epinowcast.org/reference/enw_quantiles_to_long.md) : Convert summarised quantiles from wide to long format - [`enw_summarise_samples()`](https://package.epinowcast.org/reference/enw_summarise_samples.md) : Summarise posterior samples - [`subset_obs()`](https://package.epinowcast.org/reference/subset_obs.md) : Subset observations data table for either modelled dates or not-modelled earlier dates. ## Plot Functions for plotting preprocessed data and nowcast model output - [`enw_delay_categories()`](https://package.epinowcast.org/reference/enw_delay_categories.md) : Categorise new confirmations by delay group - [`enw_delay_quantiles()`](https://package.epinowcast.org/reference/enw_delay_quantiles.md) : Empirical delay quantiles by reference date - [`enw_plot_delay_counts()`](https://package.epinowcast.org/reference/enw_plot_delay_counts.md) : Plot notifications by delay group - [`enw_plot_delay_cumulative()`](https://package.epinowcast.org/reference/enw_plot_delay_cumulative.md) : Plot cumulative empirical reporting delay - [`enw_plot_delay_fraction()`](https://package.epinowcast.org/reference/enw_plot_delay_fraction.md) : Plot empirical reporting delay heatmap - [`enw_plot_delay_quantiles()`](https://package.epinowcast.org/reference/enw_plot_delay_quantiles.md) : Plot empirical reporting delay quantiles - [`enw_plot_nowcast_quantiles()`](https://package.epinowcast.org/reference/enw_plot_nowcast_quantiles.md) : Plot nowcast quantiles - [`enw_plot_obs()`](https://package.epinowcast.org/reference/enw_plot_obs.md) : Generic quantile plot - [`enw_plot_pp_quantiles()`](https://package.epinowcast.org/reference/enw_plot_pp_quantiles.md) : Plot posterior prediction quantiles - [`enw_plot_quantiles()`](https://package.epinowcast.org/reference/enw_plot_quantiles.md) : Generic quantile plot - [`enw_plot_theme()`](https://package.epinowcast.org/reference/enw_plot_theme.md) : Package plot theme - [`plot(`*``*`)`](https://package.epinowcast.org/reference/plot.enw_preprocess_data.md) : Plot method for enw_preprocess_data - [`plot(`*``*`)`](https://package.epinowcast.org/reference/plot.epinowcast.md) : Plot method for epinowcast ## Model validation Functions for validating model fits - [`as_forecast_sample(`*``*`)`](https://package.epinowcast.org/reference/as_forecast_sample.epinowcast.md) : Convert an epinowcast object to a forecast_sample object ## Formula design tools Functions that assist with interpreting model formulas - [`ar()`](https://package.epinowcast.org/reference/ar.md) : Autoregressive alias for [`arima()`](https://rdrr.io/r/stats/arima.html) - [`arima()`](https://package.epinowcast.org/reference/arima.md) : Adds an ARIMA(p, d, q) latent residual to the model. - [`arima_terms()`](https://package.epinowcast.org/reference/arima_terms.md) : Finds ARIMA terms in a formula object - [`arma()`](https://package.epinowcast.org/reference/arma.md) : ARMA alias for [`arima()`](https://rdrr.io/r/stats/arima.html) - [`as_string_formula()`](https://package.epinowcast.org/reference/as_string_formula.md) : Converts formulas to strings - [`construct_arima()`](https://package.epinowcast.org/reference/construct_arima.md) : Constructs ARIMA term metadata - [`construct_gp()`](https://package.epinowcast.org/reference/construct_gp.md) : Constructs Gaussian process term metadata - [`construct_re()`](https://package.epinowcast.org/reference/construct_re.md) : Constructs random effect terms - [`construct_rw()`](https://package.epinowcast.org/reference/construct_rw.md) : Constructs random walk terms - [`enw_formula()`](https://package.epinowcast.org/reference/enw_formula.md) : Define a model using a formula interface - [`enw_manual_formula()`](https://package.epinowcast.org/reference/enw_manual_formula.md) : Define a model manually using fixed and random effects - [`gp()`](https://package.epinowcast.org/reference/gp.md) : Adds an approximate Gaussian process to the model. - [`gp_terms()`](https://package.epinowcast.org/reference/gp_terms.md) : Finds Gaussian process terms in a formula object - [`ma()`](https://package.epinowcast.org/reference/ma.md) : Moving-average alias for [`arima()`](https://rdrr.io/r/stats/arima.html) - [`parse_formula()`](https://package.epinowcast.org/reference/parse_formula.md) : Parse a formula into components - [`re()`](https://package.epinowcast.org/reference/re.md) : Defines random effect terms using the lme4 syntax - [`remove_arima_terms()`](https://package.epinowcast.org/reference/remove_arima_terms.md) : Remove ARIMA terms from a formula object - [`remove_gp_terms()`](https://package.epinowcast.org/reference/remove_gp_terms.md) : Remove Gaussian process terms from a formula object - [`remove_rw_terms()`](https://package.epinowcast.org/reference/remove_rw_terms.md) : Remove random walk terms from a formula object - [`rw()`](https://package.epinowcast.org/reference/rw.md) : Adds random walks with Gaussian steps to the model. - [`rw_terms()`](https://package.epinowcast.org/reference/rw_terms.md) : Finds random walk terms in a formula object - [`split_formula_to_terms()`](https://package.epinowcast.org/reference/split_formula_to_terms.md) : Split formula into individual terms ## Model design tools Functions that assist with designing models - [`enw_add_cumulative_membership()`](https://package.epinowcast.org/reference/enw_add_cumulative_membership.md) : Add a cumulative membership effect to a `data.frame` - [`enw_add_pooling_effect()`](https://package.epinowcast.org/reference/enw_add_pooling_effect.md) : Add a pooling effect to model design metadata - [`enw_design()`](https://package.epinowcast.org/reference/enw_design.md) : A helper function to construct a design matrix from a formula - [`enw_effects_metadata()`](https://package.epinowcast.org/reference/enw_effects_metadata.md) : Extracts metadata from a design matrix - [`enw_one_hot_encode_feature()`](https://package.epinowcast.org/reference/enw_one_hot_encode_feature.md) : One-hot encode a variable and column-bind it to the original data.table ## Datasets Package datasets used in examples and by users to explore the package functionality - [`enw_example()`](https://package.epinowcast.org/reference/enw_example.md) : Load a package example - [`germany_covid19_hosp`](https://package.epinowcast.org/reference/germany_covid19_hosp.md) : Hospitalisations in Germany by date of report and reference ## Simulate Datasets Tools for simulating datasets - [`enw_simulate_missing_reference()`](https://package.epinowcast.org/reference/enw_simulate_missing_reference.md) : Simulate observations with a missing reference date. ## Check inputs Functions to check the structure of user inputs - [`check_design_matrix_sparsity()`](https://package.epinowcast.org/reference/check_design_matrix_sparsity.md) : Check design matrix sparsity - [`check_group()`](https://package.epinowcast.org/reference/check_group.md) : Check observations for reserved grouping variables - [`check_group_date_unique()`](https://package.epinowcast.org/reference/check_group_date_unique.md) : Check observations for uniqueness of grouping variables with respect to `reference_date` and `report_date` - [`check_max_delay()`](https://package.epinowcast.org/reference/check_max_delay.md) : Check appropriateness of maximum delay - [`check_module()`](https://package.epinowcast.org/reference/check_module.md) : Check a model module contains the required components - [`check_modules_compatible()`](https://package.epinowcast.org/reference/check_modules_compatible.md) : Check that model modules have compatible specifications - [`check_numeric_timestep()`](https://package.epinowcast.org/reference/check_numeric_timestep.md) : Check Numeric Timestep - [`check_observation_indicator()`](https://package.epinowcast.org/reference/check_observation_indicator.md) : Check observation indicator - [`check_quantiles()`](https://package.epinowcast.org/reference/check_quantiles.md) : Check required quantiles are present - [`check_timestep()`](https://package.epinowcast.org/reference/check_timestep.md) : Check timestep - [`check_timestep_by_date()`](https://package.epinowcast.org/reference/check_timestep_by_date.md) : Check timestep by date - [`check_timestep_by_group()`](https://package.epinowcast.org/reference/check_timestep_by_group.md) : Check timestep by group ## Utilities Utility functions - [`coerce_date()`](https://package.epinowcast.org/reference/coerce_date.md) : Coerce Dates - [`coerce_dt()`](https://package.epinowcast.org/reference/coerce_dt.md) : Coerce `data.table`s - [`date_to_numeric_modulus()`](https://package.epinowcast.org/reference/date_to_numeric_modulus.md) : Convert date column to numeric and calculate its modulus with given timestep. - [`enw_get_data()`](https://package.epinowcast.org/reference/enw_get_data.md) : Extract data from preprocessed nowcast objects - [`enw_rolling_sum()`](https://package.epinowcast.org/reference/enw_rolling_sum.md) : Perform rolling sum aggregation - [`get_internal_timestep()`](https://package.epinowcast.org/reference/get_internal_timestep.md) : Get internal timestep - [`is.Date()`](https://package.epinowcast.org/reference/is.Date.md) : Check an object is a Date - [`stan_fns_as_string()`](https://package.epinowcast.org/reference/stan_fns_as_string.md) : Read in a stan function file as a character string # Articles ### All vignettes - [ARIMA latent residuals: maths, priors, and usage](https://package.epinowcast.org/articles/arima.md): The maths behind the ARIMA(p, d, q) latent residuals in epinowcast, how to use them in any module’s formula, and how to set their priors. - [Estimating reporting delays with the full and delay-only models](https://package.epinowcast.org/articles/delay-estimation.md): A walk through of estimating a reporting delay distribution, comparing the full nowcasting model with the delay-only model that conditions on known totals. - [Discretised distributions](https://package.epinowcast.org/articles/distributions.md): Distributions and their discretisation in epinowcast - [Getting Started with Epinowcast: Nowcasting](https://package.epinowcast.org/articles/epinowcast.md): A quick start example demonstrating use of epinowcast to nowcast hospital admissions. - [Model Features Summary](https://package.epinowcast.org/articles/features.md): Quick reference to package capabilities - [Gaussian process latent terms: maths, priors, and usage](https://package.epinowcast.org/articles/gaussian-process.md): The maths behind the Hilbert-space approximate Gaussian process latent terms in epinowcast, how to use them in any module’s formula, and how to set their priors. - [Hierarchical nowcasting of age stratified COVID-19 hospitalisations in Germany](https://package.epinowcast.org/articles/germany-age-stratified-nowcasting.md): A case study exploring hierarchical models of varying complexity to jointly nowcast age stratified COVID-19 hospitalisations in Germany. - [Comparing Inference Methods](https://package.epinowcast.org/articles/inference-methods.md): A comparison of NUTS sampling, pathfinder approximate inference, and pathfinder-initialised NUTS across two model specifications. - [Latent process and periodic options for the growth-rate model](https://package.epinowcast.org/articles/latent-processes.md): Random walks, ARIMA(p, d, q) residuals, and periodic effects — the time-series structures available in the formula interface for the growth rate. - [Model definition and implementation](https://package.epinowcast.org/articles/model.md): Model formulation and implementation details - [Case studies](https://package.epinowcast.org/articles/package-use-cases.md): A place to document how epinowcast has been used - [Visualising Preprocessed Data](https://package.epinowcast.org/articles/preprocess-visualisation.md): Understanding reporting patterns before model fitting. - [Estimating the effective reproduction number in real-time for a single timeseries with reporting delays](https://package.epinowcast.org/articles/single-timeseries-rt-estimation.md): A walk through of a simple approach to jointly estimating the effective reproduction number over time and the delay from a positive test to this test being reported. - [Resources to help with model fitting using Stan](https://package.epinowcast.org/articles/stan-help.md): How to address issues you may encounter with Stan - [Temporal aggregation guide](https://package.epinowcast.org/articles/temporal-aggregation.md): How to fit nowcasts when the data and process timesteps differ, including pure weekly, weekly reporting on a daily process, and a daily benchmark.