ard_categorical_ci: ARD Proportion Confidence Intervals

View source: R/ard_categorical_ci.R

ard_categorical_ciR Documentation

ARD Proportion Confidence Intervals

Description

Calculate confidence intervals for proportions.

Usage

ard_categorical_ci(data, ...)

## S3 method for class 'data.frame'
ard_categorical_ci(
  data,
  variables,
  by = dplyr::group_vars(data),
  method = c("waldcc", "wald", "clopper-pearson", "wilson", "wilsoncc", "strat_wilson",
    "strat_wilsoncc", "agresti-coull", "jeffreys"),
  denominator = c("column", "row", "cell"),
  conf.level = 0.95,
  value = list(where(is_binary) ~ 1L, where(is.logical) ~ TRUE),
  strata = NULL,
  weights = NULL,
  max.iterations = 10,
  ...
)

Arguments

data

(data.frame)
a data frame

...

Arguments passed to methods.

variables

(tidy-select)
columns to include in summaries. Columns must be class ⁠<logical>⁠ or ⁠<numeric>⁠ values coded as c(0,1).

by

(tidy-select)
columns to stratify calculations by.

method

(string)
string indicating the type of confidence interval to calculate. Must be one of . See ?proportion_ci for details.

denominator

(string)
Must be one of 'column' (default), 'row', and 'cell', which specifies the direction of the calculation/denominator. Argument is similar to cards::ard_categorical(denominator).

conf.level

(scalar numeric)
a scalar in ⁠(0,1)⁠ indicating the confidence level. Default is 0.95

value

(formula-list-selector)
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.

strata, weights, max.iterations

arguments passed to proportion_ci_strat_wilson(), when method='strat_wilson'

Value

an ARD data frame

Examples


# compute CI for binary variables
ard_categorical_ci(mtcars, variables = c(vs, am), method = "wilson")

# compute CIs for each level of a categorical variable
ard_categorical_ci(mtcars, variables = cyl, method = "jeffreys")


cardx documentation built on April 12, 2025, 9:10 a.m.