Skip to content

OakleyJ/assurance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

assurance

An R package for implementing the assurance method for normally distributed data, with elicited distributions for the treatment effect, and the population variances in the treatment and control arms. The package implements the methodology from

  • Alhussain, ZA, Oakley, JE. Assurance for clinical trial design with normally distributed outcomes: Eliciting uncertainty about variances. Pharmaceutical Statistics. 2020; 19: 827–839. https://doi.org/10.1002/pst.2040

Installation

The assurance package is currently on GitHub only and requires installation of SHELF. Install these with the commands

install.packages(c("devtools", "SHELF"))
devtools::install_github("OakleyJ/assurance")

Example

(If your browser is in dark mode, the equations won’t be visible!). This code illustrates the example from Alhussein and Oakley (2019).

We suppose the expert judges

Pr(\delta = 0) = 0.5,

and conditional on \delta \neq 0, the expert judges

Pr(\delta \le 0.25|\delta \neq 0) = 0.25,

Pr(\delta \le 0.4|\delta \neq 0) = 0.5,

Pr(\delta \le 0.55|\delta \neq 0) = 0.75.

We fit a distribution to these judgements with the command

v <- c(0.25, 0.4, 0.55)
p <- c(0.25, 0.5, 0.75)
myfitDelta <- SHELF::fitdist(vals = v, probs = p)

We suppose that a response of at least 0.2 is required for a patient to benefit. We suppose that if treatment effect were \delta = 0.4, expert judges between 60% and 80% of patients would benefit.

myfitTau <- SHELF::fitprecision(c(-Inf, 0.2),
                                propvals = c(0.2, 0.4),
                                propprobs = c(0.05, 0.95),
                                med = 0.4)

We now estimate the assurance, for sample sizes of 20 patients per group:

assurance::assuranceNormal(fitDelta = myfitDelta,
                fitPrecisionTmt = myfitTau,
                pDeltaZero  = 0.5,
                nTreatment = 20,
                nControl = 20)
#> [1] 0.3611

Next, we consider the information that might result from observing 10 patients in each arm. Denoting these 20 observations by D, we consider the predictive distribution of

Pr(\delta > 0 | D),

as a function of the yet-to-be-observed data D. The following command will simulate 1000 trials, and estimate the probability of a positive treatment effect given the data from each trial.

pEffective <- assurance::sampleInterim(fitDelta = myfitDelta,
                                       fitPrecisionTmt = myfitTau,
                                       nControl = 10,
                                       nTreatment = 10,
                                       pDeltaZero = 0.5,
                                       nTrials = 1000)

We would like

Pr(\delta > 0 | D),

to be close to 0 or 1. We count the proportion of the 1000 trials in which this probability is either less than 0.05, or greater than 0.95:

mean(pEffective < 0.05 | pEffective > 0.95)
#> [1] 0.468

We display the predictive distribution of posterior probabilities with a histogram:

hist(pEffective, breaks = seq(from = 0, 
                              to = 1, 
                              by = 0.05),
     xlab = expression(P(delta>0~"| trial data")),
     main ="")

shiny app

A shiny app is included in the package for implementing all the above methods. To launch the app, run the command

assuranceNormalApp()

About

Assurance for Clinical Trial Design

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published