Skip to content

Commit

Permalink
remove epiparameter from create_*() and .clean_*() function names
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Jul 17, 2024
1 parent 2b22263 commit 6d27c86
Show file tree
Hide file tree
Showing 30 changed files with 365 additions and 372 deletions.
14 changes: 7 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export(calc_disc_dist_quantile)
export(cdf)
export(convert_params_to_summary_stats)
export(convert_summary_stats_to_params)
export(create_epiparameter_citation)
export(create_epiparameter_metadata)
export(create_epiparameter_method_assess)
export(create_epiparameter_prob_dist)
export(create_epiparameter_region)
export(create_epiparameter_summary_stats)
export(create_epiparameter_uncertainty)
export(create_citation)
export(create_metadata)
export(create_method_assess)
export(create_prob_dist)
export(create_region)
export(create_summary_stats)
export(create_uncertainty)
export(discretise)
export(discretize)
export(epiparameter)
Expand Down
2 changes: 1 addition & 1 deletion R/accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ get_parameters.epiparameter <- function(x, ...) {
}

# convert to meanlog and sdlog names
params <- .clean_epiparameter_params(
params <- .clean_params(
prob_dist = family(x),
prob_dist_params = params
)
Expand Down
19 changes: 9 additions & 10 deletions R/coercion.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ epiparameter_df_to_epiparameter <- function(x, ...) {
} else {
uncertainty <- lapply(
prob_distribution_params,
function(x) create_epiparameter_uncertainty()
function(x) create_uncertainty()
)
}

Expand Down Expand Up @@ -268,7 +268,7 @@ epireview_to_epiparameter <- function(x, ...) { # nolint cyclocomp_linter
sd_ <- NULL
if (rlang::is_na(prob_dist)) {
prob_dist_params <- NA_real_
uncertainty <- create_epiparameter_uncertainty()
uncertainty <- create_uncertainty()
} else {
prob_dist <- switch(
prob_dist,
Expand Down Expand Up @@ -319,15 +319,15 @@ epireview_to_epiparameter <- function(x, ...) { # nolint cyclocomp_linter
prob_dist_params <- unlist(prob_dist_params)
uncertainty <- lapply(
prob_dist_params,
function(x) create_epiparameter_uncertainty()
function(x) create_uncertainty()
)
names(uncertainty) <- names(prob_dist_params)
}
# overwrite prob_dist with user specified if given
if (!is.null(prob_dist_in)) {
prob_dist <- prob_dist_in
# erase uncertainty, new prob_dist will likely have different param names
uncertainty <- create_epiparameter_uncertainty()
uncertainty <- create_uncertainty()
}
# vectorise switch (cannot use vapply due to various return FUN.VALUE)
param_type <- sapply( # nolint undesirable_function_linter
Expand Down Expand Up @@ -355,7 +355,7 @@ epireview_to_epiparameter <- function(x, ...) { # nolint cyclocomp_linter
)
param_type <- NULL
}
summary_stats <- create_epiparameter_summary_stats()
summary_stats <- create_summary_stats()
summary_stats[param_type] <- x$parameter_value
uncertainty_type <- .unique(
x$parameter_uncertainty_type,
Expand All @@ -377,7 +377,7 @@ epireview_to_epiparameter <- function(x, ...) { # nolint cyclocomp_linter
if (!is.null(sd_)) {
summary_stats$sd <- sd_
}
metadata <- create_epiparameter_metadata()
metadata <- create_metadata()
metadata$sample_size <- .unique(x$population_sample_size)
metadata$inference_method <- inference_method
location <- .unique(x$population_location)
Expand All @@ -391,7 +391,7 @@ epireview_to_epiparameter <- function(x, ...) { # nolint cyclocomp_linter
}
metadata$region <- region
if (is.null(article)) {
citation <- create_epiparameter_citation(
citation <- create_citation(
author = .unique(x$first_author_surname, var_name = "citation authors"),
year = .unique(x$year_publication, var_name = "citation years"),
title = "<title not available>",
Expand All @@ -409,7 +409,7 @@ epireview_to_epiparameter <- function(x, ...) { # nolint cyclocomp_linter
call. = FALSE
)
}
citation <- create_epiparameter_citation(
citation <- create_citation(
author = article$first_author_surname,
year = article$year_publication,
title = article$article_title,
Expand Down Expand Up @@ -454,8 +454,7 @@ epireview_to_epiparameter <- function(x, ...) { # nolint cyclocomp_linter
#' Input summary statistic uncertainty
#'
#' @param x A `<data.frame>` from \pkg{epireview}.
#' @param summary_stats A list returned from
#' [create_epiparameter_summary_stats()].
#' @param summary_stats A list returned from [create_summary_stats()].
#' @param summary_stat_type A `character` string with the name of the summary
#' statistic type (e.g., `"mean"`, `"median"`).
#'
Expand Down
10 changes: 5 additions & 5 deletions R/create_epidist_prob_dist.R → R/create_prob_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,38 @@
#'
#' @examples
#' # example with continuous distribution without truncation
#' create_epiparameter_prob_dist(
#' create_prob_dist(
#' prob_dist = "gamma",
#' prob_dist_params = c(shape = 1, scale = 1),
#' discretise = FALSE,
#' truncation = NA
#' )
#'
#' # example with continuous distribution with truncation
#' create_epiparameter_prob_dist(
#' create_prob_dist(
#' prob_dist = "gamma",
#' prob_dist_params = c(shape = 1, scale = 1),
#' discretise = FALSE,
#' truncation = 10
#' )
#'
#' # example with discrete distribution
#' create_epiparameter_prob_dist(
#' create_prob_dist(
#' prob_dist = "gamma",
#' prob_dist_params = c(shape = 1, scale = 1),
#' discretise = TRUE,
#' truncation = NA
#' )
#'
#' # example passing extra arguments to distcrete
#' create_epiparameter_prob_dist(
#' create_prob_dist(
#' prob_dist = "gamma",
#' prob_dist_params = c(shape = 1, scale = 1),
#' discretise = TRUE,
#' truncation = NA,
#' w = 0.5
#' )
create_epiparameter_prob_dist <- function(prob_dist,
create_prob_dist <- function(prob_dist,
prob_dist_params,
discretise = FALSE,
truncation = NA,
Expand Down
Loading

0 comments on commit 6d27c86

Please sign in to comment.