Introduction to PropTestR

Vinodhkumar Obli Rajendran

Keerthi Aaradhana

Overview

PropTestR provides a common interface for independent two-proportion inference. The principal function is compare_2prop().

library(PropTestR)
r <- compare_2prop(82, 100, 75, 100, method=c("wald","score","fisher","miettinen_nurminen"))
print(r)
#> PropTestR: comparison of two independent proportions
#> Group 1: 82/100 (0.8200)
#> Group 2: 75/100 (0.7500)
#> Risk difference: 0.0700; null margin: 0.0000
#> 
#>              method estimate    conf.low conf.high statistic   p.value
#>                Wald     0.07 -0.04345805 0.1834580  1.209235 0.2265724
#>               Score     0.07 -0.04432278 0.1823656  1.204839 0.2282655
#>        Fisher exact     0.07          NA        NA        NA 0.3017227
#>  Miettinen-Nurminen     0.07 -0.04479568 0.1844067        NA        NA
#>                                                                           note
#>                             Large-sample Wald test; null difference is margin.
#>                                     Score test with constrained null variance.
#>  Exact conditional 2x2 test; Fisher CI is for odds ratio, not risk difference.
#>                      Confidence interval method; no separate p-value reported.

Non-inferiority

For a non-inferiority margin of 10 percentage points, use a null difference of -0.10 and a one-sided greater alternative.

farrington_manning(82, 100, 85, 100, margin=-0.10, alternative="greater")
#> 
#>  Farrington-Manning score test
#> 
#> data:  x1 = 82, n1 = 100; x2 = 85, n2 = 100
#> Z = 1.3198, p-value = 0.09345
#> alternative hypothesis: true difference in proportions is greater than -0.1
#>  percent confidence interval:
#>  -0.135012  0.074556
#> sample estimates:
#> difference in proportions 
#>                     -0.03

Equivalence

equivalence_2prop(80, 100, 78, 100, margin=0.10, conf.level=0.90)
#>   estimate    conf.low conf.high margin equivalent
#> 1     0.02 -0.07557697 0.1155364    0.1      FALSE
#>                                                       method
#> 1 Miettinen-Nurminen CI / two-one-sided equivalence decision