Skip to content

Commit

Permalink
swap from macro to markdown for lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Nov 20, 2020
1 parent aac0b88 commit 22920d7
Show file tree
Hide file tree
Showing 124 changed files with 213 additions and 214 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,3 @@ LinkingTo:
rstan (>= 2.21.1),
StanHeaders (>= 2.21.0-5)
Language: en-GB
RdMacros: lifecycle
2 changes: 1 addition & 1 deletion R/adjust.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Adjust from Case Counts by Infection Date to Date of Report
#'
#' @description \lifecycle{soft-deprecated}
#' @description `r lifecycle::badge("soft-deprecated")`
#' Maps from cases by date of infection to date of report via date of
#' onset.
#' @param infections `data.table` containing a `date` variable and a numeric `cases` variable.
Expand Down
22 changes: 11 additions & 11 deletions R/create.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' Create Clean Reported Cases
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Cleans a data frame of reported cases by replacing missing dates with 0 cases and applies an optional
#' threshold at which point 0 cases are replaced with a moving average of observed cases. See `zero_threshold`
#' for details.
Expand Down Expand Up @@ -40,7 +40,7 @@ create_clean_reported_cases <- function(reported_cases, horizon, zero_threshold

#' Create Delay Shifted Cases
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' This functions creates a data frame of reported cases that has been smoothed using
#' a rolling average (with a period set by `smoothing_window`) and shifted back in time
#' by some delay. It is used by `estimate_infections` to generate the mean shifted prior
Expand Down Expand Up @@ -86,7 +86,7 @@ create_shifted_cases <- function(reported_cases, shift,

#' Construct the Required Future Rt assumption
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Converts the `future` argument from `rt_opts()` into arguments that can be passed to `stan`.
#' @param future A character string or integer. This argument indicates how to set future Rt values. Supported
#' options are to project using the Rt model ("project"), to use the latest estimate based on partial data ("latest"),
Expand Down Expand Up @@ -114,7 +114,7 @@ create_future_rt <- function(future = "latest", delay = 0) {

#' Create Time-varying Reproduction Number Data
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Takes the output from `rt_opts()` and converts it into a list understood by
#' `stan`.
#' @param rt A list of options as generated by `rt_opts()` defining Rt estimation.
Expand Down Expand Up @@ -178,7 +178,7 @@ create_rt_data <- function(rt = rt_opts(), breakpoints = NULL,
}
#' Create Back Calculation Data
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Takes the output of `backcalc_opts()` and converts it into a list understood by `stan`.
#' @param backcalc A list of options as generated by `backcalc_opts()` to define the
#' back calculation. Defaults to `backcalc_opts()`.
Expand Down Expand Up @@ -208,7 +208,7 @@ create_backcalc_data <- function(backcalc = backcalc_opts) {
}
#' Create Gaussian Process Data
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Takes the output of `gp_opts()` and converts it into a list understood by `stan`.
#' @param gp A list of options as generated by `gp_opts()` to define the
#' Gaussian process. Defaults to `gp_opts()`.Set to NULL to disable the
Expand Down Expand Up @@ -273,7 +273,7 @@ create_gp_data <- function(gp = gp_opts(), data) {

#' Create Observation Model Settings
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Takes the output of `obs_opts()` and converts it into a list understood by `stan`.
#' @param obs A list of options as generated by `obs_opts()` defining the
#' observation model. Defaults to `obs_opts()`.
Expand Down Expand Up @@ -306,12 +306,12 @@ create_obs_model <- function(obs = obs_opts()) {
}
#' Create Stan Data Required for estimate_infections
#'
#' @description \lifecycle{stable}
#' @description`r lifecycle::badge("stable")`
#' Takes the output of `stan_opts()` and converts it into a list understood by `stan`. Internally
#' calls the other `create_` family of functions to construct a single list for input into stan
#' with all data required present.
#' @param shifted_cases A dataframe of delay shifted cases
#' @param truncation \lifecycle{experimental} A list of options as generated by `trunc_opts()`
#' @param truncation `r lifecycle::badge("experimental")` A list of options as generated by `trunc_opts()`
#' defining the truncation of observed data. Defaults to `trunc_opts()`. See `estimate_truncation()`
#' for an approach to estimating truncation from data.
#' @inheritParams create_gp_data
Expand Down Expand Up @@ -383,7 +383,7 @@ create_stan_data <- function(reported_cases, generation_time,
}

#' Create Initial Conditions Generating Function
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Uses the output of `create_stan_data` to create a function which can be used to
#' sample from the prior distributions (or as close as possible) for parameters. Used
#' in order to initialise each `stan` chain within a range of plausible values.
Expand Down Expand Up @@ -447,7 +447,7 @@ create_initial_conditions <- function(data) {

#' Create a List of Stan Arguments
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Generates a list of arguments as required by `rstan::sampling` or `rstan::vb` by combining the required options,
#' with data, and type of initialisation. Initialisation defaults to random but it is expected that `create_initial_conditions`
#' will be used.
Expand Down
6 changes: 3 additions & 3 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' Literature Estimates of Generation Times
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Generation time estimates. See here for details:
#' https://github.com/epiforecasts/EpiNow2/blob/master/data-raw/generation-time.R
#' @format A `data.table` of summarising the distribution
"generation_times"

#' Literature Estimates of Incubation Periods
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Incubation period estimates. See here for details:
#' https://github.com/epiforecasts/EpiNow2/blob/master/data-raw/incubation-period.R
#' @format A `data.table` of summarising the distribution
Expand All @@ -17,7 +17,7 @@

#' Example Confirmed Case Data Set
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' An example data frame of observed cases
#' @format A data frame containing cases reported on each date.
"example_confirmed"
16 changes: 8 additions & 8 deletions R/dist.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Distribution Skeleton
#'
#' @description \lifecycle{questioning}
#' @description `r lifecycle::badge("questioning")`
#' This function acts as a skeleton for a truncated distribution defined by
#' model type, maximum value and model parameters. It is designed to be used with the
#' output from `get_dist`.
Expand Down Expand Up @@ -121,7 +121,7 @@ dist_skel <- function(n, dist = FALSE, cum = TRUE, model,

#' Fit an Integer Adjusted Exponential, Gamma or Lognormal distributions
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Fits an integer adjusted exponential, gamma or lognormal distribution using
#' `stan`.
#' @param values Numeric vector of values
Expand Down Expand Up @@ -212,7 +212,7 @@ dist_fit <- function(values = NULL, samples = NULL, cores = 1,

#' Generate a Gamma Distribution Definition Based on Parameter Estimates
#'
#' @description \lifecycle{soft-deprecated}
#' @description `r lifecycle::badge("soft-deprecated")`
#' Generates a distribution definition when only parameter estimates
#' are available for gamma distributed parameters. See `rgamma` for distribution information.
#' @param shape Numeric, shape parameter of the gamma distribution.
Expand Down Expand Up @@ -268,7 +268,7 @@ gamma_dist_def <- function(shape, shape_sd,

#' Generate a Log Normal Distribution Definition Based on Parameter Estimates
#'
#' @description \lifecycle{soft-deprecated}
#' @description `r lifecycle::badge("soft-deprecated")`
#' Generates a distribution definition when only parameter estimates
#' are available for log normal distributed parameters. See `rlnorm` for distribution information.
#' @param mean Numeric, log mean parameter of the gamma distribution.
Expand Down Expand Up @@ -334,7 +334,7 @@ lognorm_dist_def <- function(mean, mean_sd,

#' Fit a Subsampled Bootstrap to Integer Values and Summarise Distribution Parameters
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Fits an integer adjusted distribution to a subsampled bootstrap of data and then integrates
#' the posterior samples into a single set of summary statistics. Can be used to generate a robust
#' reporting delay that accounts for the fact the underlying delay likely varies over time or that
Expand Down Expand Up @@ -432,7 +432,7 @@ bootstrapped_dist_fit <- function(values, dist = "lognormal",

#' Estimate a Delay Distribution
#'
#' @description \lifecycle{maturing}
#' @description `r lifecycle::badge("maturing")`
#' Estimate a log normal delay distribution from a vector of integer delays.
#' Currently this function is a simple wrapper for `bootstrapped_dist_fit`.
#' @param delays Integer vector of delays
Expand All @@ -452,7 +452,7 @@ estimate_delay <- function(delays, ...) {

#' Approximate Sampling a Distribution using Counts
#'
#' @description \lifecycle{soft-deprecated}
#' @description `r lifecycle::badge("soft-deprecated")`
#' Convolves cases by a PMF function. This function will soon be removed or replaced with a
#' more robust `stan` implementation.
#' @param cases A dataframe of cases (in date order) with the following variables:
Expand Down Expand Up @@ -595,7 +595,7 @@ sample_approx_dist <- function(cases = NULL,

#' Tune an Inverse Gamma to Achieve the Target Truncation
#'
#' @description \lifecycle{questioning}
#' @description `r lifecycle::badge("questioning")`
#' Allows an inverse gamma distribution to be. tuned so that less than 0.01 of its
#' probability mass function falls outside of the specified
#' bounds. This is required when using an inverse gamma prior, for example for a
Expand Down
14 changes: 7 additions & 7 deletions R/epinow-internal.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Updates Forecast Horizon Based on Input Data and Target
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Makes sure that a forecast is returned for the user specified
#' time period beyond the target date.
#' @inheritParams setup_target_folder
Expand All @@ -16,7 +16,7 @@ update_horizon <- function(horizon, target_date, reported_cases) {

#' Save Observed Data
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Saves observed data to a target location if given.
#' @inheritParams setup_target_folder
#' @inheritParams epinow
Expand All @@ -36,7 +36,7 @@ save_input <- function(reported_cases, target_folder) {

#' Save Estimated Infections
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Saves output from `estimate_infections` to a target directory.
#' @param estimates List of data frames as output by `estimate_infections`
#' @param samples Logical, defaults to TRUE. Should samples be saved
Expand Down Expand Up @@ -65,7 +65,7 @@ save_estimate_infections <- function(estimates, target_folder = NULL,

#' Save Forecast Infections
#'
#' @description \lifecycle{experimental}
#' @description `r lifecycle::badge("experimental")`
#' Saves the output from `forecast_infections` to a target directory.
#' @param forecast A list of data frames as output by `forecast_infections`
#' @inheritParams save_estimate_infections
Expand All @@ -85,7 +85,7 @@ save_forecast_infections <- function(forecast, target_folder = NULL, samples = T

#' Estimate Cases by Report Date
#'
#' @description \lifecycle{questioning}
#' @description `r lifecycle::badge("questioning")`
#' Either extracts or converts reported cases from an input data table. For output from
#' `estimate_infections` this is a simple filtering step but for output from `forecast_infection`
#' this is currently an approximate convolution. This step is likely to be updated/deprecated
Expand Down Expand Up @@ -158,7 +158,7 @@ estimates_by_report_date <- function(estimates, forecast, delays, CrIs = c(0.2,

#' Copy Results From Dated Folder to Latest
#'
#' @description \lifecycle{questioning}
#' @description `r lifecycle::badge("questioning")`
#' Copies output from the dated folder to a latest folder. May be undergo changes in later releases.
#' @param latest_folder Character string containing the path to the latest target folder.
#' As produced by `setup_target_folder`.
Expand Down Expand Up @@ -188,7 +188,7 @@ copy_results_to_latest <- function(target_folder = NULL, latest_folder = NULL) {

#' Construct Output
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Combines the output produced internally by `epinow` into a single list.
#' @param estimated_reported_cases A list of dataframes as produced by
#' `estimates_by_report_date`.
Expand Down
2 changes: 1 addition & 1 deletion R/epinow.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Real-time Rt Estimation, Forecasting and Reporting
#'
#' @description \lifecycle{maturing}
#' @description `r lifecycle::badge("maturing")`
#' This function wraps the functionality of `estimate_infections()` and `forecast_infections()` in order
#' to estimate Rt and cases by date of infection, forecast into these infections into the future. It also contains
#' additional functionality to convert forecasts to date of report and produce summary output useful for reporting
Expand Down
8 changes: 4 additions & 4 deletions R/estimate_infections.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Estimate Infections, the Time-Varying Reproduction Number and the Rate of Growth
#'
#' @description \lifecycle{maturing}
#' @description `r lifecycle::badge("maturing")`
#' Uses a non-parametric approach to reconstruct cases by date of infection from reported
#' cases. It uses either a generative Rt model or non-parametric back calculation to estimate underlying
#' latent infections and then maps these infections to observed cases via uncertain reporting delays and a flexible
Expand Down Expand Up @@ -256,7 +256,7 @@ estimate_infections <- function(reported_cases,

#' Fit a Stan Model using the NUTs sampler
#'
#' @description \lifecycle{maturing}
#' @description `r lifecycle::badge("maturing")`
#' Fits a stan model using `rstan::sampling`. Provides the optional ability to run chains using
#' `future` with error catching, timeouts and merging of completed chains.
#' @param args List of stan arguments
Expand Down Expand Up @@ -365,7 +365,7 @@ fit_model_with_nuts <- function(args, future = FALSE, max_execution_time = Inf,

#' Fit a Stan Model using Variational Inference
#'
#' @description \lifecycle{maturing}
#' @description `r lifecycle::badge("maturing")`
#' Fits a stan model using variational inference.
#' @inheritParams fit_model_with_nuts
#' @importFrom futile.logger flog.debug flog.info flog.error
Expand Down Expand Up @@ -425,7 +425,7 @@ fit_model_with_vb <- function(args, future = FALSE, id = "stan", verbose = FALSE

#' Format Posterior Samples
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Summaries posterior samples and adds additional custom variables.
#' @param posterior_samples A list of posterior samples as returned by `extract_parameter_samples`
#' @param horizon Numeric, forecast horizon
Expand Down
6 changes: 3 additions & 3 deletions R/estimate_truncation.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Estimate Truncation of Observed Data
#'
#' @description \lifecycle{experimental}
#' @description `r lifecycle::badge("experimental")`
#' Estimates a truncation distribution from multiple snapshots of the same
#' data source over time. This distribution can then be used in `regional_epinow`,
#' `epinow`, and `estimate_infections` to adjust for truncated data. See [here](https://gist.github.com/seabbs/176b0c7f83eab1a7192a25b28bbd116a)
Expand Down Expand Up @@ -198,8 +198,8 @@ estimate_truncation <- function(obs, max_truncation = 10,

#' Plot method for estimate_truncation
#'
#' @description \lifecycle{experimental}
#' \code{plot} method for class "estimate_truncation". Returns
#' @description `r lifecycle::badge("experimental")`
#' `plot` method for class "estimate_truncation". Returns
#' a plot faceted over each dataset used in fitting with the latest
#' observations as columns, the data observed at the time (and so truncated)
#' as dots and the truncation adjusted estimates as a ribbon.
Expand Down
4 changes: 2 additions & 2 deletions R/extract.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Extract Samples for a Parameter from a Stan model
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Extracts a single from a list of `stan` output and returns it as a `data.table`.
#' @param param Character string indicating the parameter to extract
#' @param samples Extracted stan model (using `rstan::extract`)
Expand Down Expand Up @@ -41,7 +41,7 @@ extract_static_parameter <- function(param, samples) {

#' Extract Parameter Samples from a Stan Model
#'
#' @description \lifecycle{stable}
#' @description `r lifecycle::badge("stable")`
#' Extracts a custom set of parameters from a stan object and adds stratification and
#' dates where appropriate.
#' @param stan_fit A fit Stan model as returned by `rstan:sampling`
Expand Down
2 changes: 1 addition & 1 deletion R/forecast_infections.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Forecast Infections and the Time-Varying Reproduction Number
#'
#' @description \lifecycle{experimental}
#' @description `r lifecycle::badge("experimental")`
#' Provides optional tools for forecasting cases and Rt estimates using the timeseries methods
#' (via the `EpiSoon` package). It requires the `Episoon` package. Installation instructions for the EpiSoon package are
#' available [here](https://epiforecasts.io/EpiSoon/).
Expand Down
Loading

0 comments on commit 22920d7

Please sign in to comment.