Bayesian Inference and Bayesian Adaptive Trial Examples

Yuan Zhong

2024-08-01

Introduction

This document shows how to use the Bayesian inference function Bayes_test and BayesAT in the package.

Simulation Examples

Bayesian inference

Consider a clinical trial designed to enroll 100 patients over a three-year period and last up to 5 years. Details of the patient enrollment simulation are outlined below:

data <- Simulate_Enroll(n = 100,
                        lambda = 0.03,
                        event = 0.1,
                        M = 1,
                        group = 5,
                        maxt = 5,
                        accrual = 3,
                        censor = 0.9,
                        followup = 2,
                        partition = "Even")

In the function Bayes_test, the Bayesian survival model uses the Gamma prior function Gamma. When users set type = "Posterior", the Bayesian inference can conduct statistical tests based on MCMC sampling outputs. With the specific threshold value, this function can test if the posterior estimation of \(lambda\) is less than this value by using test = "less" and provide the corresponding probability \(P(\hat{\lambda} < \text{threshold})\). For example, the Bayesian survival model utilizes Gamma prior Gamma(alpha = 3, beta = 20), and the simulated data is used to test if the estimated hazard rate is less than 0.03. The outputs can be summarized through summary function, which shows that the estimation results and probability of \(lambda\) are less than 0.03.

test <- Bayes_test(data, 
                   alpha = 3, 
                   beta = 20, 
                   test = "less",  
                   threshold = 0.03, 
                   type = "Posterior",
                   diagnosis = FALSE)

summary(test)
## 
## Bayesian inference can conclude that: 
## Posterior mean is  0.0334 and standard deviation is  0.3845 
## Credible interval and summary statistics is given by 
##   2.5%     5%    25%    50%    75%    95%  97.5% 
## 0.0178 0.0198 0.0268 0.0326 0.0392 0.0499 0.0539 
## 
## Posterior probability P( hr^ <  0.03 ) =  0.3845 
## Standardized z score is 0.3717

Users can change test = "greater" or test = "two_sided to test if \(lambda\) is greater than or not equal to 0.03.

test <- Bayes_test(data, 
                   alpha = 3, 
                   beta = 20, 
                   test = "greater", 
                   pred = 2, 
                   threshold = 0.03, 
                   type = "Posterior",
                   diagnosis = FALSE)
summary(test)
## 
## Bayesian inference can conclude that: 
## Posterior mean is  0.0334 and standard deviation is  0.6139 
## Credible interval and summary statistics is given by 
##   2.5%     5%    25%    50%    75%    95%  97.5% 
## 0.0178 0.0198 0.0268 0.0326 0.0391 0.0499 0.0539 
## 
## Posterior probability P( hr^ >=  0.03 ) =  0.6139 
## Standardized z score is 0.369

In those examples, the standardized z score is calculated as \[ \frac{\hat{\lambda} - \lambda_0}{SD( \hat{\lambda} )}.\] This value can be compared with a certain significance level.

In addition, when setting type = "Predictive", the function can test if the predicted survival probability of specific time point pred is greater than, less than, or equal to the threshold value. For example, the predictive probability of a 2-year survival rate greater than 90% can be estimated by using inputs test = "greater", pred = 2, and threshold = 0.9.

test <- Bayes_test(data, 
                   alpha = 3, 
                   beta = 60, 
                   test = "greater", 
                   pred = 2, 
                   threshold = 0.9, 
                   type = "Predictive",
                   diagnosis = TRUE)
summary(test)
## 
## Bayesian inference can conclude that: 
## Predictive survival mean is  0.9413 and standard deviation is  0.0157 
## Credible interval and summary statistics is given by 
##  2.5%    5%   25%   50%   75%   95% 97.5% 
## 90.71 91.33 93.15 94.26 95.26 96.48 96.82 
## 
## Predictive probability P( S^ >= 0.9 ) =  0.989 
## Standardized z score is 2.6272 
## The Bayes factor of chosen prior is  5.3974  compared with non-informative prior.

The standardized z score is calculated by \[ z = \frac{\hat{S} - S_0}{SD( \hat{S} )},\] and the Bayes factor is estimated based on Jeffrey’s prior as \(\pi \propto 1/\lambda\).

Interim analysis

The function BayesAT is designed for a Bayesian adaptive trial that allows assessing multiple-stage interim outcomes.

Suppose there are four clinical trials simulated with the following settings:

data <- Simulate_Enroll(n = c(17,23,16,24,15,25),
                        lambda = 0.025,
                        event = 0.05,
                        M = 4,
                        group = 6,
                        maxt = 4,
                        accrual = 3,
                        censor = 0.95,
                        followup = 1,
                        partition = "Uneven")

head(data[[1]])
##        Time Censor     Enroll
## 1 0.8163012      1 0.20743724
## 2 2.2753054      0 0.25532639
## 3 2.6890483      0 0.24341465
## 4 2.8542002      0 0.27123046
## 5 3.2998083      0 0.05095704
## 6 4.0000000      0 0.06977653

The function BayesAT can conduct multiple-stage interim analysis. The duration of interim analysis D needs to be set with matching length of enrollment, so the function can allocate patients into each stage based on the enrollment time. For example, the interim analysis can be arranged as follows,

Each stage of interim analysis applies the Bayesian test to assess efficacy or futility. Default stopping criteria are based on the normal quantile for a 5% significance level, divided by the number of stages for efficacy assessments, and 95% divided by the number of stages for determining futility.

IA <- BayesAT(data,
              D = 3,
              stage = 7,
              threshold = 0.89, 
              start = 1.5,
              objective = 2,
              alpha = 2, 
              beta = 20)
summary(IA)
## 
## Interim analysis results:
## 
## Trial 1 :
##               Stage 1 Stage 2 Stage 3 Stage 4 Stage 5 Stage 6 Stage 7
## Upper bound       4.3   2.394   2.128    1.96  1.8339  1.7317  1.6449
## Lower bound      -4.3 -1.0013  -0.477 -0.0627  0.3407  0.8122  1.6449
## Z score       -0.3982    0.74  0.7153  1.1556  2.9559  3.6052  3.5884
## Efficacy Prob       0  0.0026  0.0461  0.2236  0.8681  0.9532  0.9585
## Futility Prob  0.0014  0.0623  0.1231    0.12  0.0157  0.0109  0.0419
## Efficacy            -       -       -       -       +       +       +
## Futility            -       -       -       -       -       -       -
## 
## Trial 2 :
##               Stage 1 Stage 2 Stage 3 Stage 4 Stage 5 Stage 6 Stage 7
## Upper bound       4.3   2.394   2.128    1.96  1.8339  1.7317  1.6449
## Lower bound      -4.3 -1.0013  -0.477 -0.0627  0.3407  0.8122  1.6449
## Z score        0.2248  0.0969  1.1869  3.4447  3.2251  5.5358  4.4056
## Efficacy Prob       0       0  0.1684   0.917   0.907  0.9975  0.9888
## Futility Prob   8e-04  0.1381   0.067  0.0054  0.0107   5e-04  0.0118
## Efficacy            -       -       -       +       +       +       +
## Futility            -       -       -       -       -       -       -
## 
## Trial 3 :
##               Stage 1 Stage 2 Stage 3 Stage 4 Stage 5 Stage 6 Stage 7
## Upper bound       4.3   2.394   2.128    1.96  1.8339  1.7317  1.6449
## Lower bound      -4.3 -1.0013  -0.477 -0.0627  0.3407  0.8122  1.6449
## Z score       -0.4452  1.7253   1.901  2.4628  3.1593   3.045  4.2755
## Efficacy Prob       0  0.2868  0.4797  0.7308  0.8987  0.8966  0.9864
## Futility Prob  0.0016  0.0192  0.0258    0.02  0.0112  0.0261  0.0136
## Efficacy            -       -       -       +       +       +       +
## Futility            -       -       -       -       -       -       -
## 
## Trial 4 :
##               Stage 1 Stage 2 Stage 3 Stage 4 Stage 5 Stage 6 Stage 7
## Upper bound       4.3   2.394   2.128    1.96  1.8339  1.7317  1.6449
## Lower bound      -4.3 -1.0013  -0.477 -0.0627  0.3407  0.8122  1.6449
## Z score       -0.5082  0.2107   1.144  1.1756   3.006  3.0442  4.2305
## Efficacy Prob       0       0  0.1537  0.2291  0.8727  0.8963  0.9858
## Futility Prob  0.0018  0.1195  0.0712  0.1163  0.0148  0.0263  0.0145
## Efficacy            -       -       -       -       +       +       +
## Futility            -       -       -       -       -       -       -
plot(IA)

The results include the boundaries, the standardized z score, and predictive power for efficacy and futility. Users can use summary function to show the table of interim analysis results for each trial, and use plot to visualize the results.