Skip to contents

[Experimental]
Calculate confidence intervals for proportions.

Usage

ard_proportion_ci(
  data,
  variables,
  by = dplyr::group_vars(data),
  conf.level = 0.95,
  strata,
  weights = NULL,
  max.iterations = 10,
  method = c("waldcc", "wald", "clopper-pearson", "wilson", "wilsoncc", "strat_wilson",
    "strat_wilsoncc", "agresti-coull", "jeffreys")
)

Arguments

data

(data.frame)
a data frame

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

conf.level

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

strata, weights, max.iterations

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

method

(string)
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 ?proportion_ci for details.

Value

an ARD data frame

Examples

ard_proportion_ci(mtcars, variables = c(vs, am), method = "wilson")
#> {cards} data frame: 20 x 8
#>    variable   context   stat_name stat_label      stat fmt_fn
#> 1        vs proporti…           N          N        32      0
#> 2        vs proporti…  conf.level  conf.lev…      0.95      1
#> 3        vs proporti…    estimate   estimate     0.438      1
#> 4        vs proporti…   statistic  statistic       0.5      1
#> 5        vs proporti…     p.value    p.value      0.48      1
#> 6        vs proporti…   parameter  parameter         1      0
#> 7        vs proporti…    conf.low   conf.low     0.282      1
#> 8        vs proporti…   conf.high  conf.high     0.607      1
#> 9        vs proporti…      method     method Wilson C…   <fn>
#> 10       vs proporti… alternative  alternat… two.sided   <fn>
#> 11       am proporti…           N          N        32      0
#> 12       am proporti…  conf.level  conf.lev…      0.95      1
#> 13       am proporti…    estimate   estimate     0.406      1
#> 14       am proporti…   statistic  statistic     1.125      1
#> 15       am proporti…     p.value    p.value     0.289      1
#> 16       am proporti…   parameter  parameter         1      0
#> 17       am proporti…    conf.low   conf.low     0.255      1
#> 18       am proporti…   conf.high  conf.high     0.577      1
#> 19       am proporti…      method     method Wilson C…   <fn>
#> 20       am proporti… alternative  alternat… two.sided   <fn>
#>  2 more variables: warning, error