Skip to content

Commit

Permalink
DOC: Update roxygen comments and examples
Browse files Browse the repository at this point in the history
Separated existing functions with new method, method exports, and better
inheritance of params etc. #28
  • Loading branch information
fredjaya committed Jul 9, 2024
1 parent b367ee6 commit 39d7c61
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 121 deletions.
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ S3method(as.character,pool_strat)
S3method(design_effect,fixed_design)
S3method(design_effect,variable_design)
S3method(format,pool_strat)
S3method(optimise_prevalence,fixed_sN)
S3method(print,pool_strat)
S3method(print,power_size_results)
export(design_effect)
Expand All @@ -15,8 +16,8 @@ export(fi_pool_cluster_random)
export(fi_pool_random)
export(fixed_design)
export(nb_catch)
export(optimise_prevalence)
export(optimise_random_prevalence)
export(optimise_sN_prevalence)
export(optimise_s_prevalence)
export(pois_catch)
export(pool_max_size)
Expand Down
36 changes: 29 additions & 7 deletions R/optimise_prevalence.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#' numeric value greater than or equal to 0. For `optimise_s_prevalence()`,
#' this can be ignored if correlation is NA.
#' @param max_s numeric The maximum number of units per pool (pool size).
#' @param max_N numeric The maximum number of pools per cluster (pool number).
#' @param max_period numeric The maximum number of collection periods (per
#' cluster if `correlation` is not `NA`)
#' @param form string The distribution used to model the cluster-level
Expand All @@ -78,16 +77,16 @@
#' sampling periods; the unit cost of Fisher information; the mean, variance,
#' and distribution of the number of units caught across all sampling
#' periods(per cluster where applicable); and the optimal pooling strategy.
#' @rdname optimise_prevalence
#' @export
#'
#' @examples
#' optimise_s_prevalence(prevalence = 0.01, cost_unit = 5, cost_pool = 10)
#'
#' optimise_sN_prevalence(
#'
#' optimise_prevalence(
#' fixed_design(),
#' prevalence = 0.01, cost_unit = 5, cost_pool = 10,
#' cost_cluster = 100, correlation = 0.05
#' )
#' cost_cluster = 100, correlation = 0.05, form = "beta"
#' )
optimise_s_prevalence <- function(pool_number = 1,
prevalence,
cost_unit,
Expand Down Expand Up @@ -222,7 +221,30 @@ optimise_s_prevalence <- function(pool_number = 1,
out
}

#' Optimise prevalence
#'
#' Placeholder documentation to track params for the refactor.
#'
#' @inheritParams design_effect
#' @param cost_unit numeric The cost to process a single unit. Must be a numeric
#' value greater than or equal to 0.
#' @param cost_pool numeric The cost to process a single pool. Must be a numeric
#' value greater than or equal to 0.
#' @param cost_cluster numeric/NA The cost to process a cluster. Must be a
#' numeric value greater than or equal to 0. For `optimise_s_prevalence()`,
#' this can be ignored if correlation is NA.
#' @param max_s numeric The maximum number of units per pool (pool size).
#' @param ... Additional arguments passed to methods.
#' @export
optimise_prevalence <- function(x, ...) {
UseMethod("optimise_prevalence")
}

#' @rdname optimise_prevalence
#'
#' @inheritParams optimise_prevalence
#' @param max_N numeric The maximum number of pools per cluster (pool number).
#' @method optimise_prevalence fixed_sN
#' @export
optimise_prevalence.fixed_sN <- function(x,
prevalence,
Expand Down Expand Up @@ -296,7 +318,7 @@ optimise_prevalence.fixed_sN <- function(x,
)
}

#' @rdname optimise_prevalence
#' @rdname optimise_s_prevalence
#' @export
optimise_random_prevalence <- function(catch_mean, catch_variance,
pool_strat_family,
Expand Down
128 changes: 15 additions & 113 deletions man/optimise_prevalence.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

143 changes: 143 additions & 0 deletions man/optimise_s_prevalence.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 39d7c61

Please sign in to comment.