rStats.js v1.3.0
    Preparing search index...

    Function binomDiffCI

    • Confidence interval for the difference p1 - p2 of two independent proportions x1/n1 and x2/n2. Equivalent to DescTools::BinomDiffCI() in R.

      Methods (method): "ac" (Agresti-Caffo, the default as in DescTools: the Wald interval with one success and one failure added to each group), "wald", "score" (Newcombe's hybrid score interval, his method 10), "mn" (Miettinen-Nurminen score interval) and "mee" (Farrington-Manning / Mee: the same without the factor N/(N - 1); epiR's score interval of the attributable risk). With sides: "left" or "right" only the lower or the upper limit is kept, at the one-sided level confLevel, and the other end is 1 or -1. The "mn" and "mee" limits are the roots of the score statistic to the precision of the doubles (DescTools stops at about 1e-7 and 1e-4).

      Parameters

      • x1: number

        Successes in group 1.

      • n1: number

        Trials in group 1.

      • x2: number

        Successes in group 2.

      • n2: number

        Trials in group 2.

      • options: BinomDiffCIOptions = {}

      Returns BinomDiffCIResult

      The estimate p1 - p2 and the interval; see BinomDiffCIResult.

      RangeError for counts that are not integers with 0 <= x <= n, n > 0, a level outside (0, 1) (at least 0.5 one-sided), or an unknown method or sides.

      binomDiffCI(56, 70, 48, 80).confInt; // [0.05245292663805373, 0.3357584554757674]
      binomDiffCI(56, 70, 48, 80, { method: "mn" }).confInt; // [0.05282971324584462, 0.33817294001586834]