From 08551cc76b7e6fe1a12765b41fcd8f7fe18c75ea Mon Sep 17 00:00:00 2001 From: Adam Howes Date: Sun, 23 Jun 2024 16:17:02 +0100 Subject: [PATCH] Issue #126: Import stats functions (#128) * Add importing stats functions * Fix lint --- DESCRIPTION | 3 ++- NAMESPACE | 8 ++++++++ R/fitting-and-postprocessing.R | 1 + R/latent_individual.R | 1 + R/plot-helpers.R | 1 + R/preprocess.R | 1 + R/simulate.R | 4 ++++ 7 files changed, 18 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index e436288ea..be76232d8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,7 +31,8 @@ Imports: posterior, purrr, ggridges, - here + here, + stats Suggests: bookdown, epinowcast, diff --git a/NAMESPACE b/NAMESPACE index 6e16137af..9f0551e7c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -60,3 +60,11 @@ import(cmdstanr) import(data.table) import(ggplot2) importFrom(posterior,as_draws_df) +importFrom(stats,as.formula) +importFrom(stats,ecdf) +importFrom(stats,integrate) +importFrom(stats,median) +importFrom(stats,quantile) +importFrom(stats,rexp) +importFrom(stats,runif) +importFrom(stats,t.test) diff --git a/R/fitting-and-postprocessing.R b/R/fitting-and-postprocessing.R index 47dda7dae..d43931105 100644 --- a/R/fitting-and-postprocessing.R +++ b/R/fitting-and-postprocessing.R @@ -276,6 +276,7 @@ make_relative_to_truth <- function(draws, secondary_dist, by = "parameter") { #' @param not_by ... #' @param by A vector of columns to group by #' @family postprocess +#' @importFrom stats median quantile #' @export summarise_draws <- function(draws, sf, not_by = "value", by) { if (missing(by)) { diff --git a/R/latent_individual.R b/R/latent_individual.R index a20174f1b..f7cf5d9f1 100644 --- a/R/latent_individual.R +++ b/R/latent_individual.R @@ -32,6 +32,7 @@ epidist_prepare.epidist_latent_individual <- function(data, ...) { #' @param ... ... #' @method epidist_formula epidist_latent_individual #' @family latent_individual +#' @importFrom stats as.formula #' @export epidist_formula.epidist_latent_individual <- function(data, delay_central = ~ 1, sigma = ~ 1, ...) { diff --git a/R/plot-helpers.R b/R/plot-helpers.R index 164eccc26..41cc17bc1 100644 --- a/R/plot-helpers.R +++ b/R/plot-helpers.R @@ -33,6 +33,7 @@ calculate_cohort_mean <- function(data, type = c("cohort", "cumulative"), #' @param ptime ... #' @param distribution ... #' @family plot +#' @importFrom stats integrate #' @export calculate_truncated_means <- function(draws, obs_at, ptime, distribution = function(x, y, z) { diff --git a/R/preprocess.R b/R/preprocess.R index 93b43fb35..4c92fe91a 100644 --- a/R/preprocess.R +++ b/R/preprocess.R @@ -138,6 +138,7 @@ combine_obs <- function(truncated_obs, obs) { #' @param additional_by ... #' @family preprocess #' @autoglobal +#' @importFrom stats t.test #' @export calculate_censor_delay <- function(truncated_obs, additional_by = c()) { truncated_obs_psumm <- data.table::copy(truncated_obs) diff --git a/R/simulate.R b/R/simulate.R index 8e9f9bdea..500ca0d5e 100644 --- a/R/simulate.R +++ b/R/simulate.R @@ -11,6 +11,7 @@ #' (primary event time). #' #' @family simulate +#' @importFrom stats runif #' @export simulate_uniform_cases <- function(sample_size = 1000, t = 60) { data.table::data.table( @@ -34,6 +35,7 @@ simulate_uniform_cases <- function(sample_size = 1000, t = 60) { #' (primary event time). #' #' @family simulate +#' @importFrom stats runif #' @export simulate_exponential_cases <- function(r = 0.2, sample_size = 10000, @@ -74,6 +76,7 @@ simulate_exponential_cases <- function(r = 0.2, #' (primary event time). #' #' @family simulate +#' @importFrom stats rexp #' @export simulate_gillespie <- function(r = 0.2, gamma = 1 / 7, @@ -166,6 +169,7 @@ simulate_secondary <- function(linelist, dist = rlnorm, ...) { #' delays. #' #' @family simulate +#' @importFrom stats runif ecdf #' @export simulate_double_censored_pmf <- function( alpha, beta, max, n = 1000,