From 9a50ea916903035b02d5ab60d389a658d25725da Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Wed, 29 May 2024 11:06:41 -0700 Subject: [PATCH] Updating `ard_proportion_ci()` to accept categorical variables (#158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **What changes are proposed in this pull request?** * The `ard_proportion_ci(value)` argument has been added. Previously, only binary variables (0/1 or TRUE/FALSE) could be summarized. Now, binary variables will have the value specified in `value` summarized. For non-binary, categorical variables, each level is summarized. ``` r cardx::ard_proportion_ci( mtcars, variables = cyl ) |> dplyr::filter(stat_name %in% c("N", "estimate", "conf.low", "conf.high")) #> {cards} data frame: 12 x 9 #> variable variable_level context stat_name stat_label stat #> 1 cyl 4 proporti… N N 32 #> 2 cyl 4 proporti… estimate estimate 0.344 #> 3 cyl 4 proporti… conf.low conf.low 0.164 #> 4 cyl 4 proporti… conf.high conf.high 0.524 #> 5 cyl 6 proporti… N N 32 #> 6 cyl 6 proporti… estimate estimate 0.219 #> 7 cyl 6 proporti… conf.low conf.low 0.06 #> 8 cyl 6 proporti… conf.high conf.high 0.378 #> 9 cyl 8 proporti… N N 32 #> 10 cyl 8 proporti… estimate estimate 0.438 #> 11 cyl 8 proporti… conf.low conf.low 0.25 #> 12 cyl 8 proporti… conf.high conf.high 0.625 #> ℹ 3 more variables: fmt_fn, warning, error ``` Created on 2024-05-25 with [reprex v2.1.0](https://reprex.tidyverse.org) closes #154 -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [x] **All** GitHub Action workflows pass with a :white_check_mark: - [x] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [x] If a bug was fixed, a unit test was added. - [x] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [x] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [x] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [x] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --------- Signed-off-by: Daniel Sjoberg Co-authored-by: Zelos Zhu --- DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 2 + R/ard_proportion_ci.R | 91 ++++++++++++++++++++-- R/proportion_ci.R | 7 ++ man/ard_proportion_ci.Rd | 29 ++++--- man/figures/lifecycle-archived.svg | 21 +++++ man/figures/lifecycle-defunct.svg | 21 +++++ man/figures/lifecycle-deprecated.svg | 21 +++++ man/figures/lifecycle-experimental.svg | 21 +++++ man/figures/lifecycle-maturing.svg | 21 +++++ man/figures/lifecycle-questioning.svg | 21 +++++ man/figures/lifecycle-soft-deprecated.svg | 21 +++++ man/figures/lifecycle-stable.svg | 29 +++++++ man/figures/lifecycle-superseded.svg | 21 +++++ man/proportion_ci.Rd | 5 ++ tests/testthat/_snaps/ard_proportion_ci.md | 47 ++++++----- tests/testthat/test-ard_proportion_ci.R | 62 +++++++++++++-- 18 files changed, 404 insertions(+), 39 deletions(-) create mode 100644 man/figures/lifecycle-archived.svg create mode 100644 man/figures/lifecycle-defunct.svg create mode 100644 man/figures/lifecycle-deprecated.svg create mode 100644 man/figures/lifecycle-experimental.svg create mode 100644 man/figures/lifecycle-maturing.svg create mode 100644 man/figures/lifecycle-questioning.svg create mode 100644 man/figures/lifecycle-soft-deprecated.svg create mode 100644 man/figures/lifecycle-stable.svg create mode 100644 man/figures/lifecycle-superseded.svg diff --git a/DESCRIPTION b/DESCRIPTION index 543d223bb..73800a0e6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,7 @@ BugReports: https://github.com/insightsengineering/cardx/issues Depends: R (>= 4.1) Imports: - cards (>= 0.1.0.9026), + cards (>= 0.1.0.9032), cli (>= 3.6.1), dplyr (>= 1.1.2), glue (>= 1.6.2), diff --git a/NAMESPACE b/NAMESPACE index 83c0a01ca..ca9bbf793 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -55,6 +55,7 @@ export(construct_model) export(contains) export(ends_with) export(everything) +export(is_binary) export(last_col) export(matches) export(num_range) diff --git a/NEWS.md b/NEWS.md index 913d16e54..9eb70e7bb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,8 @@ ard_moodtest() -> ard_stats_mood_test() ### New Features +* The `ard_proportion_ci(value)` argument has been added. Previously, only binary variables (0/1 or TRUE/FALSE) could be summarized. When a value is not supplied, each level of the variable is summarized independently. By default, binary variables will have the 1/TRUE level summarized. + * Added the following functions for calculating Analysis Results Data (ARD). - `ard_stats_aov()` for calculating ANOVA results using `stats::aov()`. (#3) - `ard_stats_anova()` for calculating ANOVA results using `stats::anova()`. (#12) diff --git a/R/ard_proportion_ci.R b/R/ard_proportion_ci.R index dad57e5ee..10ae04b0f 100644 --- a/R/ard_proportion_ci.R +++ b/R/ard_proportion_ci.R @@ -18,23 +18,35 @@ #' See `?proportion_ci` for details. #' @param strata,weights,max.iterations arguments passed to `proportion_ci_strat_wilson()`, #' when `method='strat_wilson'` +#' @param value ([`formula-list-selector`][syntax])\cr +#' function will calculate the CIs for all levels of the variables specified. +#' Use this argument to instead request only a single level by summarized. +#' Default is `list(where(is_binary) ~ 1L, where(is.logical) ~ TRUE)`, where +#' columns coded as `0`/`1` and `TRUE`/`FALSE` will summarize the `1` and `TRUE` levels. #' #' @return an ARD data frame #' @export #' #' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx")) +#' # compute CI for binary variables #' ard_proportion_ci(mtcars, variables = c(vs, am), method = "wilson") -ard_proportion_ci <- function(data, variables, by = dplyr::group_vars(data), - conf.level = 0.95, - strata, - weights = NULL, - max.iterations = 10, +#' +#' # compute CIs for each level of a categorical variable +#' ard_proportion_ci(mtcars, variables = cyl, method = "jeffreys") +ard_proportion_ci <- function(data, + variables, + by = dplyr::group_vars(data), method = c( "waldcc", "wald", "clopper-pearson", "wilson", "wilsoncc", "strat_wilson", "strat_wilsoncc", "agresti-coull", "jeffreys" - )) { + ), + conf.level = 0.95, + value = list(where(is_binary) ~ 1L, where(is.logical) ~ TRUE), + strata = NULL, + weights = NULL, + max.iterations = 10) { set_cli_abort_call() # check installed packages --------------------------------------------------- @@ -47,8 +59,43 @@ ard_proportion_ci <- function(data, variables, by = dplyr::group_vars(data), cards::process_selectors(data, strata = strata) check_scalar(strata) } + cards::process_formula_selectors( + data[variables], + value = value + ) # calculate confidence intervals --------------------------------------------- + map( + variables, + function(variable) { + levels <- .unique_values_sort(data, variable = variable, value = value[[variable]]) + + .calculate_ard_proportion( + data = .as_dummy(data, variable = variable, levels = levels, by = by, strata = strata), + variables = c(everything(), -all_of(c(by, strata))), + by = all_of(by), + method = method, + conf.level = conf.level, + strata = strata, + weights = weights, + max.iterations = max.iterations + ) %>% + # merge in the variable levels + dplyr::left_join( + dplyr::select(., "variable") |> + dplyr::distinct() |> + dplyr::mutate(variable_level = as.list(.env$levels)), + by = "variable" + ) |> + # rename variable column + dplyr::mutate(variable = .env$variable) |> + dplyr::relocate("variable_level", .after = "variable") + } + ) |> + dplyr::bind_rows() +} + +.calculate_ard_proportion <- function(data, variables, by, method, conf.level, strata, weights, max.iterations) { cards::ard_complex( data = data, variables = {{ variables }}, @@ -85,3 +132,35 @@ ard_proportion_ci <- function(data, variables, by = dplyr::group_vars(data), context = "proportion_ci" ) } + +.unique_values_sort <- function(data, variable, value = NULL) { + unique_levels <- + # styler: off + if (is.logical(data[[variable]])) c(TRUE, FALSE) + else if (is.factor(data[[variable]])) factor(levels(data[[variable]]), levels = levels(data[[variable]])) + else unique(data[[variable]]) |> sort() + # styler: on + + if (!is_empty(value) && !value %in% unique_levels) { + cli::cli_warn( + c("A value of {.code value={.val {value}}} for variable {.val {variable}} + was passed, but is not one of the observed levels: {.val {unique_levels}}.", + i = "This may be an error.", + i = "If value is a valid, convert variable to factor with all levels specified to avoid this message." + ) + ) + } + if (!is_empty(value)) { + unique_levels <- value + } + + unique_levels +} + +.as_dummy <- function(data, variable, levels, by, strata) { + # define dummy variables and return tibble + map(levels, ~ data[[variable]] == .x) |> + set_names(paste0("this_is_not_a_column_name_anyone_would_choose_", variable, "_", levels, "...")) %>% + {dplyr::tibble(!!!.)} |> # styler: off + dplyr::bind_cols(data[c(by, strata)]) +} diff --git a/R/proportion_ci.R b/R/proportion_ci.R index 34aef53d2..cce2b9a4f 100644 --- a/R/proportion_ci.R +++ b/R/proportion_ci.R @@ -362,6 +362,13 @@ proportion_ci_strat_wilson <- function(x, compact() } +#' @describeIn proportion_ci Helper to determine if vector is binary (logical or 0/1) +#' +#' @export +is_binary <- function(x) { + is.logical(x) || (is_integerish(x) && is_empty(setdiff(x, c(0, 1, NA)))) +} + #' Helper Function for the Estimation of Stratified Quantiles #' #' This function wraps the estimation of stratified percentiles when we assume diff --git a/man/ard_proportion_ci.Rd b/man/ard_proportion_ci.Rd index 50349110b..00c885344 100644 --- a/man/ard_proportion_ci.Rd +++ b/man/ard_proportion_ci.Rd @@ -8,12 +8,13 @@ ard_proportion_ci( data, variables, by = dplyr::group_vars(data), + method = c("waldcc", "wald", "clopper-pearson", "wilson", "wilsoncc", "strat_wilson", + "strat_wilsoncc", "agresti-coull", "jeffreys"), conf.level = 0.95, - strata, + value = list(where(is_binary) ~ 1L, where(is.logical) ~ TRUE), + strata = NULL, weights = NULL, - max.iterations = 10, - method = c("waldcc", "wald", "clopper-pearson", "wilson", "wilsoncc", "strat_wilson", - "strat_wilsoncc", "agresti-coull", "jeffreys") + max.iterations = 10 ) } \arguments{ @@ -27,17 +28,23 @@ or \verb{} values coded as \code{c(0, 1)}.} \item{by}{(\code{\link[dplyr:dplyr_tidy_select]{tidy-select}})\cr columns to stratify calculations by} +\item{method}{(\code{string})\cr +string indicating the type of confidence interval to calculate. +Must be one of 'waldcc', 'wald', 'clopper-pearson', 'wilson', 'wilsoncc', 'strat_wilson', 'strat_wilsoncc', 'agresti-coull', 'jeffreys'. +See \code{?proportion_ci} for details.} + \item{conf.level}{(\code{numeric})\cr a scalar in \verb{(0, 1)} indicating the confidence level. Default is \code{0.95}} +\item{value}{(\code{\link[=syntax]{formula-list-selector}})\cr +function will calculate the CIs for all levels of the variables specified. +Use this argument to instead request only a single level by summarized. +Default is \code{list(where(is_binary) ~ 1L, where(is.logical) ~ TRUE)}, where +columns coded as \code{0}/\code{1} and \code{TRUE}/\code{FALSE} will summarize the \code{1} and \code{TRUE} levels.} + \item{strata, weights, max.iterations}{arguments passed to \code{proportion_ci_strat_wilson()}, when \code{method='strat_wilson'}} - -\item{method}{(\code{string})\cr -string indicating the type of confidence interval to calculate. -Must be one of 'waldcc', 'wald', 'clopper-pearson', 'wilson', 'wilsoncc', 'strat_wilson', 'strat_wilsoncc', 'agresti-coull', 'jeffreys'. -See \code{?proportion_ci} for details.} } \value{ an ARD data frame @@ -48,6 +55,10 @@ Calculate confidence intervals for proportions. } \examples{ \dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +# compute CI for binary variables ard_proportion_ci(mtcars, variables = c(vs, am), method = "wilson") + +# compute CIs for each level of a categorical variable +ard_proportion_ci(mtcars, variables = cyl, method = "jeffreys") \dontshow{\}) # examplesIf} } diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg new file mode 100644 index 000000000..745ab0c78 --- /dev/null +++ b/man/figures/lifecycle-archived.svg @@ -0,0 +1,21 @@ + + lifecycle: archived + + + + + + + + + + + + + + + lifecycle + + archived + + diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg new file mode 100644 index 000000000..d5c9559ed --- /dev/null +++ b/man/figures/lifecycle-defunct.svg @@ -0,0 +1,21 @@ + + lifecycle: defunct + + + + + + + + + + + + + + + lifecycle + + defunct + + diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg new file mode 100644 index 000000000..b61c57c3f --- /dev/null +++ b/man/figures/lifecycle-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: deprecated + + + + + + + + + + + + + + + lifecycle + + deprecated + + diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg new file mode 100644 index 000000000..5d88fc2c6 --- /dev/null +++ b/man/figures/lifecycle-experimental.svg @@ -0,0 +1,21 @@ + + lifecycle: experimental + + + + + + + + + + + + + + + lifecycle + + experimental + + diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg new file mode 100644 index 000000000..897370ecf --- /dev/null +++ b/man/figures/lifecycle-maturing.svg @@ -0,0 +1,21 @@ + + lifecycle: maturing + + + + + + + + + + + + + + + lifecycle + + maturing + + diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg new file mode 100644 index 000000000..7c1721d05 --- /dev/null +++ b/man/figures/lifecycle-questioning.svg @@ -0,0 +1,21 @@ + + lifecycle: questioning + + + + + + + + + + + + + + + lifecycle + + questioning + + diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg new file mode 100644 index 000000000..9c166ff30 --- /dev/null +++ b/man/figures/lifecycle-soft-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: soft-deprecated + + + + + + + + + + + + + + + lifecycle + + soft-deprecated + + diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg new file mode 100644 index 000000000..9bf21e76b --- /dev/null +++ b/man/figures/lifecycle-stable.svg @@ -0,0 +1,29 @@ + + lifecycle: stable + + + + + + + + + + + + + + + + lifecycle + + + + stable + + + diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg new file mode 100644 index 000000000..db8d757f7 --- /dev/null +++ b/man/figures/lifecycle-superseded.svg @@ -0,0 +1,21 @@ + + lifecycle: superseded + + + + + + + + + + + + + + + lifecycle + + superseded + + diff --git a/man/proportion_ci.Rd b/man/proportion_ci.Rd index 8094fc047..f2a5d9039 100644 --- a/man/proportion_ci.Rd +++ b/man/proportion_ci.Rd @@ -8,6 +8,7 @@ \alias{proportion_ci_agresti_coull} \alias{proportion_ci_jeffreys} \alias{proportion_ci_strat_wilson} +\alias{is_binary} \title{Functions for Calculating Proportion Confidence Intervals} \usage{ proportion_ci_wald(x, conf.level = 0.95, correct = FALSE) @@ -28,6 +29,8 @@ proportion_ci_strat_wilson( max.iterations = 10L, correct = FALSE ) + +is_binary(x) } \arguments{ \item{x}{vector of a binary values, i.e. a logical vector, or numeric with values \code{c(0, 1)}} @@ -99,6 +102,8 @@ for multiple binomial proportions. \emph{Statistics in Biopharmaceutical Researc z_{\alpha/2} \sqrt{\frac{\hat{p}_j(1 - \hat{p}_j)}{n_j} + \frac{z^2_{\alpha/2}}{4n_j^2}}}{1 + \frac{z^2_{\alpha/2}}{n_j}}} +\item \code{is_binary()}: Helper to determine if vector is binary (logical or 0/1) + }} \examples{ \dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} diff --git a/tests/testthat/_snaps/ard_proportion_ci.md b/tests/testthat/_snaps/ard_proportion_ci.md index d7388ed0f..94a7c043f 100644 --- a/tests/testthat/_snaps/ard_proportion_ci.md +++ b/tests/testthat/_snaps/ard_proportion_ci.md @@ -3,32 +3,43 @@ Code ard_proportion_ci_strat_wilson Message - {cards} data frame: 6 x 8 + {cards} data frame: 6 x 9 Output - variable context stat_name stat_label stat fmt_fn - 1 rsp proporti… N N 80 0 - 2 rsp proporti… estimate estimate 0.625 1 - 3 rsp proporti… conf.low conf.low 0.487 1 - 4 rsp proporti… conf.high conf.high 0.719 1 - 5 rsp proporti… conf.level conf.lev… 0.95 1 - 6 rsp proporti… method method Stratifi… + variable variable_level context stat_name stat_label stat + 1 rsp TRUE proporti… N N 80 + 2 rsp TRUE proporti… estimate estimate 0.625 + 3 rsp TRUE proporti… conf.low conf.low 0.487 + 4 rsp TRUE proporti… conf.high conf.high 0.719 + 5 rsp TRUE proporti… conf.level conf.lev… 0.95 + 6 rsp TRUE proporti… method method Stratifi… Message - i 2 more variables: warning, error + i 3 more variables: fmt_fn, warning, error --- Code ard_proportion_ci_strat_wilsoncc Message - {cards} data frame: 6 x 8 + {cards} data frame: 6 x 9 Output - variable context stat_name stat_label stat fmt_fn - 1 rsp proporti… N N 80 0 - 2 rsp proporti… estimate estimate 0.625 1 - 3 rsp proporti… conf.low conf.low 0.448 1 - 4 rsp proporti… conf.high conf.high 0.753 1 - 5 rsp proporti… conf.level conf.lev… 0.95 1 - 6 rsp proporti… method method Stratifi… + variable variable_level context stat_name stat_label stat + 1 rsp TRUE proporti… N N 80 + 2 rsp TRUE proporti… estimate estimate 0.625 + 3 rsp TRUE proporti… conf.low conf.low 0.448 + 4 rsp TRUE proporti… conf.high conf.high 0.753 + 5 rsp TRUE proporti… conf.level conf.lev… 0.95 + 6 rsp TRUE proporti… method method Stratifi… Message - i 2 more variables: warning, error + i 3 more variables: fmt_fn, warning, error + +# ard_proportion_ci() messaging + + Code + ard <- ard_proportion_ci(data = mtcars, variables = cyl, value = cyl ~ 10, + method = "jeffreys") + Condition + Warning: + A value of `value=10` for variable "cyl" was passed, but is not one of the observed levels: 4, 6, and 8. + i This may be an error. + i If value is a valid, convert variable to factor with all levels specified to avoid this message. diff --git a/tests/testthat/test-ard_proportion_ci.R b/tests/testthat/test-ard_proportion_ci.R index 6f7ceb9b7..03e9bcc87 100644 --- a/tests/testthat/test-ard_proportion_ci.R +++ b/tests/testthat/test-ard_proportion_ci.R @@ -1,12 +1,13 @@ skip_if_not(do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) test_that("ard_proportion_ci() works", { - # testing the easy methods together + # testing the easy methods together for binary variables expect_error( - c( - "waldcc", "wald", "clopper-pearson", - "wilson", "wilsoncc", "agresti-coull", "jeffreys" - ) |> + lst_ard_props <- + c( + "waldcc", "wald", "clopper-pearson", + "wilson", "wilsoncc", "agresti-coull", "jeffreys" + ) |> lapply( \(x) { ard_proportion_ci( @@ -18,6 +19,44 @@ test_that("ard_proportion_ci() works", { ), NA ) + expect_equal( + lst_ard_props[[1]] |> + cards::get_ard_statistics( + stat_name %in% c("estimate", "conf.low", "conf.high"), + variable == "am" + ), + proportion_ci_wald(mtcars$am, correct = TRUE)[c("estimate", "conf.low", "conf.high")] + ) + + # testing a categorical variable + expect_error( + ard_factor <- + ard_proportion_ci( + mtcars |> dplyr::mutate(cyl = factor(cyl, levels = c(4, 6, 8, 10))), + variables = cyl, + by = am + ), + NA + ) + expect_equal( + cards::get_ard_statistics( + ard_factor, + group1_level %in% 0, + map_lgl(variable_level, ~ .x == "4") + )[c("estimate", "conf.low", "conf.high")], + proportion_ci_wald(mtcars$cyl[mtcars$am == 0] == 4, correct = TRUE)[c("estimate", "conf.low", "conf.high")] + ) + # now checking the unobserved level of cyl + expect_equal( + cards::get_ard_statistics( + ard_factor, + group1_level %in% 0, + unlist(variable_level) == "10" + )[c("estimate", "conf.low", "conf.high")], + proportion_ci_wald(mtcars$cyl[mtcars$am == 0] == 10, correct = TRUE)[c("estimate", "conf.low", "conf.high")] + ) + # checking structure + expect_silent(cards::check_ard_structure(ard_factor)) }) test_that("ard_proportion_ci(method='strat_wilson') works", { @@ -45,6 +84,7 @@ test_that("ard_proportion_ci(method='strat_wilson') works", { variables = rsp, strata = strata, weights = weights, + max.iterations = 10, method = "strat_wilson" ), NA @@ -61,9 +101,21 @@ test_that("ard_proportion_ci(method='strat_wilson') works", { variables = rsp, strata = strata, weights = weights, + max.iterations = 10, method = "strat_wilsoncc" ), NA ) expect_snapshot(ard_proportion_ci_strat_wilsoncc) }) + +test_that("ard_proportion_ci() messaging", { + expect_snapshot( + ard <- ard_proportion_ci( + data = mtcars, + variables = cyl, + value = cyl ~ 10, + method = "jeffreys" + ) + ) +})