MyNixOS website logo
Description

Calculate Confidence Intervals.

This calculates a variety of different CIs for proportions and difference of proportions that are commonly used in the pharmaceutical industry including Wald, Wilson, Clopper-Pearson, Agresti-Coull and Jeffreys for proprotions. And Miettinen-Nurminen (1985) <doi:10.1002/sim.4780040211>, Wald, Haldane, and Mee <https://www.lexjansen.com/wuss/2016/127_Final_Paper_PDF.pdf> for difference in proportions.

cicalc

R-CMD-check CRANstatus codecov

{cicalc} contains a number of confidence intervals commonly used in the pharma industry. For a full list of available methods see the package index

Installation

You can install the development version of cicalc from GitHub with:

# install.packages("devtools")
devtools::install_github("GSK-Biostatistics/cicalc")

Example

A subsection of common CI’s available in this package are below:

library(cicalc)
# Example of CI for proportions
x <- c(
  TRUE, TRUE, TRUE, TRUE, TRUE,
  FALSE, FALSE, FALSE, FALSE, FALSE
)
ci_prop_wald(x, conf.level = 0.9)
#> 
#> ── Wald Confidence Interval without Continuity Correction ──────────────────────
#> • 5 responses out of 10
#> • Estimate: 0.5
#> • 90% Confidence Interval:
#>   (0.2399, 0.7601)
ci_prop_wilson(x, correct = TRUE)
#> 
#> ── Wilson Confidence Interval with continuity correction ───────────────────────
#> • 5 responses out of 10
#> • Estimate: 0.5
#> • 95% Confidence Interval:
#>   (0.2366, 0.7634)
ci_prop_clopper_pearson(x)
#> 
#> ── Clopper-Pearson Confidence Interval ─────────────────────────────────────────
#> • 5 responses out of 10
#> • Estimate: 0.5
#> • 95% Confidence Interval:
#>   (0.1871, 0.8129)
ci_prop_agresti_coull(x)
#> 
#> ── Agresti-Coull Confidence Interval ───────────────────────────────────────────
#> • 5 responses out of 10
#> • Estimate: 0.5
#> • 95% Confidence Interval:
#>   (0.2366, 0.7634)
ci_prop_jeffreys(x)
#> 
#> ── Jeffreys Interval ───────────────────────────────────────────────────────────
#> • 5 responses out of 10
#> • Estimate: 0.5
#> • 95% Confidence Interval:
#>   (0.2235, 0.7765)
# Example of CI for difference of proportions 
# Generate binary samples
responses <- expand(c(9, 3), c(10, 10))
arm <- rep(c("treat", "control"), times = c(10, 10))

# Calculate 95% confidence interval for difference in proportions
ci_prop_diff_mn(x = responses, by = arm)
#> 
#> ── Miettinen-Nurminen Confidence Interval ──────────────────────────────────────
#> • 9/10 - 3/10
#> • Estimate: 0.6
#> • 95% Confidence Interval:
#>   (0.17, 0.8406)

# Stratified 
strat_df <- dplyr::tibble(
  responses = expand(c(9, 3, 7, 2), c(10, 10, 10, 10)),
  arm = rep(c("treat", "control"), 20),
  strata = rep(c("stratum1", "stratum2"), times = c(20, 20))
)

ci_prop_diff_mn_strata(x = responses, by = arm, strata = strata, data = strat_df)
#> 
#> ── Stratified Score Miettinen-Nurminen Confidence Interval ─────────────────────
#> • 12/20 - 9/20
#> • Weights: stratum1 = 5, stratum2 = 5
#> • Estimate: 0.15
#> • 95% Confidence Interval:
#>   (-0.1606, 0.4338)
Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows