Skip to content

R package for implementing non-inferiority tests with accompanying p-values and confidence intervals including an Exact-Corrected proposed method

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

NourHawila/EC

Repository files navigation

EC

Overview

This package calculates the exact-corrected confidence interval Hawila & Berg, 2021 and other confidence intervals for noninferiorty binomial trials with various methods. Additionally, as described in Hawila & Berg (2021), functions are provided to calculate maximal sizes and p-values corresponding to different confidence interval methods.

Installation

library(devtools)
install_github("NourHawila/EC")

Load the package

library(EC)

Usage

We consider a noninferiority trial with treatment group (T) and control/standard-of-care group (C) having a binary endpoint representing whether or not an outcome is observed. Here we assume the outcome is a positive event (e.g. resolution of a disease).

Let PT and PC be the probabilities the outcome is observed, and let δ = PT − PC represent the risk difference. We consider the following hypotheses:

H0 : δ ≤  − δ0: “inferior trial”; T is inferior to C

H1 : δ >  − δ0: “non-inferior trial”; T is not inferior to C

Let x.T, x.C, N.T, N.C, delta0, and alpha be the user-defined values for the noninferiority trial.

We use small sample sizes in the example below as the Chan & Zhang confidence interval method can take a while to compute.

x.T=5
x.C=2
N.T=6
N.C=6  
delta0=.12
alpha=.05

Confidence intervals

Note that only the exact corrected confidence interval, ci_EC, uses the noninferiority margin δ0 in constructing the confidence interval. Note that H0 is rejected if the lower bound of the confidence interval is larger than  − δ0.

ci_EC(x.T=x.T,x.C=x.C,N.T=N.T,N.C=N.C,alpha=alpha,delta0=delta0)
#> $ci.lower
#> [1] -0.1090285
#> 
#> $ci.upper
#> [1] 0.7909168
#> 
#> $count
#> [1] 35
ci_CZ(x.T=x.T,x.C=x.C,N.T=N.T,N.C=N.C,alpha=alpha)
#> $ci.lower
#> [1] -0.14288
#> 
#> $ci.upper
#> [1] 0.8879
ci_MN(x.T=x.T,x.C=x.C,N.T=N.T,N.C=N.C,alpha=alpha)
#> $ci.lower
#> [1] -0.05788002
#> 
#> $ci.upper
#> [1] 0.8210233
#> 
#> $count
#> [1] 36
ci_Wald(x.T=x.T,x.C=x.C,N.T=N.T,N.C=N.C,alpha=alpha)
#> $ci.lower
#> [1] 0.01916852
#> 
#> $ci.upper
#> [1] 0.9808315

p-values

As described in Hawila & Berg, 2021, we correspond a p-value with each confidence interval method. Note that H0 is rejected if the p-value is smaller than α/2.

pval_Chan(x.T=x.T,x.C=x.C,N.T=N.T,N.C=N.C,delta0=delta0)
#> [1] 0.02271896
pval_CZ(x.T=x.T,x.C=x.C,N.T=N.T,N.C=N.C,delta0=delta0)
#> [1] 0.02994009
pval_MN(x.T=x.T,x.C=x.C,N.T=N.T,N.C=N.C,delta0=delta0)
#> [1] 0.01438484
pval_Wald(x.T=x.T,x.C=x.C,N.T=N.T,N.C=N.C,delta0=delta0)
#> [1] 0.005748107

Maximal sizes

As described in Hawila & Berg, 2021, for a given value of NT, NC, and α, we can also calculate the maximal size for each confidence interval method. The size of the exact-corrected method is bounded by α/2, but the sizes of the other methods can be larger than α/2.

size_EC(alpha=alpha,N.T=N.T,N.C=N.C,delta0=delta0)
#> $level
#> [1] 0.02238953
#size_CZ(alpha=alpha,N.T=N.T,N.C=N.C,delta0=delta0)
size_MN(alpha=alpha,N.T=N.T,N.C=N.C,delta0=delta0)
#> $level
#> [1] 0.02986227
size_Wald(alpha=alpha,N.T=N.T,N.C=N.C,delta0=delta0)
#> $level
#> [1] 0.4644041

Getting help

help(package="EC")

About

R package for implementing non-inferiority tests with accompanying p-values and confidence intervals including an Exact-Corrected proposed method

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published