blockRAR: An R package for Simulation of Block Design for Response-Adaptive Randomization

Thevaa Chandereng, Rick Chappell

Introduction

Response-Adaptive Randomization (RAR) design utilizes accrual information to tilt the randomization ratio to the better performing treatment group. Patients enrolled in these trials are not only treated to obtain effectiveness of a treatment but also treated to the best way possible. Altering the randomization ratio drastically can potentially affect the bias in a trial especially if one treatment is very superior to the other treatment. The major drawback to response-adaptive randomization design is that the trial needs to be short to be able to obtain the outcome of the trial for future randomization. There are various methods developed to address some of this flaws besides developing a proper design for response-adaptive randomization.

Time drift can lead to bias by confounding the treatment effect with time effects. Time trends are nearly universally ignored among RAR proponents. Besides skewed randomization ratio, time trend can be a confounding factor as illustrated in the example below.

Example of time trend issue in response-adaptive randomization (RAR) design:

Therefore, we designed a stratified group-sequential method on altering the randomization ratio in a block/group level to address this issue instead of altering the randomization ratio by patient basis. In each block/group, the randomization ratio is kept constant. However, the ideal number of block/group is still vague.

blockRAR is an R package for the simulation of response-adaptive randomization trials with binomial outcomes where patients are assigned in block and randomization ratio is altered by block rather than patient by patient basis using both frequentist and Bayesian method. For more details on the method, please look at our preprint.

If you use blockRAR in published research, please cite our preprint:

Robust Response-Adaptive Randomization Design. Chandereng, T., & Chappell, R. (2019). arXiv preprint arXiv:1904.07758.

If after reading through this vignette you have questions or problems using blockRAR, please post them to https://github.com/thevaachandereng/blockRAR/issues. This will notify the package maintainers and we can work to address the issue(s). Please note that comments and questions should not be emailed directly to the package authors.

Running blockRAR

Prior to analyzing your data, the R package needs to be installed. The easiest way to install blockRAR is through CRAN:

install.packages("blockRAR")

There are additional ways to download blockRAR. The first option is most useful for downloading a specific version of blockRAR (which can be found at https://github.com/thevaachandereng/bayesCT/releases):

devtools::install_github("thevaachandereng/blockRAR@vx.xx.x")
# or 
devtools::install_version("blockRAR", version = "x.x.x", repos = "http://cran.us.r-project.org")

The second option is to download the most recent stable version through GitHub:

devtools::install_github("thevaachandereng/blockRAR")

After successful installation, the package must be loaded into the working space:

library(blockRAR)

Required input

In this section, we will describe each input for the frequentist and Bayesian approach of block design for RAR.

Frequentist Approach

p_control: The object p_control has to be \(0 <\) p_control \(< 1\). This determines the proportion of events in the control group.

p_treatment: The object p_treatment has to be \(0 <\) p_treatment \(< 1\). This determines the proportion of events in the treatment group.

N_total: The object N_total determines the targeted sample size of subjects enrolled in the trial. When early stopping criteria is specified, the total sample size enrolled in the trial might be smaller than the one used.

block_number: The object block_number determines the number of blocks/groups used in the design of the trial. The value of block_number needs to smaller or equal to the size of N_total. For traditional RAR, set block_number equal to N_total. For traditional RCT, select block_number to 1. The early stopping criteria is applied after completing enrollment and data collection in each block. The randomization ratio is also altered at the block level. The default block_number is set to 4.

drift: The object drift controls the size of the patient-drift as described in the preprint.The drift changes the magnitude of proportion of events in either positive/negative direction. The drift is applied at the block level where p_control and p_treatment both increasing in a step-wise manner at each block level from their initial values to final value of the drift. Please make sure that the drift is within the limit specified, 0 < p_treatment + drift < 1 and 0 < p_control + drift < 1.

simulation: The object simulation sets the number of trials to be run.

conf_int: The object conf_int determines the confidence interval of the trial. This value is same as 1- \(\alpha\) in the clinical setting.

alternative: The object alternative only takes two value “greater” (default) or “less”. If alternative is greater then the the trial is successful p_treatment > p_control and vice versa.

correct: The object correct is a logical indicator. If correct is set to FALSE (default), the Yates-continuity correction is not applied and vice-versa.

replace: The object replace is a logical indicator. If replace is set to TRUE (default), the sampling is done with replacement. If replace is set to FALSE, the replacement is done without replacement.

early_stop: The object early_stop is a logical indicator. The default is set to FALSE, which does not allow early stopping. If early stopping is applied, the early stopping is done at block level using the Lan-DeMets alpha-spending function.

Bayesian Approach

p_control: The object p_control has to be \(0 <\) p_control \(< 1\). This determines the proportion of events in the control group.

p_treatment: The object p_treatment has to be \(0 <\) p_treatment \(< 1\). This determines the proportion of events in the treatment group.

N_total: The object N_total determines the targeted sample size of subjects enrolled in the trial. When early stopping criteria is specified, the total sample size enrolled in the trial might be smaller than the one used.

block_number: The object block_number determines the number of blocks/groups used in the design of the trial. The value of block_number needs to smaller or equal to the size of N_total. For traditional RAR, set block_number equal to N_total. For traditional RCT, select block_number to 1. The early stopping criteria is applied after completing enrollment and data collection in each block. The randomization ratio is also altered at the block level. The default block_number is set to 4.

drift: The object drift controls the size of the patient-drift as described in the preprint.The drift changes the magnitude of proportion of events in either positive/negative direction. The drift is applied at the block level where p_control and p_treatment both increasing in a step-wise manner at each block level from their initial values to final value of the drift. Please make sure that the drift is within the limit specified, 0 < p_treatment + drift < 1 and 0 < p_control + drift < 1.

simulation: The object simulation sets the number of trials to be run.

a0: The object a0 set the parameter value of a in the non-informative prior in Beta(a, b).

b0: The object b0 set the parameter value of b in the non-informative prior in Beta(a, b).

p: The object p sets the power in the allocation probability. The probability of randomizing subjects to treatment A in stratum j is defined as \[\pi_{j, A} = \frac{(p_{A>B} (data))^ {p}}{(p_{A>B} (data))^ {p} + (p_{B>A} (data))^ {p}},\] where \(p_{A > B}(data)\) is the posterior probability that treatment A has a higher success rate than treatment B and \(p_{A>B} (data)) = 1 - p_{B>A} (data))\).

number_mcmc: The object number_mcmc determines the number of posterior sample draw randomly using Monte-Carlo method. The default is set to 10,000.

prob_accept_ha: The object prob_accept_ha controls the posterior probability of accepting the alternative hypothesis. The default is set to 0.95.

early_success_prob: The object early_success_prob sets the probability of stopping early for success. The default is set to 0.99. Change this value to 1 if you do not want to stop early for success.

futility_prob: The object futility_prob sets the probability of stopping early for futility. The default is set to 0.01. Change this value to 0 if you do not want to stop early for futility.

alternative: The object alternative only takes two value “greater” (default) or “less”. If alternative is greater then the the trial is successful p_treatment > p_control and vice versa.

Obtaining Power and Sample Size

blockRAR computes power (true-positive) and return several outputs: power (proportion of true-positive), mean estimated proportion of events in the control and treatment group, stratified proportion difference in treatment, sample size enrolled, sample size in each treatment group.

Frequentist Approach

Computing power, stratified difference in treatment proportion using the binomialfreq function.

An example function execution with proportion of events in control is 0.25, proportion of events in treatment is 0.45, targeted sample size of 200, 5 number of blocks where randomization ratio is altered, no drift is applied, \(\alpha\) of 0.05, alternative of “greater”, sampling with replacement and early stopping not applied.

#> $power
#> [1] 0.9
#> 
#> $p_control_estimate
#>   [1] 0.2446809 0.2197802 0.2696629 0.2783505 0.3368421 0.1470588 0.2365591
#>   [8] 0.2959184 0.1666667 0.2365591 0.2151899 0.2285714 0.1791045 0.1704545
#>  [15] 0.1538462 0.2352941 0.2588235 0.2054795 0.2947368 0.1720430 0.2083333
#>  [22] 0.2527473 0.2828283 0.1881188 0.2976190 0.1621622 0.2727273 0.2333333
#>  [29] 0.2700000 0.2429907 0.2739726 0.2613636 0.2696629 0.2705882 0.2289157
#>  [36] 0.2658228 0.2921348 0.2736842 0.1139241 0.2307692 0.2989691 0.2916667
#>  [43] 0.2790698 0.2531646 0.2682927 0.1758242 0.1538462 0.3118280 0.2784810
#>  [50] 0.2317073 0.2211538 0.2711864 0.2352941 0.2658228 0.2268041 0.2134831
#>  [57] 0.2500000 0.2784810 0.2844037 0.2539683 0.2000000 0.2555556 0.3119266
#>  [64] 0.2891566 0.2187500 0.2500000 0.3333333 0.2631579 0.2558140 0.2413793
#>  [71] 0.1830986 0.2315789 0.2222222 0.2906977 0.2625000 0.2626263 0.2474227
#>  [78] 0.2705882 0.2207792 0.2727273 0.2054795 0.2111111 0.3048780 0.2777778
#>  [85] 0.2761905 0.2400000 0.2596154 0.2465753 0.2788462 0.3176471 0.2804878
#>  [92] 0.1827957 0.2500000 0.2134831 0.2359551 0.3058824 0.2739726 0.1527778
#>  [99] 0.2650602 0.2916667
#> 
#> $p_treatment_estimate
#>   [1] 0.4716981 0.4220183 0.4684685 0.4854369 0.4761905 0.4848485 0.3925234
#>   [8] 0.4019608 0.4344262 0.5046729 0.5371901 0.5153846 0.3834586 0.4375000
#>  [15] 0.4666667 0.4173913 0.4173913 0.4409449 0.5904762 0.3831776 0.3653846
#>  [22] 0.4128440 0.4059406 0.3737374 0.4396552 0.4126984 0.5089286 0.4090909
#>  [29] 0.4700000 0.5161290 0.5196850 0.4017857 0.4864865 0.4782609 0.4786325
#>  [36] 0.4710744 0.3963964 0.4761905 0.4710744 0.5000000 0.4466019 0.4807692
#>  [43] 0.4912281 0.4049587 0.4830508 0.4862385 0.4344262 0.4485981 0.4710744
#>  [50] 0.3728814 0.4062500 0.3658537 0.5043478 0.4049587 0.4466019 0.4594595
#>  [57] 0.3888889 0.5041322 0.3846154 0.4744526 0.4250000 0.5545455 0.3296703
#>  [64] 0.5128205 0.3557692 0.4913793 0.3465347 0.4666667 0.4210526 0.4601770
#>  [71] 0.4496124 0.5333333 0.4201681 0.4561404 0.5166667 0.4653465 0.4757282
#>  [78] 0.5043478 0.4308943 0.5040650 0.4724409 0.4000000 0.3983051 0.4000000
#>  [85] 0.4736842 0.5200000 0.3645833 0.4488189 0.4166667 0.4869565 0.4152542
#>  [92] 0.4299065 0.4351852 0.4594595 0.4594595 0.4608696 0.4330709 0.4453125
#>  [99] 0.4615385 0.4326923
#> 
#> $prop_diff_estimate
#>   [1] 0.21878279 0.20671835 0.18832194 0.20629921 0.13350126 0.31322506
#>   [7] 0.14588592 0.09866393 0.25605727 0.25298082 0.33083110 0.27142857
#>  [13] 0.19156415 0.26736842 0.31116252 0.17677553 0.16330749 0.23399433
#>  [19] 0.30341207 0.22448980 0.14771574 0.16059518 0.10512688 0.17255504
#>  [25] 0.13592751 0.26152074 0.23435897 0.18006104 0.18331617 0.25871942
#>  [31] 0.25598219 0.13949843 0.22299839 0.19451630 0.21628768 0.20751720
#>  [37] 0.09868766 0.21828454 0.36729223 0.30939227 0.14962217 0.17638037
#>  [43] 0.19065521 0.15311005 0.21204188 0.28137092 0.30056497 0.12480418
#>  [49] 0.21105795 0.13597884 0.19050051 0.09195402 0.26420010 0.14203051
#>  [55] 0.21759500 0.22347873 0.10874089 0.23545405 0.08517188 0.22537764
#>  [61] 0.22842105 0.30804954 0.01686254 0.23026674 0.15092402 0.25313808
#>  [67] 0.01168348 0.20652728 0.17045455 0.21003621 0.26925338 0.29914098
#>  [73] 0.19121585 0.14943123 0.24358974 0.20746040 0.23490614 0.23789693
#>  [79] 0.22760981 0.21656407 0.26946438 0.20472009 0.09884332 0.12018256
#>  [85] 0.19603860 0.28696127 0.10515672 0.20162602 0.13336714 0.17539126
#>  [91] 0.12303665 0.26541009 0.19070010 0.22674095 0.22312787 0.17082228
#>  [97] 0.16826111 0.30022321 0.21574803 0.14554974
#> 
#> $N_enrolled
#>   [1] 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
#>  [18] 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
#>  [35] 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
#>  [52] 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
#>  [69] 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
#>  [86] 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
#> 
#> $N_control
#>   [1]  94  91  89  97  95  68  93  98  78  93  79  70  67  88  65  85  85
#>  [18]  73  95  93  96  91  99 101  84  74  88  90 100 107  73  88  89  85
#>  [35]  83  79  89  95  79  78  97  96  86  79  82  91  78  93  79  82 104
#>  [52] 118  85  79  97  89  92  79 109  63  80  90 109  83  96  84  99  95
#>  [69]  86  87  71  95  81  86  80  99  97  85  77  77  73  90  82  90 105
#>  [86]  75 104  73 104  85  82  93  92  89  89  85  73  72  83  96
#> 
#> $N_treatment
#>   [1] 106 109 111 103 105 132 107 102 122 107 121 130 133 112 135 115 115
#>  [18] 127 105 107 104 109 101  99 116 126 112 110 100  93 127 112 111 115
#>  [35] 117 121 111 105 121 122 103 104 114 121 118 109 122 107 121 118  96
#>  [52]  82 115 121 103 111 108 121  91 137 120 110  91 117 104 116 101 105
#>  [69] 114 113 129 105 119 114 120 101 103 115 123 123 127 110 118 110  95
#>  [86] 125  96 127  96 115 118 107 108 111 111 115 127 128 117 104

Bayesian Approach

Computing power, stratified difference in treatment proportion using the binomialbayes function.

An example function execution with proportion of events in control is 0.35, proportion of events in treatment is 0.35, targeted sample size of 150, 2 number of blocks where randomization ratio is altered, 0.10 drift is applied, \(Beta(0.5, 0.5)\) non-informative prior is used, probability of accepting alternative of 0.95, alternative of “greater”, sampling with replacement and early stopping not applied.

#> $power
#> [1] 0.02
#> 
#> $prop_diff_estimate
#>  [1]  0.122363723  0.055128537  0.110957049  0.170985187 -0.044515289
#>  [6] -0.099337040 -0.150922333  0.024658098  0.003202895  0.077071507
#> [11] -0.016140283 -0.088682950  0.144027059 -0.077464462 -0.116272073
#> [16]  0.095522389 -0.066996015  0.003455292 -0.143872778 -0.143348617
#> [21] -0.084607494  0.050956538  0.040198961 -0.098757917 -0.081229490
#> [26] -0.081227978  0.053112581  0.022053088 -0.007419894 -0.076619089
#> [31]  0.040670619  0.047726067 -0.009258954 -0.001266261 -0.120760464
#> [36]  0.033794273  0.003031237 -0.055175679  0.025318312  0.011988397
#> [41] -0.027332365  0.005105955 -0.087138708 -0.258360729 -0.009175432
#> [46] -0.024068728 -0.050552072 -0.078054852  0.031481029  0.095502706
#> 
#> $N_enrolled
#>  [1] 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150
#> [18] 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150
#> [35] 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150
#> 
#> $N_control
#>  [1]  61  63  56  53 107 103 111  76  75  67  61  80  53  97  83  82  88
#> [18]  66  96  83 102  98  86  95  90  86  61  76  88  86  67  76  71  56
#> [35]  89  79  77  88  82  69  85  70  94 105  78  70  89  80  84  61
#> 
#> $N_treatment
#>  [1] 89 87 94 97 43 47 39 74 75 83 89 70 97 53 67 68 62 84 54 67 48 52 64
#> [24] 55 60 64 89 74 62 64 83 74 79 94 61 71 73 62 68 81 65 80 56 45 72 80
#> [47] 61 70 66 89
#> 
#> $early_success
#>  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> [36] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $early_futilty
#>  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> [36] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Session Info

#> R version 3.5.2 (2018-12-20)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Mojave 10.14.5
#> 
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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] blockRAR_1.0.1 ggplot2_3.2.0 
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.1        nloptr_1.2.1      pillar_1.4.2     
#>  [4] compiler_3.5.2    tools_3.5.2       boot_1.3-23      
#>  [7] lme4_1.1-21       digest_0.6.20     nlme_3.1-140     
#> [10] evaluate_0.14     tibble_2.1.3      gtable_0.3.0     
#> [13] lattice_0.20-38   pkgconfig_2.0.2   rlang_0.4.0      
#> [16] Matrix_1.2-17     yaml_2.2.0        xfun_0.8         
#> [19] coda_0.19-3       withr_2.1.2       dplyr_0.8.3      
#> [22] stringr_1.4.0     knitr_1.23        ldbounds_1.1-1.1 
#> [25] grid_3.5.2        tidyselect_0.2.5  glue_1.3.1       
#> [28] R6_2.4.0          survival_2.44-1.1 arm_1.10-1       
#> [31] rmarkdown_1.14    bayesDP_1.3.2     minqa_1.2.4      
#> [34] purrr_0.3.2       magrittr_1.5      splines_3.5.2    
#> [37] scales_1.0.0      htmltools_0.3.6   MASS_7.3-51.4    
#> [40] abind_1.4-5       assertthat_0.2.1  colorspace_1.4-1 
#> [43] labeling_0.3      stringi_1.4.3     lazyeval_0.2.2   
#> [46] munsell_0.5.0     crayon_1.3.4