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

    Function binomCI

    • Confidence interval for a binomial proportion x/n. Equivalent to DescTools::BinomCI() in R.

      Methods (method): "wilson" (the default, Wilson's score interval), "wald", "wilsoncc" (with continuity correction), "agresti-coull", "jeffreys", "clopper-pearson" (the exact interval) and "midp" (the mid-p exact interval). With sides: "left" or "right" only the lower or the upper limit is kept, at the one-sided level confLevel (the two-sided interval at 1 - 2 (1 - confLevel)), and the other end is 0 or 1. Limits are clipped to [0, 1].

      The mid-p limits are the roots of their equations to the precision of the doubles; DescTools stops its search at an absolute 1.22e-4, which leaves its limits up to 1e-4 off and gives 0 for lower limits below that. Unlike DescTools, which returns NaN or numbers, x > n, a negative or non-integer count, n = 0 and a level outside (0, 1) are errors.

      Parameters

      Returns BinomCIResult

      The estimate x/n and the interval; see BinomCIResult.

      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.

      binomCI(37, 100).confInt; // [0.28182360534324535, 0.4677947041905709]
      binomCI(37, 100, { method: "clopper-pearson" }).confInt; // [0.27556657961455155, 0.4723516405516831]
      binomCI(1, 1000, { method: "midp", sides: "right" }).confInt; // [0, 0.004106205924199768]