diff --git a/NAMESPACE b/NAMESPACE index d1293237c..bcf83cf6c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -19,7 +19,6 @@ export(filter_obs_by_obs_time) export(filter_obs_by_ptime) export(filtered_censoring_adjusted_delay) export(filtered_naive_delay) -export(get_targets_archive) export(latent_censoring_adjusted_delay) export(latent_truncation_censoring_adjusted_delay) export(linelist_to_cases) @@ -39,9 +38,6 @@ export(primary_censoring_bias_correction) export(reverse_obs_at) export(sample_epinowcast_model) export(sample_model) -export(save_csv) -export(save_dataset) -export(save_rds) export(simulate_double_censored_pmf) export(simulate_exponential_cases) export(simulate_gillespie) @@ -51,9 +47,7 @@ export(summarise_draws) export(summarise_variable) export(truncation_adjusted_delay) export(truncation_censoring_adjusted_delay) -export(upload_targets_archive) import(brms) import(cmdstanr) import(data.table) import(ggplot2) -importFrom(ggplot2,ggsave) diff --git a/README.md b/README.md new file mode 100644 index 000000000..a8493afe9 --- /dev/null +++ b/README.md @@ -0,0 +1,218 @@ + +# Estimate epidemiological delay distributions for infectious diseases + + + +[![Lifecycle: +experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) +[![R-CMD-check](https://github.com/epinowcast/epidist/workflows/R-CMD-check/badge.svg)](https://github.com/epinowcast/epidist/actions/workflows/R-CMD-check.yaml) +[![Codecov test +coverage](https://codecov.io/gh/epinowcast/epidist/branch/main/graph/badge.svg)](https://app.codecov.io/gh/epinowcast/epidist) +
+[![Universe](https://epinowcast.r-universe.dev/badges/epidist)](https://epinowcast.r-universe.dev/epidist) +[![MIT +license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/epinowcast/epidist/blob/master/LICENSE.md/) +[![GitHub +contributors](https://img.shields.io/github/contributors/epinowcast/epidist)](https://github.com/epinowcast/epidist/graphs/contributors) +
+[![DOI](https://zenodo.org/badge/422611952.svg)](https://zenodo.org/badge/latestdoi/422611952) + + +*Warning: This package is a prototype and is under active development. +Breaking changes are likely.* + +## Summary + +Understanding and accurately estimating epidemiological delay +distributions is important for public health policy. These estimates +directly influence epidemic situational awareness, control strategies, +and resource allocation. In this package, we provide methods to address +the key challenges in estimating these distributions, including +truncation, interval censoring, and dynamical biases. Despite their +importance, these issues are frequently overlooked, often resulting in +biased conclusions. + +## 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( + "epidist", 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/epidist", dependencies = TRUE +) +``` + +Similarly, you can install historical versions by specifying the release +tag (e.g. this installs +[`0.1.0`](https://github.com/epinowcast/epidist/releases/tag/v0.1.0)): + +``` r +remotes::install_github( + "epinowcast/epidist", 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 CmdStan + +If you wish to do model fitting and nowcasting, you will need to install +[CmdStan](https://mc-stan.org/users/interfaces/cmdstan), which also +entails having a suitable C++ toolchain setup. We recommend using the +[`cmdstanr` package](https://mc-stan.org/cmdstanr/). 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/), but the brief version is: + +``` r +# if you not yet installed `epinowcast`, or you installed it without `Suggests` dependencies +install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", 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/epidist). +You can use this image to run `epidist` 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) and +to [highlight other features with 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/epidist/issues). Please check and +add to the issues, and/or add a [pull +request](https://github.com/epinowcast/epidist/pulls) and see our +[contributing guide](CONTRIBUTING.md) for more information. + +### 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/epidist/issues). If you have a +question, please don’t open an issue. Instead, ask on our [Q and A +page](https://github.com/epinowcast/dist/discussions/categories/q-a). +See our [contributing guide](CONTRIBUTING.md) for more information. + +### Code of Conduct + +Please note that the `epidist` project is released with a [Contributor +Code of Conduct](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://epidist.epinowcast.org/articles/model.html). If you use +`epidist` in your work, please consider citing it with +`citation("epidist")`. diff --git a/man/dynamicaltruncation-package.Rd b/man/dynamicaltruncation-package.Rd deleted file mode 100644 index 7a82ebe99..000000000 --- a/man/dynamicaltruncation-package.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/epidist-package.R -\docType{package} -\name{epidist-package} -\alias{epidist} -\alias{epidist-package} -\title{epidist: Adjusting for Common Biases in Infectious Disease Data when Estimating Distributions} -\description{ -Adjusting for common biases in infectious disease data when estimating distributions -} -\author{ -\strong{Maintainer}: First Last \email{first.last@example.com} (\href{https://orcid.org/YOUR-ORCID-ID}{ORCID}) - -} -\keyword{internal} diff --git a/man/epidist-package.Rd b/man/epidist-package.Rd new file mode 100644 index 000000000..d23459e67 --- /dev/null +++ b/man/epidist-package.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/epidist-package.R +\docType{package} +\name{epidist-package} +\alias{epidist} +\alias{epidist-package} +\title{epidist: Estimate epidemiological delay distributions for infectious diseases} +\description{ +Understanding and accurately estimating epidemiological delay distributions is important for public health policy. These estimates directly influence epidemic situational awareness, control strategies, and resource allocation. In this package, we provide methods to address the key challenges in estimating these distributions, including truncation, interval censoring, and dynamical biases. Despite their importance, these issues are frequently overlooked, often resulting in biased conclusions. +} +\author{ +\strong{Maintainer}: Sang Woo Park \email{swp2@princeton.edu} (\href{https://orcid.org/0000-0003-2202-3361}{ORCID}) + +Authors: +\itemize{ + \item Sam Abbott \email{contact@samabbott.co.uk} (\href{https://orcid.org/0000-0001-8057-8037}{ORCID}) +} + +} +\keyword{internal} diff --git a/man/get_targets_archive.Rd b/man/get_targets_archive.Rd deleted file mode 100644 index c2022e1ed..000000000 --- a/man/get_targets_archive.Rd +++ /dev/null @@ -1,11 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/targets-archive.R -\name{get_targets_archive} -\alias{get_targets_archive} -\title{Downloads the targets archive} -\usage{ -get_targets_archive(dir = ".", ...) -} -\description{ -Downloads the targets archive -} diff --git a/man/save_csv.Rd b/man/save_csv.Rd deleted file mode 100644 index 16e334af2..000000000 --- a/man/save_csv.Rd +++ /dev/null @@ -1,11 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{save_csv} -\alias{save_csv} -\title{Save a dataframe to a csv and return the path for targets} -\usage{ -save_csv(dt, filename, path, allow_empty = TRUE) -} -\description{ -Save a dataframe to a csv and return the path for targets -} diff --git a/man/save_dataset.Rd b/man/save_dataset.Rd deleted file mode 100644 index aa87d2823..000000000 --- a/man/save_dataset.Rd +++ /dev/null @@ -1,11 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{save_dataset} -\alias{save_dataset} -\title{Save a dataframe as an Arrow dataset} -\usage{ -save_dataset(dt, path, ...) -} -\description{ -Save a dataframe as an Arrow dataset -} diff --git a/man/save_plot.Rd b/man/save_plot.Rd deleted file mode 100644 index 819dae95e..000000000 --- a/man/save_plot.Rd +++ /dev/null @@ -1,11 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{save_plot} -\alias{save_plot} -\title{Save a plot and return the path for targets} -\usage{ -save_plot(plot, filename, path, ...) -} -\description{ -Save a plot and return the path for targets -} diff --git a/man/save_rds.Rd b/man/save_rds.Rd deleted file mode 100644 index dcaeaadd4..000000000 --- a/man/save_rds.Rd +++ /dev/null @@ -1,11 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{save_rds} -\alias{save_rds} -\title{Save a dataframe to an RDS} -\usage{ -save_rds(dt, filename, path, allow_empty = TRUE) -} -\description{ -Save a dataframe to an RDS -} diff --git a/man/simulate_double_censored_pmf.Rd b/man/simulate_double_censored_pmf.Rd index b5790bea5..b5385b5fb 100644 --- a/man/simulate_double_censored_pmf.Rd +++ b/man/simulate_double_censored_pmf.Rd @@ -10,8 +10,8 @@ simulate_double_censored_pmf( max, n = 1000, rprimary = function(x) (runif(x, 0, 1)), - rsecondary = function(x) (runif(x, 0, 1)), - rdelay = rlnorm + rdelay = rlnorm, + delay_obs_process = function(s, p) (floor(s) - floor(p)) ) } \arguments{ @@ -26,11 +26,12 @@ simulate_double_censored_pmf( \item{rprimary}{Random number generator function for primary events. Defaults to runif.} -\item{rsecondary}{Random number generator function for secondary events. -Defaults to runif.} - \item{rdelay}{Random number generator function for delays. Defaults to rlnorm.} + +\item{delay_obs_process}{Observation process for delays. Defaults to +using the \code{floor} function to round both primary and secondary events to the +nearest integer. Internally the delay is also bounded to be non-negative.} } \value{ A probability mass function that represents the distribution of the diff --git a/man/upload_targets_archive.Rd b/man/upload_targets_archive.Rd deleted file mode 100644 index 94ed13389..000000000 --- a/man/upload_targets_archive.Rd +++ /dev/null @@ -1,11 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/targets-archive.R -\name{upload_targets_archive} -\alias{upload_targets_archive} -\title{Upload the targets archive} -\usage{ -upload_targets_archive(...) -} -\description{ -Upload the targets archive -}