This is the first release of epidist on CRAN.
epidist estimates epidemiological delay distributions, such as the incubation period or the delay from onset to report, using brms.
It corrects for the common biases in these data: interval censoring of the primary and secondary events, right truncation, left truncation, and the dynamical bias from a growing or shrinking epidemic.
It provides a naive model, a latent model that samples the unobserved event times, and a marginal model that integrates them out through primarycensored.
It also provides an experimental meta model, which fits published summary estimates jointly with individual level data and adjusts each summary for how its study was estimated.
Delays can follow a lognormal, gamma, Weibull or generalised gamma distribution.
Every distributional parameter can take a brms formula, so delays can vary with covariates, over time or between groups with partial pooling.
Tools for preparing data, setting priors, simulating data, summarising and plotting fitted delay distributions, and passing them on to other packages complete the workflow.
The meta model is still experimental and its interface may change.
gengamma(), a generalised gamma delay family in the Prentice parameterisation of flexsurv::dgengamma(), for the naive, latent, marginal and meta models.
The Weibull and gamma are special cases and the lognormal is its limit.
Closes #644.epidist_meta_leave_one_out() gains a studies argument that holds out only the studies named, so a model with many studies can be checked against its largest few.epidist now needs primarycensored 1.6.0 or later.
Closes #807.epidist_gen_meta_log_lik() and as_epidist_meta_model() now states the cost of log_lik() and loo() for meta model summary rows, and how ndraws reduces it.
Closes #705.simulate_*() functions and to epidist_family(), epidist_formula(), epidist_prior() and epidist_stancode().brms functions, so log_lik(), posterior_predict() and posterior_epred() use epidist's own functions for every family.
These cover the lognormal, gamma, Weibull, exponential and generalised gamma families.
For any other family these functions now give an error.epidist_meta_leave_one_out() runs the chains of each refit in parallel by default, where they previously ran one after another.
Its new cores argument defaults to the mc.cores option where it is set and otherwise to one core per chain.print() of an epidist_multivariate object writes its header as output rather than a message, so suppressMessages() no longer hides it.bookdown::html_vignette2, which cuts the installed size of the package by about 4Mb.sierra_leone_ebola_data source by its DOI and corrected its column descriptions.BH, Rcpp, RcppEigen, pkgdown and usethis suggested dependencies.epireview is no longer a suggested dependency, so the package needs no repository beyond CRAN.
epidist_estimates_epireview() takes any table with the columns epireview uses.This release adds a meta model for fitting to published summary estimates, exponentially growing primary events, left truncation, and a new set of tools for post-processing and plotting fitted models. It also removes several functions and changes some interfaces, as listed below.
predict_delay_parameters() and predict_dpar() are removed in favour of delay_parameter_draws(), and add_mean_sd() in favour of add_summaries().
See #471.epidist_family_param() and epidist_transform_data() are now internal.
Extensions implement epidist_family_model() and epidist_transform_data_model() instead.
See #79.is_epidist_*() predicates share one signature, is_epidist_<class>(data), and no longer take ....
Closes #706.epidist data objects share an epidist_data class, checked by is_epidist_data().
They re-check themselves when modified and drop any class whose requirements they no longer meet, with a warning.
See ?epidist_data and #399.cmdstanr is no longer a suggested dependency.
Tests and examples fit through rstan, and cmdstanr remains available as a brms backend.
See #687 and #688.brms 2.23.0 and primarycensored 1.5.2.
The Remotes field is removed, so all dependencies resolve from CRAN.
See #592 and #727.as_epidist_meta_model(), which fits published summary estimates jointly with individual level data.
Each summary is forward modelled from the study's own estimation procedure, so estimates that did not adjust for censoring or truncation still contribute unbiased information.
It is experimental and its interface may change.
See #620.as_epidist_estimates_data(), epidist_estimates_summaries(), epidist_estimates_parameters(), epidist_estimates_epireview() and as_epidist_multivariate() for preparing published estimates.
They cover means, standard deviations, quantiles, standard errors, fitted distribution parameters and summaries with a covariance, and check the inputs for common problems.
See #620.epidist_gen_meta_log_lik() and epidist_gen_meta_predict(), so log_lik(), loo() and posterior predictions work for meta model fits.
See #620.epidist_meta_leave_one_out(), which refits a meta model once per study with that study held out and reports how the delay mean and standard deviation change.
Closes #642.simulate_study(), which applies a published study's observation and estimation procedure to a simulated line list.
Closes #672.NA or uncertain growth_rate values, sharing it with individual level data.
Closes #678.primary = "expgrowth" for the latent, marginal and meta models.
The growth rate is a distributional parameter, so it takes a formula and prior.
See #489 and #618.delay_min argument to as_epidist_marginal_model(), also supported by the meta model.
See #588 and #596.delay_parameter_draws(), add_delay_parameter_draws(), add_summaries(), epidist_strata() and delay_summary_draws() for posterior draws of the delay distribution and its mean, standard deviation and quantiles.
epidist_newdata() builds the newdata they need.
See #280, #471 and #667.plot_events(), plot_delays(), and plot() and ggplot2::autoplot() methods for delay draws.
plot_delays() also gives a posterior predictive check of a fitted model.
See #670, #689 and #743.distspec::as_dist_spec() method for fitted models.
See #712.simulate_dates(), which turns simulated event times into censored dates.epidist_gen_log_lik(), and made its generic method linear in the number of posterior draws.
See #79, #476 and #646.epidist_prior() no longer warns about user priors on valid brms parameters, and lists unmatched priors clearly.
See #483.epidist() now restores the PKG_CPPFLAGS and PKG_LIBS environment variables that rstan leaves set.
See #532.epidist_gen_log_lik() method now normalises over delay_min when there is no right truncation.
Closes #646.delay_parameter_draws() no longer passes on the brms warning about the infinite observation times epidist uses.
Closes #718.dplyr verbs, so plot() still dispatches.
Closes #721.brms functions.
See #420.epidist.
See #596 and #620.L (left truncation) parameter to the primarycensored_lpmf call in
the marginal model. See #583.primarycensored (>= 1.4.0) version bound to DESCRIPTION.primarycensored_lpmf and ODE/distribution helpers) with
pcd_load_stan_functions(dependencies = TRUE) instead of loading all
functions. See #582.check-cmdstan workflow to also check marginal model Stan syntax.as_epidist_marginal_model(). See #565.Hotfix release to patch a change in how the grepl function works in new versions of R.
This release adds support for a wider range of distributions in the marginal model, improves documentation with new vignettes and FAQ sections, enhances the getting started guide with clearer examples of model comparison, and fixes several bugs related to parameter bounds and likelihood calculations.
primarycensored in the marginal model. See #540.posterior package with epidist models, particularly for working with random variables (rvars) to propagate uncertainty in calculations. See #547.marginaleffects package with epidist models. See #547.predict_delay_parameters() where it couldn't detect brms families when used directly. See #549.This release adds a new marginal model based on primarycensored which provides a more efficient approach for fitting delay distributions compared to the existing latent model. We've also improved data handling by adding support for aggregated data across all models, added comprehensive examples using real world data, and enhanced documentation based on user feedback. The package has also undergone significant internal improvements including generalised Stan reparameterisation and improved data transformation methods.
As part of this release we have moved from @athowes maintaining the package (who led the initial package development, implementation of the S3 infrastructure, implementation of the core models, and wrote the first versions of the getting started vignette, Ebola case study, FAQ section, and the approximate inference vignette) to @seabbs maintaining the package.
primarycensored. This can be specified using as_epidist_marginal_model(). This is currently limited to Weibull, log-normal, and gamma distributions with uniform primary censoring but this will be generalised in future releases. See #426.weight argument to as_epidist_marginal_model() to allow for weighted data (for example count data) to be used in the marginal model. See #509.epidist_aggregate_data method to as_epidist_marginal_model() to allow straightforward use of the marginal model with aggregated data. See #510.epidist_aggregate_data method to as_epidist_latent_model() to allow straightforward use of the latent model with aggregated data. See #510.epidist_aggregate_data method to as_epidist_naive_model() to allow straightforward use of the naive model with aggregated data. See #510.epidist(). See #473.enforce_presence argument to epidist_prior() to allow for priors to be
specified if they do not match existing parameters. See #474.merge argument to epidist_prior() to allow for not merging user and package priors. See #474.brms and then extracting the reparameterisation. See #474.transform_data S3 method to allow for data to be transformed for specific models. This is specifically useful for the marginal model at the moment as it allows reducing the data to its unique strata. See #474.epidist_aggregate_data class to handle pre-aggregated line list data. See #510.as_epidist_aggregate_data() method for epidist_linelist_data objects to allow for easy conversion to aggregate data. See #510.as_epidist_linelist_data() method for epidist_aggregate_data objects to allow for easy conversion to linelist data. See #510.sierra_leone_ebola_data to the package. See #510.epidist_transform_data() methods work for the marginal and naive models. See #510.epinowcast standards. See #467.primarycensored that doesn't make use of size(). This fixes some Mac compilation edge cases. See #524.This is the first minor release of epidist intended for early test users of the package.
As some features may change, the package is marked as experimental.
We expect to release a stable 1.0.0 version shortly.
The epidist package implements models for epidemiological delay distributions.
It uses brms to perform Bayesian inference.
One data format is currently available:
Two statistical models are currently available:
brmsThe package is readily extensible to additional models via an S3 class based system. In particular, model fitting with [epidist()] is possible using S3 classes for custom:
We provide functionality for post-processing.
Alternatively, users may directly use tidybayes for specific families.
Three vignettes are available. There is also a frequently asked questions section.