The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

SAMprior for Continuous Endpoints

Peng Yang and Ying Yuan

2023-09-27

Introduction

The self-adapting mixture prior (SAMprior) package is designed to enhance the effectiveness and practicality of clinical trials by leveraging historical information or real-world data [1]. The package incorporate historical data into a new trial using an informative prior constructed based on historical data while mixing a non-informative prior to enhance the robustness of information borrowing. It utilizes a data-driven way to determine a self-adapting mixture weight that dynamically favors the informative (non-informative) prior component when there is little (substantial) evidence of prior-data conflict. Operating characteristics are evaluated and compared to the robust Meta-Analytic-Predictive (rMAP) prior [2], which assigns a fixed weight of 0.5.

SAM Prior Derivation

SAM prior is constructed by mixing an informative prior \(\pi_1(\theta)\), constructed based on historical data, with a non-informative prior \(\pi_0(\theta)\) using the mixture weight \(w\) determined by SAM_weight function to achieve the degree of prior-data conflict [1]. The following sections describe how to construct SAM prior in details.

Informative Prior Construction based on Historical Data

We assume three historical data as follows:

study n mean se
1 40 0.136 0.426
2 50 0.172 0.381
3 60 -0.416 0.398

To construct informative priors based on the aforementioned three historical data, we apply gMAP function from RBesT to perform meta-analysis. This informative prior results in a representative form from a large MCMC samples, and it can be converted to a parametric representation with the automixfit function using expectation-maximization (EM) algorithm [3]. This informative prior is also called MAP prior.

sigma = 3
# load R packages
library(ggplot2)
theme_set(theme_bw()) # sets up plotting theme
set.seed(22)
map_mcmc <- gMAP(cbind(mean, se) ~ 1 | study, 
                 weights=n,data=dat,
                 family=gaussian,
                 beta.prior=cbind(0, sigma),
                 tau.dist="HalfNormal",tau.prior=cbind(0,sigma/2))
## Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#bulk-ess
## Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
## Running the chains for more iterations may help. See
## https://mc-stan.org/misc/warnings.html#tail-ess
map_automix <- automixfit(map_mcmc)
map_automix
## EM for Normal Mixture Model
## Log-Likelihood = -527.5969
## 
## Univariate normal mixture
## Reference scale: 2.831279
## Mixture Components:
##   comp1       comp2      
## w  0.73488046  0.26511954
## m -0.07518592  0.02203138
## s  0.37782075  1.56125541
plot(map_automix)$mix

The resulting MAP prior is approximated by a mixture of conjugate priors.

SAM Weight Determination

Let \(\theta\) and \(\theta_h\) denote the treatment effects associated with the current arm data \(D\) and historical \(D_h\), respectively. Let \(\delta\) denote the clinically significant difference such that is \(|\theta_h - \theta| \ge \delta\), then \(\theta_h\) is regarded as clinically distinct from \(\theta\), and it is therefore inappropriate to borrow any information from \(D_h\). Consider two hypotheses:

\[ H_0: \theta = \theta_h, ~~ H_1: \theta = \theta_h + \delta ~ \text{or} ~ \theta = \theta_h - \delta. \] \(H_0\) represents that \(D_h\) and \(D\) are consistent (i.e., no prior-data conflict) and thus information borrowing is desirable, whereas \(H_1\) represents that the treatment effect of \(D\) differs from \(D_h\) to such a degree that no information should be borrowed.

The SAM prior uses the likelihood ratio test (LRT) statistics \(R\) to quantify the degree of prior-data conflict and determine the extent of information borrowing. \[ R = \frac{P(D | H_0, \theta_h)}{P(D | H_1, \theta_h)} = \frac{P(D | \theta = \theta_h)}{\max \{ P(D | \theta = \theta_h + \delta), P(D | \theta = \theta_h - \delta) \}} , \] where \(P(D | \cdot)\) denotes the likelihood function. An alternative Bayesian choice is the posterior probability ratio (PPR): \[ R = \frac{P(D | H_0, \theta_h)}{P(D | H_1, \theta_h)} = \frac{P(H_0)}{P(H_1)} \times BF , \] where \(P(H_0)\) and \(P(H_1)\) is the prior probabilities of \(H_0\) and \(H_1\) being true. \(BF\) is the Bayes Factor that in this case is the same as LRT.

The SAM prior, denoted as \(\pi_{sam}(\theta)\), is then defined as a mixture of an informative prior \(\pi_1(\theta)\), constructed based on \(D_h\), with a non-informative prior \(\pi_0(\theta)\): \[\pi_{sam}(\theta) = w \pi_1(\theta) + (1 - w) \pi_0(\theta)\] where the mixture weight \(w\) is calculated as: \[w = \frac{R}{1 + R}.\] As the level of prior-data conflict increases, the likelihood ratio \(R\) decreases, resulting in a decrease in the weight \(w\) assigned to the informative prior and a decrease in information borrowing. As a result, \(\pi_{sam}(\theta)\) is data-driven and has the ability to self-adapt the information borrowing based on the degree of prior-data conflict.

To calculate the SAM weight \(w\), we first assume the sample size enrolled in the control arm is \(n = 30\), with \(\theta = 0.4\) and \(\sigma = 3\). Additionally, we assume the effective size is \(d = \frac{\theta - \theta_h}{\sigma} = 0.5\), then we can apply function SAM_weight in SAMprior as follows:

set.seed(234)
sigma        <- 3 ## Standard deviation in the current trial
data.crt     <- rnorm(30, mean = 0.4, sd = sigma)
wSAM <- SAM_weight(if.prior = map_automix, 
                   delta = 0.5 * sigma,
                   data = data.crt)
cat('SAM weight: ', wSAM)
## SAM weight:  0.9338857

The default method to calculate \(w\) is using LRT, which is fully data-driven. However, if investigators want to incorporate prior information on prior-data conflict to determine the mixture weight \(w\), this can be achieved by using PPR method as follows:

wSAM <- SAM_weight(if.prior = map_automix, 
                   delta = 0.5 * sigma,
                   method.w = 'PPR',
                   prior.odds = 3/7,
                   data = data.crt)
cat('SAM weight: ', wSAM)
## SAM weight:  0.8582306

The prior.odds indicates the prior probability of \(H_0\) over the prior probability of \(H_1\). In this case (e.g., prior.odds = 3/7), the prior information favors the presence prior-data conflict and it results in a decreased mixture weight.

When historical information is congruent with the current control arm, SAM weight reaches to the highest peak. As the level of prior-data conflict increases, SAM weight decreases. This demonstrates that SAM prior is data-driven and self-adapting, favoring the informative (non-informative) prior component when there is little (substantial) evidence of prior-data conflict.

SAM Prior Construction

To construct the SAM prior, we mix the derived informative prior \(\pi_1(\theta)\) with a vague prior \(\pi_0(\theta)\) using pre-determined mixture weight by SAM_prior function in SAMprior as follows:

unit_prior <- mixnorm(nf.prior = c(1, summary(map_automix)['mean'], sigma))
SAM.prior <- SAM_prior(if.prior = map_automix, 
                       nf.prior = unit_prior,
                       weight = wSAM, sigma = sigma)
SAM.prior
## Univariate normal mixture
## Reference scale: 2.831279
## Mixture Components:
##   comp1       comp2       nf.prior   
## w  0.63069693  0.22753371  0.14176935
## m -0.07518592  0.02203138 -0.04941172
## s  0.37782075  1.56125541  3.00000000

where the non-informative prior \(\pi_0(\theta)\) follows an unit-information prior.

Operating Characteristics

In this section, we aim to investigate the operating characteristics of the SAM prior, constructed based on the historical data, via simulation. The incorporation of historical information is expected to be beneficial in reducing the required sample size for the current arms. To achieve this, we assume a 1:2 ratio between the control and treatment arms.

We compare the operating characteristics of the SAM prior and rMAP prior with pre-specified fixed weight under various scenarios. Specifically, we will evaluate the relative bias and relative mean squared error (MSE) of these methods. The relative bias and relative MSE are defined as the differences between the bias/MSE of a given method and the bias/MSE obtained when using a non-informative prior.

Additionally, we investigate the type I error and power of the methods under different degrees of prior-data conflicts. The decision regarding whether a treatment is superior or inferior to a standard control will be based on the condition: \[\Pr(\theta_t - \theta > 0) > 0.95.\]

In SAMprior, the operating characteristics can be considered in following steps:

  1. Specify priors: This step involves constructing informative prior based on historical data and non-informative prior.

  2. Specify the decision criterion: The decision2S function is used to initialize the decision criterion. This criterion determines whether a treatment is considered superior or inferior to a standard control.

  3. Specify design parameters for the get_OC function: This step involves defining the design parameters for evaluating the operating characteristics. These parameters include the clinically significant difference (CSD) used in SAM prior calculation, the method used to determine the mixture weight for the SAM prior, the sample sizes for the control and treatment arms, the number of trials used for simulation, the choice of weight for the robust MAP prior used as a benchmark, and the vector of mean for both the control and treatment arms.

Type I Error

To compute the type I error, we consider four scenarios, with the first and last two scenarios representing minimal and substantial prior-data conflicts, respectively. In general, the results show that both methods effectively control the type I error.

set.seed(123)
# weak_prior <- mixnorm(c(1, summary(map_automix)[1], 1e4))
TypeI <- get_OC(if.prior = map_automix,    ## MAP prior from historical data
                nf.prior = unit_prior,     ## Weak-informative prior for treatment arm
                delta    = 0.5*sigma,      ## CSD for SAM prior
                n        = 35, n.t = 70,   ## Sample size for control and treatment arms
                ## Decisions
                decision = decision2S(0.95, 0, lower.tail=FALSE), 
                ntrial   = 1000,           ## Number of trials simulated
                if.MAP   = TRUE,           ## Output robust MAP prior for comparison
                weight   = 0.5,            ## Weight for robust MAP prior
                ## Mean for control and treatment arms
                theta    = c(0, 0,    -2, 4),
                theta.t  = c(0, -0.1, -2, 4),
                sigma    = sigma
                  )
kable(TypeI)
scenarios Bias_SAM Bias_rMAP RMSE_SAM RMSE_rMAP wSAM res_SAM res_rMAP res_NP
1 -0.0248206 -0.0243740 -0.1075388 -0.1240484 0.8041724 0.041 0.035 0.045
2 -0.0247446 -0.0242491 -0.1126363 -0.1291589 0.7943349 0.028 0.023 0.041
3 0.0093525 0.0973235 0.0212740 0.0903446 0.0209923 0.039 0.034 0.039
4 -0.0010887 -0.0173615 0.0013474 0.0109438 0.0000019 0.059 0.062 0.059

Power

For power evaluation, we also consider four scenarios, with the first and last two scenarios representing minimal and substantial prior-data conflicts, respectively. In general, it is observed that the SAM prior achieves comparable or better power compared to rMAP.

set.seed(123)
Power <- get_OC(if.prior = map_automix,    ## MAP prior based on historical data
                nf.prior = unit_prior,     ## Non-informative prior for treatment arm
                delta    = 0.5*sigma,      ## CSD for SAM prior
                n        = 35, n.t = 70,   ## Sample size for control and treatment arms
                ## Decisions
                decision = decision2S(0.95, 0, lower.tail=FALSE), 
                ntrial   = 1000,           ## Number of trials simulated
                if.MAP   = TRUE,           ## Output robust MAP prior for comparison
                weight   = 0.5,            ## Weight for robust MAP prior
                ## Mean for control and treatment arms
                theta    = c(0, 0.1, 0.5,  -3),
                theta.t  = c(1, 1.1, 2.0,  -1.5),
                sigma    = sigma
                  )
kable(Power)
scenarios Bias_SAM Bias_rMAP RMSE_SAM RMSE_rMAP wSAM res_SAM res_rMAP res_NP
1 -0.0248206 -0.0243740 -0.1075388 -0.1240484 0.8041724 0.649 0.613 0.490
2 -0.0522174 -0.0546798 -0.1026904 -0.1220012 0.7811122 0.683 0.643 0.497
3 -0.1251201 -0.1537897 -0.0005318 -0.0454033 0.6179126 0.841 0.864 0.787
4 -0.0013552 0.0279196 0.0006793 0.0177291 0.0004386 0.768 0.744 0.768

Decision Making

Finally, we present an example of how to make a final decision on whether the treatment is superior or inferior to a standard control once the trial has been completed and data has been collected. This step can be accomplished using the postmix function from RBesT, as shown below:

## Simulate data for treatment arm
data.trt <- rnorm(60, mean = 3, sd = sigma)

## first obtain posterior distributions...
post_SAM <- postmix(priormix = SAM.prior,   ## SAM Prior
                    data = data.crt)
post_trt <- postmix(priormix = unit_prior,  ## Non-informative prior
                    data = data.trt)

## Define the decision function
decision = decision2S(0.95, 0, lower.tail=FALSE)

## Decision-making
decision(post_trt, post_SAM)
## [1] 1

References

[1] Yang P. et al., Biometrics, 2023; 00, 1–12. https://doi.org/10.1111/biom.13927
[2] Schmidli H. et al., Biometrics, 2014; 70(4):1023-1032.
[3] Neuenschwander B. et al., Clin Trials, 2010; 7(1):5-18.

R Session Info

sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur ... 10.16
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] knitr_1.43       SAMprior_1.1.1   ggplot2_3.4.3    Metrics_0.1.4   
## [5] checkmate_2.2.0  assertthat_0.2.1 RBesT_1.7-2     
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.11          mvtnorm_1.2-3        prettyunits_1.1.1   
##  [4] ps_1.7.5             digest_0.6.33        utf8_1.2.3          
##  [7] plyr_1.8.8           R6_2.5.1             backports_1.4.1     
## [10] stats4_4.2.1         evaluate_0.21        highr_0.10          
## [13] pillar_1.9.0         rlang_1.1.1          rstudioapi_0.15.0   
## [16] callr_3.7.3          jquerylib_0.1.4      rmarkdown_2.24      
## [19] labeling_0.4.3       stringr_1.5.0        loo_2.6.0           
## [22] munsell_0.5.0        compiler_4.2.1       xfun_0.40           
## [25] rstan_2.21.8         pkgconfig_2.0.3      pkgbuild_1.4.2      
## [28] rstantools_2.3.1.1   htmltools_0.5.6      tidyselect_1.2.0    
## [31] tibble_3.2.1         tensorA_0.36.2       gridExtra_2.3       
## [34] codetools_0.2-19     matrixStats_1.0.0    fansi_1.0.4         
## [37] crayon_1.5.2         dplyr_1.1.3          withr_2.5.0         
## [40] grid_4.2.1           distributional_0.3.2 jsonlite_1.8.7      
## [43] gtable_0.3.4         lifecycle_1.0.3      DBI_1.1.3           
## [46] magrittr_2.0.3       posterior_1.4.1      StanHeaders_2.26.27 
## [49] scales_1.2.1         RcppParallel_5.1.7   stringi_1.7.12      
## [52] cli_3.6.1            cachem_1.0.8         reshape2_1.4.4      
## [55] farver_2.1.1         bslib_0.5.1          generics_0.1.3      
## [58] vctrs_0.6.3          Formula_1.2-5        tools_4.2.1         
## [61] glue_1.6.2           processx_3.8.2       abind_1.4-5         
## [64] parallel_4.2.1       fastmap_1.1.1        yaml_2.3.7          
## [67] inline_0.3.19        colorspace_2.1-0     bayesplot_1.10.0    
## [70] sass_0.4.7

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.