Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove <vb_epidist> class and methods #359

Merged
merged 6 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ S3method(as.data.frame,multi_epidist)
S3method(as.function,epidist)
S3method(as_epidist,data.frame)
S3method(cdf,epidist)
S3method(cdf,vb_epidist)
S3method(convert_params_to_summary_stats,character)
S3method(convert_params_to_summary_stats,epidist)
S3method(convert_summary_stats_to_params,character)
S3method(convert_summary_stats_to_params,epidist)
S3method(density,epidist)
S3method(density,vb_epidist)
S3method(discretise,default)
S3method(discretise,epidist)
S3method(family,epidist)
S3method(format,epidist)
S3method(format,vb_epidist)
S3method(generate,epidist)
S3method(generate,vb_epidist)
S3method(get_citation,epidist)
S3method(get_citation,multi_epidist)
S3method(get_parameters,epidist)
Expand All @@ -29,9 +25,7 @@ S3method(plot,epidist)
S3method(print,epidist)
S3method(print,multi_epidist)
S3method(print,parameter_tbl)
S3method(print,vb_epidist)
S3method(quantile,epidist)
S3method(quantile,vb_epidist)
S3method(tbl_sum,p_tbl)
export(as_epidist)
export(calc_disc_dist_quantile)
Expand Down Expand Up @@ -59,11 +53,8 @@ export(is_epidist_params)
export(is_parameterised)
export(is_parameterized)
export(is_truncated)
export(is_vb_epidist)
export(parameter_tbl)
export(validate_epidist)
export(validate_vb_epidist)
export(vb_epidist)
importFrom(distributional,cdf)
importFrom(distributional,generate)
importFrom(pillar,tbl_sum)
Expand Down
58 changes: 6 additions & 52 deletions R/epidist.R
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,6 @@ validate_epidist <- function(epidist) {
#' Print method for `<epidist>` class
#'
#' @param x An `<epidist>` object.
#' @param header Boolean `logical` determining whether the header (first part)
#' of the print method is printed. This is used internally for plotting the
#' `<vb_epidist>` class.
#' @param vb A `character` string containing whether it is the intrinsic
#' (`"Intrinsic"`) or extrinsic (`"Extrinsic"`) distribution for vector-borne
#' diseases.
#' @param ... [dots] Extra arguments to be passed to the method.
#'
#' @return Invisibly returns an `<epidist>`. Called for side-effects.
Expand All @@ -390,18 +384,13 @@ validate_epidist <- function(epidist) {
#' prob_distribution_params = c(shape = 1, scale = 1)
#' )
#' epidist
print.epidist <- function(x, header = TRUE, vb = NULL, ...) {
format(x, header = header, vb = vb, ...)
print.epidist <- function(x, ...) {
format(x, ...)
}

#' Format method for `<epidist>` class
#'
#' @inheritParams print.epidist
#' @param header Boolean logical determining whether the header (first part) of
#' the print method is printed. This is used internally for plotting the
#' vb_epidist class
#' @param vb Either NULL (default) or a character string of either "Intrinsic"
#' or "Extrinsic" which is used internally for plotting the vb_epidist class
#'
#' @return Invisibly returns an `<epidist>`. Called for printing side-effects.
#' @export
Expand All @@ -414,8 +403,7 @@ print.epidist <- function(x, header = TRUE, vb = NULL, ...) {
#' prob_distribution_params = c(shape = 1, scale = 1)
#' )
#' format(epidist)
format.epidist <- function(x, header = TRUE, vb = NULL, ...) {
if (header) {
format.epidist <- function(x, ...) {
writeLines(
c(
sprintf("Disease: %s", x$disease),
Expand All @@ -424,11 +412,6 @@ format.epidist <- function(x, header = TRUE, vb = NULL, ...) {
sprintf("Study: %s", format(x$citation))
)
)
}

if (!is.null(vb)) {
writeLines(sprintf(vb))
}

if (is.object(x$prob_dist) || is.character(x$prob_dist)) {
dist_string <- ifelse(
Expand Down Expand Up @@ -496,26 +479,23 @@ is_epidist <- function(x) {
inherits(x, "epidist")
}

#' PDF, CDF, PMF, quantiles and random number generation for `<epidist>` and
#' `<vb_epidist>` objects
#' PDF, CDF, PMF, quantiles and random number generation for `<epidist>` objects
#'
#' @description The `<epidist>` object holds a probability distribution which
#' can either be a continuous or discrete distribution. These are the density,
#' cumulative distribution, quantile and random number generation functions.
#' These operate on any distribution that can be included in an `<epidist>`
#' object.
#'
#' @param x An `<epidist>` or `<vb_epidist>` object.
#' @param x An `<epidist>` object.
#' @param at The quantiles to evaluate at.
#' @param q The quantiles to evaluate at.
#' @param p The probabilities to evaluate at.
#' @param times The number of random samples.
#' @inheritParams print.epidist
#' @inheritParams distributional::cdf
#'
#' @return If an `<epidist>` object is given a numeric vector is returned, if an
#' `<vb_epidist>` object is given a list of two elements each with a numeric
#' vector is returned.
#' @return `numeric` vector.
#'
#' @name epidist_distribution_functions
#' @keywords epidist_distribution_functions
Expand All @@ -533,32 +513,6 @@ is_epidist <- function(x) {
#' distributional::cdf(edist, q = 1)
#' stats::quantile(edist, p = 0.2)
#' distributional::generate(edist, times = 10)
#'
#' vb_edist <- vb_epidist(
#' intrinsic_epidist = epidist(
#' disease = "dengue",
#' epi_dist = "incubation_period",
#' prob_distribution = "gamma",
#' prob_distribution_params = c(shape = 1, scale = 1),
#' metadata = create_epidist_metadata(transmission_mode = "vector_borne")
#' ),
#' extrinsic_epidist = epidist(
#' disease = "dengue",
#' epi_dist = "incubation_period",
#' prob_distribution = "gamma",
#' prob_distribution_params = c(shape = 1, scale = 1),
#' metadata = create_epidist_metadata(
#' transmission_mode = "vector_borne",
#' extrinsic = TRUE
#' )
#' )
#' )
#'
#' # example of each distribution method for an `vb_epidist` object
#' stats::density(vb_edist, at = 1)
#' distributional::cdf(vb_edist, q = 1)
#' stats::quantile(vb_edist, p = 0.2)
#' distributional::generate(vb_edist, times = 10)
NULL

#' @rdname epidist_distribution_functions
Expand Down
Loading
Loading