Skip to contents

[Experimental]

Several confidence intervals for the difference between proportions.

Usage

h_recycle(...)

desctools_binom(
  x1,
  n1,
  x2,
  n2,
  conf.level = 0.95,
  sides = c("two.sided", "left", "right"),
  method = c("ac", "wald", "waldcc", "score", "scorecc", "mn", "mee", "blj", "ha", "hal",
    "jp")
)

desctools_binomci(
  x,
  n,
  conf.level = 0.95,
  sides = c("two.sided", "left", "right"),
  method = c("wilson", "wald", "waldcc", "agresti-coull", "jeffreys", "modified wilson",
    "wilsoncc", "modified jeffreys", "clopper-pearson", "arcsine", "logit", "witting",
    "pratt", "midp", "lik", "blaker"),
  rand = 123,
  tol = 1e-05
)

Arguments

conf.level


confidence level, defaults to 0.95

sides


a character string specifying the side of the confidence interval. Must be one of "two-sided" (default), "left" or "right".

method


character string specifying which method to use. Can be one out of: "wald", "wilson", "wilsoncc", "agresti-coull", "jeffreys", "modified wilson", "modified jeffreys", "clopper-pearson", "arcsine. ", "logit", "witting", "pratt", "midp", "lik" and "blaker"

@return A matric with 3 columns containing:

  • est: estimate of proportion difference.

  • lwrci: lower end of the confidence interval

  • upci: upper end of the confidence interval.

x


number of successes

n


number of trials

grp

(factor)
vector assigning observations to one out of two groups (e.g. reference and treatment group).

Value

A named list of 3 values:

  • est: estimate of proportion difference.

  • lwrci: estimate of lower end of the confidence interval

  • upci: estimate of upper end of the confidence interval.

Functions

  • h_recycle(): This function recycles all supplied elements to the maximal dimension.

  • desctools_binom(): Several Confidence Intervals for the difference between proportions.

  • desctools_binomci(): Compute confidence intervals for binomial proportions.

Examples

# Internal function -
if (FALSE) {

set.seed(2)
rsp <- sample(c(TRUE, FALSE), replace = TRUE, size = 20)
grp <- factor(c(rep("A", 10), rep("B", 10)))
tbl <- table(grp, factor(rsp, levels = c(TRUE, FALSE)))
desctools_binom(
  tbl[1], sum(tbl[1], tbl[3]), tbl[2], sum(tbl[2], tbl[4]),
  conf.level = 0.90, method = "waldcc"
)
}