Title: | Response-Adaptive Randomization in Clinical Trials |
---|---|
Description: | Some response-adaptive randomization methods commonly found in literature are included in this package. These methods include the randomized play-the-winner rule for binary endpoint (Wei and Durham (1978) <doi:10.2307/2286290>), the doubly adaptive biased coin design with minimal variance strategy for binary endpoint (Atkinson and Biswas (2013) <doi:10.1201/b16101>, Rosenberger and Lachin (2015) <doi:10.1002/9781118742112>) and maximal power strategy targeting Neyman allocation for binary endpoint (Tymofyeyev, Rosenberger, and Hu (2007) <doi:10.1198/016214506000000906>) and RSIHR allocation with each letter representing the first character of the names of the individuals who first proposed this rule (Youngsook and Hu (2010) <doi:10.1198/sbr.2009.0056>, Bello and Sabo (2016) <doi:10.1080/00949655.2015.1114116>), A-optimal Allocation for continuous endpoint (Sverdlov and Rosenberger (2013) <doi:10.1080/15598608.2013.783726>), Aa-optimal Allocation for continuous endpoint (Sverdlov and Rosenberger (2013) <doi:10.1080/15598608.2013.783726>), generalized RSIHR allocation for continuous endpoint (Atkinson and Biswas (2013) <doi:10.1201/b16101>), Bayesian response-adaptive randomization with a control group using the Thall \& Wathen method for binary and continuous endpoints (Thall and Wathen (2007) <doi:10.1016/j.ejca.2007.01.006>) and the forward-looking Gittins index rule for binary and continuous endpoints (Villar, Wason, and Bowden (2015) <doi:10.1111/biom.12337>, Williamson and Villar (2019) <doi:10.1111/biom.13119>). |
Authors: | Chuyao Xu [aut, cre], Thomas Lumley [aut, ths], Alain Vandal [aut, ths], Sofia S. Villar [cph], Kyle J. Wathen [cph] |
Maintainer: | Chuyao Xu <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.0.1 |
Built: | 2025-03-04 03:48:08 UTC |
Source: | https://github.com/yayayaoyaoyao/rartrials |
brar_select_au_binary
involves selecting au in Bayesian Response-Adaptive Randomization with a control group
for binary outcomes with two to five arms. The conjugate prior distributions follow Beta () distributions
and can be specified individually for each arm.
brar_select_au_binary( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, h, N2, tp, armlabel, blocksize, alpha1 = 1, beta1 = 1, alpha2 = alpha1, beta2 = beta1, alpha3 = alpha1, beta3 = beta1, alpha4 = alpha1, beta4 = beta1, alpha5 = alpha1, beta5 = beta1, minstart, deltaa, tpp = 0, deltaa1, side, output = NULL, ... )
brar_select_au_binary( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, h, N2, tp, armlabel, blocksize, alpha1 = 1, beta1 = 1, alpha2 = alpha1, beta2 = beta1, alpha3 = alpha1, beta3 = beta1, alpha4 = alpha1, beta4 = beta1, alpha5 = alpha1, beta5 = beta1, minstart, deltaa, tpp = 0, deltaa1, side, output = NULL, ... )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
armn |
number of total arms in the trial. |
h |
a vector of success probabilities in hypotheses, for example, as c(0.1,0.1) where 0.1 stands for the success probability for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the success probabilities for the control and the treatment group, respectively. |
N2 |
maximal sample size for the trial. |
tp |
tuning parameter. Some commonly used numbers are 0.5, 1 and n/2N. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
blocksize |
size of block used for equal randomization regarding participants in the 'initialization' period. Recommend to be an even multiple of the number of total arms. |
alpha1 , beta1
|
|
alpha2 , beta2
|
|
alpha3 , beta3
|
|
alpha4 , beta4
|
|
alpha5 , beta5
|
|
minstart |
a specified number of participants when one starts to check decision rules. |
deltaa |
a vector of minimal effect expected to be observed for early futility stopping in
each arm is approximately |
tpp |
indicator of |
deltaa1 |
a vector of pre-specified minimal effect size expected to be observed at the final stage
for each arm. The length of this parameter is |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
output |
control the output of |
... |
additional arguments to be passed to |
This function generates a data set or a value in one iteration for selecting the appropriate au using Bayesian
response-adaptive randomization with a control group under null hypotheses with no delay and delayed scenarios.
The function can handle trials with up to 5 arms for binary outcomes. This function uses the formula
with
side
equals to 'upper',
and
with
side
equals to 'lower', utilizing available data at each step.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
A list of results generated from formula at each step.
Note that before final stage of the trial, test statistics is calculated from
deltaa
, and test statistics is
calculated from deltaa1
at the final stage.
Wathen J, Thall P (2017). “A simulation study of outcome adaptive randomization in multi-arm clinical trials.” Clinical Trials, 14, 174077451769230. doi:10.1177/1740774517692302.
#brar_select_au_binary with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days, where h1=c(0.2,0.4), tp=0.5, #early futility stopping is set at -0.085, and the minimal effect size is 0.1. set.seed(123) stopbound1<-lapply(1:10,function(x){brar_select_au_binary(Pats=10, nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)), enrollrate=0.1,N1=24,armn=2,h=c(0.3,0.3),N2=224,tp=0.5,armlabel=c(1,2), blocksize=4,alpha1=1,beta1=1,alpha2=1,beta2=1,minstart=24,deltaa=-0.01, tpp=0,deltaa1=0.1,side='upper')}) simf<-list() for (xx in 1:10){ if (any(stopbound1[[xx]][24:223,2]<0.01)){ simf[[xx]]<-NA } else{ simf[[xx]]<-stopbound1[[xx]][224,2] } } simf1<-do.call(rbind,simf) sum(is.na(simf1))/10 #1, achieve around 10% futility sum(simf1>0.36,na.rm=TRUE)/10 #0.1 #the selected stopping boundary is 0.36 with an overall upper one-sided type I #error of 0.1, based on 10 simulations. It is recommended to conduct more simulations #(i.e., 1000) to obtain an accurate au.
#brar_select_au_binary with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days, where h1=c(0.2,0.4), tp=0.5, #early futility stopping is set at -0.085, and the minimal effect size is 0.1. set.seed(123) stopbound1<-lapply(1:10,function(x){brar_select_au_binary(Pats=10, nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)), enrollrate=0.1,N1=24,armn=2,h=c(0.3,0.3),N2=224,tp=0.5,armlabel=c(1,2), blocksize=4,alpha1=1,beta1=1,alpha2=1,beta2=1,minstart=24,deltaa=-0.01, tpp=0,deltaa1=0.1,side='upper')}) simf<-list() for (xx in 1:10){ if (any(stopbound1[[xx]][24:223,2]<0.01)){ simf[[xx]]<-NA } else{ simf[[xx]]<-stopbound1[[xx]][224,2] } } simf1<-do.call(rbind,simf) sum(is.na(simf1))/10 #1, achieve around 10% futility sum(simf1>0.36,na.rm=TRUE)/10 #0.1 #the selected stopping boundary is 0.36 with an overall upper one-sided type I #error of 0.1, based on 10 simulations. It is recommended to conduct more simulations #(i.e., 1000) to obtain an accurate au.
brar_select_au_known_var
involves selecting au in Bayesian Response-Adaptive Randomization with a control group
for continuous endpoints with known variance in trials with two to five arms. The conjugate prior distributions follow
Normal () distributions and can be specified individually for each arm.
brar_select_au_known_var( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, N2, tp, armlabel, blocksize, mean, sd, minstart, deltaa, tpp, deltaa1, mean10 = 0, mean20 = mean10, mean30 = mean10, mean40 = mean10, mean50 = mean10, sd10 = 1, sd20 = sd10, sd30 = sd10, sd40 = sd10, sd50 = sd10, n10 = 1, n20 = n10, n30 = n10, n40 = n10, n50 = n10, side, output = NULL, ... )
brar_select_au_known_var( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, N2, tp, armlabel, blocksize, mean, sd, minstart, deltaa, tpp, deltaa1, mean10 = 0, mean20 = mean10, mean30 = mean10, mean40 = mean10, mean50 = mean10, sd10 = 1, sd20 = sd10, sd30 = sd10, sd40 = sd10, sd50 = sd10, n10 = 1, n20 = n10, n30 = n10, n40 = n10, n50 = n10, side, output = NULL, ... )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
armn |
number of total arms in the trial. |
N2 |
maximal sample size for the trial. |
tp |
tuning parameter. Some commonly used numbers are 0.5, 1 and n/2N. |
armlabel |
a vector of treatment labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
blocksize |
size of block used for equal randomization regarding participants in the 'initialization' period. Recommend to be an even multiple of the number of total arms. |
mean |
a vector of means in hypotheses, for example, as c(10,10) where 10 stands for the mean in both groups. Another example is c(10,12) where 10 and 12 stand for the mean for the control and the treatment group, respectively. |
sd |
a vector of standard deviations in hypotheses, for example, as c(2,2) where 2 stands for the standard deviation in both groups. Another example is c(1,2) where 1 and 2 stand for the standard deviation for the control and the treatment group, respectively. |
minstart |
a specified number of participants when one starts to check decision rules. |
deltaa |
a vector of minimal effect expected to be observed for early futility stopping in
each arm is approximately |
tpp |
indicator of |
deltaa1 |
a vector of pre-specified minimal effect size expected to be observed at the final stage
for each arm. The length of this parameter is |
mean10 , sd10
|
prior mean and sd in |
mean20 , sd20
|
prior mean and sd in |
mean30 , sd30
|
prior mean and sd in |
mean40 , sd40
|
prior mean and sd in |
mean50 , sd50
|
prior mean and sd in |
n10 |
explicit prior n of arm 1 in the trial, which stands for the control. Default value is set to 1. |
n20 |
explicit prior n of arm 2 in the trial. Default value is set to |
n30 |
explicit prior n of arm 3 in the trial. Default value is set to |
n40 |
explicit prior n of arm 4 in the trial. Default value is set to |
n50 |
explicit prior n of arm 5 in the trial. Default value is set to |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
output |
control the output of brar_select_au_binary. If the user does not specify anything, the function returns the entire dataset used to select the stopping boundary for each iteration. If the user specifies 'B', the function only returns the selected stopping boundary for each iteration. |
... |
additional arguments to be passed to |
This function generates a data set or a value in one iteration for selecting the appropriate au using Bayesian
response-adaptive randomization with a control group under null hypotheses with no delay and delayed scenarios.
The function can handle trials with up to 5 arms for continuous outcomes with known variances. This function uses the formula
with
side
equals to 'upper',
and
with
side
equals to 'lower', utilizing available data at each step.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
A list of results generated from formula at each step.
Note that before final stage of the trial, test statistics is calculated from
deltaa
, and test statistics is
calculated from deltaa1
at the final stage.
Wathen J, Thall P (2017). “A simulation study of outcome adaptive randomization in multi-arm clinical trials.” Clinical Trials, 14, 174077451769230. doi:10.1177/1740774517692302.
#brar_select_au_known_var with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days, where mean=c(8.9/100,8.74/100,8.74/100), #sd=c(0.009,0.009,0.009), tp=0.5 and the minimal effect size is 0. set.seed(789) stopbound1<-lapply(1:10,function(x){ brar_select_au_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.1, N1=21,armn=3, N2=189,tp=0.5,armlabel=c(1,2,3),blocksize=6,mean=c((8.9/100+8.74/100+8.74/100)/3, (8.9/100+8.74/100+8.74/100)/3,(8.9/100+8.74/100+8.74/100)/3), sd=c(0.009,0.009,0.009),minstart=21,deltaa=c(0,0.001),tpp=0,deltaa1=c(0,0), mean10=0.09,mean20=0.09,mean30=0.09, sd10=0.01,sd20=0.01,sd30=0.01,n10=1,n20=1, n30=1,side='lower')}) simf<-list() simf1<-list() for (xx in 1:10){ if (any(stopbound1[[xx]][21:188,2]<0.01)){ simf[[xx]]<-NA } else{ simf[[xx]]<-stopbound1[[xx]][189,2] } if (any(stopbound1[[xx]][21:188,3]<0.01)){ simf1[[xx]]<-NA } else{ simf1[[xx]]<-stopbound1[[xx]][189,3] } } simf2<-do.call(rbind,simf) sum(is.na(simf2)) #1, achieve around 10% futility simf3<-do.call(rbind,simf1) sum(is.na(simf3)) #1, achieve around 10% futility stopbound1a<-cbind(simf2,simf3) stopbound1a[is.na(stopbound1a)] <- 0 sum(stopbound1a[,1]>0.973 | stopbound1a[,2]>0.973)/10 #0.1 #the selected stopping boundary is 0.973 with an overall lower one-sided type I #error of 0.1, based on 10 simulations. Because it is under the permutation null hypothesis, #the selected deltaa should be an average of 0 and 0.001 which is 0.0005, although #deltaa could be close to each other with larger simulation numbers. #It is recommended to conduct more simulations (i.e., 1000) to obtain an accurate deltaa and au. #As the simulation number increases, the choice of deltaa could be consistent for comparisons #of each arm to the control.
#brar_select_au_known_var with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days, where mean=c(8.9/100,8.74/100,8.74/100), #sd=c(0.009,0.009,0.009), tp=0.5 and the minimal effect size is 0. set.seed(789) stopbound1<-lapply(1:10,function(x){ brar_select_au_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.1, N1=21,armn=3, N2=189,tp=0.5,armlabel=c(1,2,3),blocksize=6,mean=c((8.9/100+8.74/100+8.74/100)/3, (8.9/100+8.74/100+8.74/100)/3,(8.9/100+8.74/100+8.74/100)/3), sd=c(0.009,0.009,0.009),minstart=21,deltaa=c(0,0.001),tpp=0,deltaa1=c(0,0), mean10=0.09,mean20=0.09,mean30=0.09, sd10=0.01,sd20=0.01,sd30=0.01,n10=1,n20=1, n30=1,side='lower')}) simf<-list() simf1<-list() for (xx in 1:10){ if (any(stopbound1[[xx]][21:188,2]<0.01)){ simf[[xx]]<-NA } else{ simf[[xx]]<-stopbound1[[xx]][189,2] } if (any(stopbound1[[xx]][21:188,3]<0.01)){ simf1[[xx]]<-NA } else{ simf1[[xx]]<-stopbound1[[xx]][189,3] } } simf2<-do.call(rbind,simf) sum(is.na(simf2)) #1, achieve around 10% futility simf3<-do.call(rbind,simf1) sum(is.na(simf3)) #1, achieve around 10% futility stopbound1a<-cbind(simf2,simf3) stopbound1a[is.na(stopbound1a)] <- 0 sum(stopbound1a[,1]>0.973 | stopbound1a[,2]>0.973)/10 #0.1 #the selected stopping boundary is 0.973 with an overall lower one-sided type I #error of 0.1, based on 10 simulations. Because it is under the permutation null hypothesis, #the selected deltaa should be an average of 0 and 0.001 which is 0.0005, although #deltaa could be close to each other with larger simulation numbers. #It is recommended to conduct more simulations (i.e., 1000) to obtain an accurate deltaa and au. #As the simulation number increases, the choice of deltaa could be consistent for comparisons #of each arm to the control.
brar_select_au_unknown_var
involves selecting au in Bayesian Response-Adaptive Randomization with a control group
for continuous endpoints with unknown variance in trials with two to five arms. The conjugate prior distributions follow
Normal-Inverse-Gamma (NIG) ()
distributions and can be specified individually for each arm.
brar_select_au_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, N2, tp, armlabel, blocksize, mean, sd, minstart, deltaa, tpp, deltaa1, side, output = NULL, V01, a01, b01, m01, V02 = V01, V03 = V01, V04 = V01, V05 = V01, a02 = a01, a03 = a01, a04 = a01, a05 = a01, b02 = b01, b03 = b01, b04 = b01, b05 = b01, m02 = m01, m03 = m01, m04 = m01, m05 = m01, ... )
brar_select_au_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, N2, tp, armlabel, blocksize, mean, sd, minstart, deltaa, tpp, deltaa1, side, output = NULL, V01, a01, b01, m01, V02 = V01, V03 = V01, V04 = V01, V05 = V01, a02 = a01, a03 = a01, a04 = a01, a05 = a01, b02 = b01, b03 = b01, b04 = b01, b05 = b01, m02 = m01, m03 = m01, m04 = m01, m05 = m01, ... )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
armn |
number of total arms in the trial. |
N2 |
maximal sample size for the trial. |
tp |
tuning parameter. Some commonly used numbers are 0.5, 1 and n/2N. |
armlabel |
a vector of treatment labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
blocksize |
size of block used for equal randomization regarding participants in the 'initialization' period. Recommend to be an even multiple of the number of total arms. |
mean |
a vector of means in hypotheses, for example, as c(10,10) where 10 stands for the mean in both groups. Another example is c(10,12) where 10 and 12 stand for the mean for the control and the other treatment group, respectively. |
sd |
a vector of standard deviations in hypotheses, for example, as c(2,2) where 2 stands for the standard deviation in both groups. Another example is c(1,2) where 1 and 2 stand for the standard deviation for the control and the other treatment group, respectively. |
minstart |
a specified number of participants when one starts to check decision rules. |
deltaa |
a vector of minimal effect expected to be observed for early futility stopping in
each arm is approximately |
tpp |
indicator of |
deltaa1 |
a vector of pre-specified minimal effect size expected to be observed at the final stage
for each arm. The length of this parameter is |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
output |
control the output of brar_select_au_binary. If the user does not specify anything, the function returns the entire dataset used to select the stopping boundary for each iteration. If the user specifies 'B', the function only returns the selected stopping boundary for each iteration. |
V01 , a01 , b01 , m01
|
prior parameters m, V, a, b in |
V02 , a02 , b02 , m02
|
prior parameters m, V, a, b in |
V03 , a03 , b03 , m03
|
prior parameters m, V, a, b in |
V04 , a04 , b04 , m04
|
prior parameters m, V, a, b in |
V05 , a05 , b05 , m05
|
prior parameters m, V, a, b in |
... |
additional arguments to be passed to |
This function generates a data set or a value in one iteration for selecting the appropriate au using Bayesian
response-adaptive randomization with a control group under null hypotheses with no delay and delayed scenarios.
The function can handle trials with up to 5 arms for continuous outcomes with unknown variances. This function uses the formula
with
side
equals to 'upper',
and
with
side
equals to 'lower', utilizing available data at each step.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
A list of results generated from formula at each step.
Note that before final stage of the trial, test statistics is calculated from
deltaa
, and test statistics is
calculated from deltaa1
at the final stage.
Wathen J, Thall P (2017). “A simulation study of outcome adaptive randomization in multi-arm clinical trials.” Clinical Trials, 14, 174077451769230. doi:10.1177/1740774517692302.
#brar_select_au_unknown_var with delayed responses follow a normal distribution with #a mean of 60 days and a standard deviation of 3 days, where #mean=c((9.1/100+8.74/100+8.74/100)/3,(9.1/100+8.74/100+8.74/100)/3, #(9.1/100+8.74/100+8.74/100)/3),sd=c(0.009,0.009,0.009),tp=1 and #the minimal effect size is 0. All arms have the same prior distributions. set.seed(789) stopbound1<-lapply(1:5,function(x){ brar_select_au_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)), enrollrate=0.1, N1=48, armn=3, N2=480, tp=1, armlabel=c(1,2,3), blocksize=6, mean=c((9.1/100+8.74/100+8.74/100)/3, (9.1/100+8.74/100+8.74/100)/3,(9.1/100+8.74/100+8.74/100)/3) , sd=c(0.009,0.009,0.009),minstart=48, deltaa=c(-0.0003,-0.00035), tpp=0, deltaa1=c(0,0),V01=1/2,a01=0.3,m01=9/100,b01=0.00001,side='lower') }) simf<-list() simf1<-list() for (xx in 1:5){ if (any(stopbound1[[xx]][48:479,2]<0.01)){ simf[[xx]]<-NA } else{ simf[[xx]]<-stopbound1[[xx]][480,2] } if (any(stopbound1[[xx]][48:479,3]<0.01)){ simf1[[xx]]<-NA } else{ simf1[[xx]]<-stopbound1[[xx]][480,3] } } simf2<-do.call(rbind,simf) sum(is.na(simf2)) #1, achieve around 20% futility simf3<-do.call(rbind,simf1) sum(is.na(simf3)) #1, achieve around 20% futility stopbound1a<-cbind(simf2,simf3) stopbound1a[is.na(stopbound1a)] <- 0 sum(stopbound1a[,1]>0.85 | stopbound1a[,2]>0.85)/5 #0.2 #the selected stopping boundary is 0.85 with an overall lower one-sided type #I error of 0.2, based on 5 simulations. Because it is under the permutation null hypothesis, #the selected deltaa should be an average of -0.0003 and -0.00035 which is -0.000325. #It is recommended to conduct more simulations (i.e., 1000) #to obtain an accurate deltaa and au. As the simulation number increases, the #choice of deltaa could be consistent for comparisons of each arm to the control.
#brar_select_au_unknown_var with delayed responses follow a normal distribution with #a mean of 60 days and a standard deviation of 3 days, where #mean=c((9.1/100+8.74/100+8.74/100)/3,(9.1/100+8.74/100+8.74/100)/3, #(9.1/100+8.74/100+8.74/100)/3),sd=c(0.009,0.009,0.009),tp=1 and #the minimal effect size is 0. All arms have the same prior distributions. set.seed(789) stopbound1<-lapply(1:5,function(x){ brar_select_au_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)), enrollrate=0.1, N1=48, armn=3, N2=480, tp=1, armlabel=c(1,2,3), blocksize=6, mean=c((9.1/100+8.74/100+8.74/100)/3, (9.1/100+8.74/100+8.74/100)/3,(9.1/100+8.74/100+8.74/100)/3) , sd=c(0.009,0.009,0.009),minstart=48, deltaa=c(-0.0003,-0.00035), tpp=0, deltaa1=c(0,0),V01=1/2,a01=0.3,m01=9/100,b01=0.00001,side='lower') }) simf<-list() simf1<-list() for (xx in 1:5){ if (any(stopbound1[[xx]][48:479,2]<0.01)){ simf[[xx]]<-NA } else{ simf[[xx]]<-stopbound1[[xx]][480,2] } if (any(stopbound1[[xx]][48:479,3]<0.01)){ simf1[[xx]]<-NA } else{ simf1[[xx]]<-stopbound1[[xx]][480,3] } } simf2<-do.call(rbind,simf) sum(is.na(simf2)) #1, achieve around 20% futility simf3<-do.call(rbind,simf1) sum(is.na(simf3)) #1, achieve around 20% futility stopbound1a<-cbind(simf2,simf3) stopbound1a[is.na(stopbound1a)] <- 0 sum(stopbound1a[,1]>0.85 | stopbound1a[,2]>0.85)/5 #0.2 #the selected stopping boundary is 0.85 with an overall lower one-sided type #I error of 0.2, based on 5 simulations. Because it is under the permutation null hypothesis, #the selected deltaa should be an average of -0.0003 and -0.00035 which is -0.000325. #It is recommended to conduct more simulations (i.e., 1000) #to obtain an accurate deltaa and au. As the simulation number increases, the #choice of deltaa could be consistent for comparisons of each arm to the control.
Convert parameters from a Normal-Inverse-Chi-Squared distribution to a Normal-Inverse-Gamma distribution.
convert_chisq_to_gamma(cpar)
convert_chisq_to_gamma(cpar)
cpar |
a list of parameters including mu, kappa, nu, sigsq from a Normal-Chi-Squared distribution. |
This function convert parameters from a Normal-Inverse-Chi-Squared
()
distribution to a Normal-Inverse-Gamma
(
)
distribution.
a list of parameters including m, V, a, b from a Normal-Inverse-Gamma distribution.
Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.
convert_chisq_to_gamma(list(mu=0.091,kappa=2,nu=1,sigsq=4e-05))
convert_chisq_to_gamma(list(mu=0.091,kappa=2,nu=1,sigsq=4e-05))
Convert parameters from a Normal-Inverse-Gamma distribution to a Normal-Inverse-Chi-Squared distribution.
convert_gamma_to_chisq(gpar)
convert_gamma_to_chisq(gpar)
gpar |
a list of parameters including m, V, a, b from a Normal-Inverse-Gamma distribution. |
This function convert parameters from a Normal-Inverse-Gamma
()
distribution to a Normal-Inverse-Chi-Squared
(
)
distribution.
a list of parameters including mu, kappa, nu, sigsq from a Normal-Inverse-Chi-Squared distribution.
Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.
convert_gamma_to_chisq(list(V=1/2,a=0.5,m=9.1/100,b=0.00002))
convert_gamma_to_chisq(list(V=1/2,a=0.5,m=9.1/100,b=0.00002))
dabcd_max_power
can be used for doubly adaptive biased coin design with maximal power
strategy for binary outcomes, targeting generalized Neyman allocation and generalized RSIHR allocation. The return
of this function is a vector of allocation probabilities to each arm, with the pre-specified number of participants in the trial.
dabcd_max_power(NN, Ntotal1, armn, BB, type, dabcd = FALSE, gamma = 2)
dabcd_max_power(NN, Ntotal1, armn, BB, type, dabcd = FALSE, gamma = 2)
NN |
a vector representing the number of participants with success results for each arm estimated from the current data. |
Ntotal1 |
a vector representing the total number of participants for each arm estimated from the current data. |
armn |
number of total arms in the trial. |
BB |
the minimal allocation probability for each arm, which is within the
range of |
type |
allocation type, with choices from 'RSIHR' and 'Neyman'. |
dabcd |
an indicator of whether to apply Hu & Zhang's formula ((Hu and Zhang 2004)), with choices from FALSE and TRUE. TRUE represents allocation probabilities calculated using Hu & Zhang's formula; FALSE represents allocation probabilities calculated before applying Hu & Zhang's formula. Default value is set to FALSE. |
gamma |
tuning parameter in Hu & Zhang's formula ((Hu and Zhang 2004)). When |
The function simulates allocation probabilities for doubly adaptive biased coin design with maximal power strategy targeting
generalized Neyman allocation with 2-5 arms which is provided in (Tymofyeyev et al. 2007) or
generalized RSIHR allocation with 2-3 arms which is provided in (Jeon and Feifang 2010), with modifications for typos
in (Sabo and Bello 2016). All of those methods are not smoothed. The output of this function is based on Hu \&
Zhang's formula (Hu and Zhang 2004).
With more than two armd the one-sided nominal level of each test is alphaa
divided by arm*(arm-1)/2
; a Bonferroni correction.
A vector of allocation probabilities to each arm.
Chuyao Xu, Thomas Lumley, Alain Vandal
Hu F, Zhang L (2004). “Asymptotic Properties of Doubly Adaptive Biased Coin Designs for Multitreatment Clinical Trials.” The Annals of Statistics, 32(1), 268–301. Tymofyeyev Y, Rosenberger WF, Hu F (2007). “Implementing Optimal Allocation in Sequential Binary Response Experiments.” Journal of the American Statistical Association, 102(477), 224-234. doi:10.1198/016214506000000906. Jeon Y, Feifang H (2010). “Optimal Adaptive Designs for Binary Response Trials With Three Treatments.” Statistics in Biopharmaceutical Research, 2, 310-318. doi:10.1198/sbr.2009.0056. Sabo R, Bello G (2016). “Optimal and lead-in adaptive allocation for binary outcomes: a comparison of Bayesian methodologies.” Communications in Statistics - Theory and Methods, 46.
dabcd_max_power(NN=c(54,67,85,63,70),Ntotal1=c(100,88,90,94,102),armn=5,BB=0.2, type='Neyman') dabcd_max_power(NN=c(54,67,85,63),Ntotal1=c(100,88,90,94),armn=4,BB=0.2, type='Neyman')
dabcd_max_power(NN=c(54,67,85,63,70),Ntotal1=c(100,88,90,94,102),armn=5,BB=0.2, type='Neyman') dabcd_max_power(NN=c(54,67,85,63),Ntotal1=c(100,88,90,94),armn=4,BB=0.2, type='Neyman')
dabcd_min_var
can be used for doubly adaptive biased coin design with minimal variance
strategy for binary outcomes, targeting generalized Neyman allocation and generalized RSIHR allocation. The return
of this function is a vector of allocation probabilities to each arm, with the pre-specified number of participants in the trial.
dabcd_min_var(NN, Ntotal1, armn, type, dabcd = FALSE, gamma = 2)
dabcd_min_var(NN, Ntotal1, armn, type, dabcd = FALSE, gamma = 2)
NN |
a vector representing the number of participants with success results for each arm estimated from the current data . |
Ntotal1 |
a vector representing the total number of participants for each arm estimated from the current data. |
armn |
number of total arms in the trial. |
type |
allocation type, with choices from 'RSIHR' and 'Neyman'. |
dabcd |
an indicator of whether to apply Hu & Zhang's formula ((Hu and Zhang 2004)), with choices from FALSE and TRUE. TRUE represents allocation probabilities calculated using Hu & Zhang's formula; FALSE represents allocation probabilities calculated before applying Hu & Zhang's formula. Default value is set to FALSE. |
gamma |
tuning parameter in Hu & Zhang's formula ((Hu and Zhang 2004)). When |
The function simulates allocation probabilities for doubly adaptive biased coin design with minimal variance strategy targeting
generalized Neyman allocation and generalized RSIHR allocation with 2-5 arms. The output of this function is based on Hu \&
Zhang's formula (Hu and Zhang 2004).
With more than two armd the one-sided nominal level of each test is alphaa
divided by arm*(arm-1)/2
; a Bonferroni correction.
A vector of allocation probabilities to each arm.
Chuyao Xu, Thomas Lumley, Alain Vandal
Hu F, Zhang L (2004). “Asymptotic Properties of Doubly Adaptive Biased Coin Designs for Multitreatment Clinical Trials.” The Annals of Statistics, 32(1), 268–301.
dabcd_min_var(NN=c(54,67,85,63,70),Ntotal1=c(100,88,90,94,102),armn=5, type='Neyman') dabcd_min_var(NN=c(54,67,85,63),Ntotal1=c(100,88,90,94),armn=4,type='RSIHR')
dabcd_min_var(NN=c(54,67,85,63,70),Ntotal1=c(100,88,90,94,102),armn=5, type='Neyman') dabcd_min_var(NN=c(54,67,85,63),Ntotal1=c(100,88,90,94),armn=4,type='RSIHR')
Function for simulating cut-off values at the final stage using the forward-looking Gittins Index rule
and the controlled forward-looking Gittins Index rule for binary outcomes in trials with 2-5 arms.
The conjugate prior distributions follow Beta () distributions and should be the same for each
arm.
flgi_cut_off_binary( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, I0, K, noRuns2 = 100, Tsize, ptrue, block, rule, ztype )
flgi_cut_off_binary( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, I0, K, noRuns2 = 100, Tsize, ptrue, block, rule, ztype )
Gittinstype |
type of Gittins indices, should be set to 'binary' in this function. |
df |
discount factor which is the multiplier for loss at each additional patient in the future. Available values are 0, 0.5, 0.7, 0.99 and 0.995. The maximal sample size can be up to 2000. |
gittins |
user specified Gittins indices for calculation in this function. Recommend using the
|
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
I0 |
a matrix with K rows and 2 columns, where the numbers inside are equal to the prior parameters, and K is equal to the total number of arms. For example, matrix(1,nrow=2,ncol=2) means that the prior distributions for two-armed trials are beta(1,1); matrix(c(2,3),nrow=2,ncol=2,byrow = TRUE) means that the prior distributions for two-armed trials are beta(2,3). The first column represents the prior of the number of successes, and the second column represents the prior of the number of failures. |
K |
number of total arms in the trial. |
noRuns2 |
number of simulations for simulated allocation probabilities within each block. Default value is set to 100, which is recommended in (Villar et al. 2015). |
Tsize |
maximal sample size for the trial. |
ptrue |
a vector of hypotheses, for example, as c(0.1,0.1) where 0.1 stands for the success probability for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the success probability for the control and the treatment group, respectively. |
block |
block size. |
rule |
rules can be used in this function, with values 'FLGI PM', 'FLGI PD' or 'CFLGI'. 'FLGI PM' stands for making decision based on posterior mean; 'FLGI PD' stands for making decision based on posterior distribution; 'CFLGI' stands for controlled forward-looking Gittins Index. |
ztype |
Z test statistics, with choice of values from 'pooled' and 'unpooled'. |
This function simulates trials using the forward-looking Gittins Index rule and the
controlled forward-looking Gittins Index rule under both no delay and delayed scenarios to obtain
cut-off values at the final stage, with control of type I error. The user is expected to run this function
multiple times to determine a reasonable cut-off value for statistical inference.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
Value of Z test statistics for one trial.
Gittins J, Glazebrook K, Weber R (2011). Multi-Armed Bandit Allocation Indices, 2nd Edition, volume 33. Hoboken,NJ:John Wiley & Sons. ISBN 9780470670026, doi:10.1002/9780470980033.ch8. Villar S, Wason J, Bowden J (2015). “Response-Adaptive Randomization for Multi-arm Clinical Trials Using the Forward Looking Gittins Index Rule.” Biometrics, 71. doi:10.1111/biom.12337.
#The forward-looking Gittins Index rule with delayed responses follow a normal distribution #with a mean of 60 days and a standard deviation of 3 days #One can run the following command 20000 times to obtain the selected cut-off value around 1.9991 #with an upper one-sided type I error 0.025 stopbound1<-lapply(1:20000,function(x){ flgi_cut_off_binary(Gittinstype='Binary',df=0.5,Pats=10, nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)), enrollrate=0.9,I0= matrix(1,nrow=2,ncol=2),K=2,Tsize=992,ptrue=c(0.6,0.6),block=20, rule='FLGI PM',ztype='unpooled')}) stopbound1a<-do.call(rbind,stopbound1) sum(stopbound1a>(1.9991) )/20000 #The selected cut-off value is around 1.9991 with an overall lower one-sided type I #error of 0.025, based on 20000 simulations.
#The forward-looking Gittins Index rule with delayed responses follow a normal distribution #with a mean of 60 days and a standard deviation of 3 days #One can run the following command 20000 times to obtain the selected cut-off value around 1.9991 #with an upper one-sided type I error 0.025 stopbound1<-lapply(1:20000,function(x){ flgi_cut_off_binary(Gittinstype='Binary',df=0.5,Pats=10, nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)), enrollrate=0.9,I0= matrix(1,nrow=2,ncol=2),K=2,Tsize=992,ptrue=c(0.6,0.6),block=20, rule='FLGI PM',ztype='unpooled')}) stopbound1a<-do.call(rbind,stopbound1) sum(stopbound1a>(1.9991) )/20000 #The selected cut-off value is around 1.9991 with an overall lower one-sided type I #error of 0.025, based on 20000 simulations.
Function for simulating cut-off values at the final stage using the forward-looking Gittins Index rule
and the controlled forward-looking Gittins Index rule for continuous outcomes with known variance in trials with
2-5 arms. The conjugate prior distributions follow Normal () distributions and should be the same for each arm.
flgi_cut_off_known_var( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, K, noRuns2, Tsize, block, rule, prior_n, prior_mean, mean, sd, side )
flgi_cut_off_known_var( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, K, noRuns2, Tsize, block, rule, prior_n, prior_mean, mean, sd, side )
Gittinstype |
type of Gittins indices, should be set to 'KV' in this function. |
df |
discount factor which is the multiplier for loss at each additional patient in the future. Available values are 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99 and 0.995. The maximal sample size can be up to 10000. |
gittins |
user specified Gittins indices for calculation in this function. If |
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
K |
number of total arms in the trial. |
noRuns2 |
number of simulations for simulated allocation probabilities within each block. Default value is set to 100, which is recommended in (Villar et al. 2015). |
Tsize |
maximal sample size for the trial. |
block |
block size. |
rule |
rules can be used in this function, with values 'FLGI PM', 'FLGI PD' or 'CFLGI'. 'FLGI PM' stands for making decision based on posterior mean; 'FLGI PD' stands for making decision based on posterior distribution; 'CFLGI' stands for controlled forward-looking Gittins Index. |
prior_n |
a vector representing the number of observations assumed in prior distributions, eg: c(1,1) for a two-armed trial. |
prior_mean |
a vector representing mean of observations assumed in prior distributions, eg: c(0,0,0) for a three-armed trial, rep(0,K) can be used to simplify the process. If a negative effect is expected, adjust the mean to a negative value. |
mean |
a vector of mean hypotheses, for example, c(0.1,0.1) where 0.1 stands for the mean for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the mean for the control and a treatment group, respectively. |
sd |
a vector of standard deviation in hypotheses, for example, as c(0.64,0.64) where 0.64 stands for the standard deviation for both groups. Another example is c(0.64,0.4) where 0.64 and 0.4 stand for the standard deviation for the control and a treatment group, respectively. |
side |
direction of one-sided test with the values of 'upper' or 'lower'. |
This function simulates trials using the forward-looking Gittins Index rule and the
controlled forward-looking Gittins Index rule under both no delay and delayed scenarios to obtain
cut-off values at the final stage, with control of type I error. The user is expected to run this function
multiple times to determine a reasonable cut-off value for statistical inference.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
Value of Z test statistics for one trial.
Williamson SF, Villar S (2019). “A Response‐Adaptive Randomization Procedure for Multi‐Armed Clinical Trials with Normally Distributed Outcomes.” Biometrics, 76. doi:10.1111/biom.13119.
#The forward-looking Gittins Index rule with delayed responses follow a normal #distribution with a mean of 30 days and a standard deviation of 3 days #One can run the following command 20000 times to obtain the selected cut-off #value around -2.1725 with an overall lower one-sided type I error 0.025 stopbound1<-lapply(1:20000,function(x){ flgi_cut_off_known_var(Gittinstype='KV',df=0.995,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.5, K=3,noRuns2=100,Tsize=852,block=20,rule='FLGI PM',prior_n=rep(1,3), prior_mean=rep(9/100,3),mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009), side='lower')}) stopbound1a<-do.call(rbind,stopbound1) sum(stopbound1a<(-2.1725) )/20000 #The selected cut-off value is around -2.1725 with an overall lower one-sided #type I error of 0.025, based on 20000 simulations. #One can run the following command 20000 times to obtain the selected cut-off #value around -2.075 with an overall lower one-sided type I error 0.025 stopbound1<-lapply(1:20000,function(x){ flgi_cut_off_known_var(Gittinstype='KV',df=0.995,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.1, K=3,noRuns2=100,Tsize=852,block=20,rule='CFLGI',prior_n=rep(1,3), prior_mean=rep(9/100,3),mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009), side='lower')}) stopbound1a<-do.call(rbind,stopbound1) sum(stopbound1a<(-2.075) )/20000 #The selected cut-off value is around -2.075 with an overall lower one-sided type I #error of 0.025, based on 20000 simulations.
#The forward-looking Gittins Index rule with delayed responses follow a normal #distribution with a mean of 30 days and a standard deviation of 3 days #One can run the following command 20000 times to obtain the selected cut-off #value around -2.1725 with an overall lower one-sided type I error 0.025 stopbound1<-lapply(1:20000,function(x){ flgi_cut_off_known_var(Gittinstype='KV',df=0.995,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.5, K=3,noRuns2=100,Tsize=852,block=20,rule='FLGI PM',prior_n=rep(1,3), prior_mean=rep(9/100,3),mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009), side='lower')}) stopbound1a<-do.call(rbind,stopbound1) sum(stopbound1a<(-2.1725) )/20000 #The selected cut-off value is around -2.1725 with an overall lower one-sided #type I error of 0.025, based on 20000 simulations. #One can run the following command 20000 times to obtain the selected cut-off #value around -2.075 with an overall lower one-sided type I error 0.025 stopbound1<-lapply(1:20000,function(x){ flgi_cut_off_known_var(Gittinstype='KV',df=0.995,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.1, K=3,noRuns2=100,Tsize=852,block=20,rule='CFLGI',prior_n=rep(1,3), prior_mean=rep(9/100,3),mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009), side='lower')}) stopbound1a<-do.call(rbind,stopbound1) sum(stopbound1a<(-2.075) )/20000 #The selected cut-off value is around -2.075 with an overall lower one-sided type I #error of 0.025, based on 20000 simulations.
Function for simulating cut-off values at the final stage using the forward-looking Gittins Index rule
and the controlled forward-looking Gittins Index rule for continuous outcomes with known variance in trials with
2-5 arms. The prior distributions follow Normal-Inverse-Gamma (NIG) ()
distributions and should be the same for each arm.
flgi_cut_off_unknown_var( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, K, noRuns2, Tsize, block, rule, prior_n, prior_mean1, prior_sd1, mean, sd, side )
flgi_cut_off_unknown_var( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, K, noRuns2, Tsize, block, rule, prior_n, prior_mean1, prior_sd1, mean, sd, side )
Gittinstype |
type of Gittins indices, should be set to 'UNKV' in this function |
df |
discount factor which is the multiplier for loss at each additional patient in the future. Available values are 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99 and 0.995. The maximal sample size can be up to 10000. |
gittins |
user specified Gittins indices for calculation in this function. If |
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
K |
number of total arms in the trial. |
noRuns2 |
number of simulations for simulated allocation probabilities within each block. Default value is set to 100 times, which is recommended in Villar et al., 2015. |
Tsize |
maximal sample size for the trial. |
block |
block size. |
rule |
rules can be used in this function, with values 'FLGI PM', 'FLGI PD' or 'CFLGI'. 'FLGI PM' stands for making decision based on posterior mean; 'FLGI PD' stands for making decision based on posterior distribution; 'CFLGI' stands for controlled forward-looking Gittins Index. |
prior_n |
a vector representing the number of observations assumed in prior distribution, eg: c(1,1) for a two-armed trial. |
prior_mean1 |
a vector representing mean of observations assumed in prior distributions, eg: c(0,0,0) for a three-armed trial, rep(0,K) can be used to simplify the process. If a negative effect is expected, adjust the mean to a negative value. |
prior_sd1 |
a vector representing the standard deviation of observations assumed in prior distribution, eg: rep(1,3) for a three-armed trial. |
mean |
a vector of mean hypotheses, for example, as c(0.1,0.1) where 0.1 stands for the mean for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the mean for the control and a treatment group, respectively. |
sd |
a vector of standard deviation hypotheses, for example, as c(0.64,0.64) where 0.64 stands for the standard deviation for both groups. Another example is c(0.64,0.4) where 0.64 and 0.4 stand for the standard deviation for the control and a treatment group, respectively. |
side |
direction of one-sided test with the values of 'upper' or 'lower'. |
This function simulates trials using the forward-looking Gittins Index rule and the
controlled forward-looking Gittins Index rule under both no delay and delayed scenarios to obtain
cut-off values at the final stage, with control of type I error. The user is expected to run this function
multiple times to determine a reasonable cut-off value for statistical inference.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
Value of T test statistics for one trial.
Williamson SF, Villar S (2019). “A Response‐Adaptive Randomization Procedure for Multi‐Armed Clinical Trials with Normally Distributed Outcomes.” Biometrics, 76. doi:10.1111/biom.13119.
#The forward-looking Gittins Index rule with delayed responses follow a normal #distribution with a mean of 60 days and a standard deviation of 3 days #One can run the following command 20000 times to obtain the selected cut-off #value around -1.9298 with an overall lower one-sided type I error 0.025 stopbound1<-lapply(1:20000,function(x){ flgi_cut_off_unknown_var(Gittinstype='UNKV',df=0.5,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)),enrollrate=0.9, K=3,noRuns2=100,Tsize=852,block=20,rule='FLGI PM',prior_n=rep(2,3), prior_mean1=rep(9/100,3),prior_sd1=rep(0.006324555,3), mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009),side='lower')}) stopbound1a<-do.call(rbind,stopbound1) sum(stopbound1a<(-1.9298) )/20000 #The selected cut-off value is around -1.9298 with an overall lower one-sided #type I error of 0.025, based on 20000 simulations.
#The forward-looking Gittins Index rule with delayed responses follow a normal #distribution with a mean of 60 days and a standard deviation of 3 days #One can run the following command 20000 times to obtain the selected cut-off #value around -1.9298 with an overall lower one-sided type I error 0.025 stopbound1<-lapply(1:20000,function(x){ flgi_cut_off_unknown_var(Gittinstype='UNKV',df=0.5,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)),enrollrate=0.9, K=3,noRuns2=100,Tsize=852,block=20,rule='FLGI PM',prior_n=rep(2,3), prior_mean1=rep(9/100,3),prior_sd1=rep(0.006324555,3), mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009),side='lower')}) stopbound1a<-do.call(rbind,stopbound1) sum(stopbound1a<(-1.9298) )/20000 #The selected cut-off value is around -1.9298 with an overall lower one-sided #type I error of 0.025, based on 20000 simulations.
Gittins
can provide Gittins indices for binary reward processes
and normal reward processes with known and unknown variance for certain discount factors.
Binary reward process can handle scenarios with up to 2000 participants in a trial, while
normal reward process can handle scenarios with up to 10000 participants in a trial.
Gittins(Gittinstype, df)
Gittins(Gittinstype, df)
Gittinstype |
type of Gittins indices, with choices from 'Binary', 'UNKV' and 'KV'. 'Binary' represents binary outcomes, 'UNKV' and 'KV' represent continuous outcomes with known and unknown variance respectively. |
df |
discount factor which is the multiplier for loss at each additional patient in the future.
Available values are 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99 and 0.995 for |
Gittins indices for binary outcomes are generated from bmab_gi_multiple_ab
function from gittins
package with
time horizon 100, 100, 100, 1000, 1000 for discount factor 0, 0.5, 0.7, 0.99 and 0.995 respectively.
Gittins indices for continuous outcomes are obtained by linear extrapolation using Table 8.1 and Table 8.3
in (Gittins et al. 2011).
A vector of Gittins indices for Gittinstype
in 'UNKV' and 'KV'. A matrix of
Gittins indices for Gittinstype
in 'Binary'.
Gittins J, Glazebrook K, Weber R (2011). Multi-Armed Bandit Allocation Indices, 2nd Edition, volume 33. Hoboken,NJ:John Wiley & Sons. ISBN 9780470670026, doi:10.1002/9780470980033.ch8.
Gittins(Gittinstype='KV',df=0.5) Gittins(Gittinstype='Binary',df=0.995) Gittins(Gittinstype='UNKV',df=0.99)
Gittins(Gittinstype='KV',df=0.5) Gittins(Gittinstype='Binary',df=0.995) Gittins(Gittinstype='UNKV',df=0.99)
Calculate the futility stopping probability in Bayesian response-adaptive randomization with
a control group using the Thall Wathen method for binary outcomes. The conjugate prior distributions follow
Beta (
) distributions and can be specified individually for each treatment group.
pgreater_beta(a1, b1, a2, b2, delta, side, ...)
pgreater_beta(a1, b1, a2, b2, delta, side, ...)
a1 , b1
|
|
a2 , b2
|
|
delta |
expected difference in success probabilities between the control group and the treatment group. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to stats::integrate() (such as rel.tol) from this function. |
This function calculates the results of for
side
equals to
'upper' and the results of for
side
equals to 'lower'.
The result indicates the posterior probability of stopping a treatment group due to futility around in Bayesian
response-adaptive randomization with a control arm using Thall
Wathen method, with accumulated results
during the conduct of trials.
a posterior probability of with
side
equals to 'upper';
a posterior probability of with
side
equals to 'lower'.
Wathen J, Thall P (2017). “A simulation study of outcome adaptive randomization in multi-arm clinical trials.” Clinical Trials, 14, 174077451769230. doi:10.1177/1740774517692302.
pgreater_beta(a1=8, b1=10,a2=5, b2=19, delta=0.1, side='upper') pgreater_beta(a1=65, b1=79,a2=58, b2=68, delta=0, side='lower')
pgreater_beta(a1=8, b1=10,a2=5, b2=19, delta=0.1, side='upper') pgreater_beta(a1=65, b1=79,a2=58, b2=68, delta=0, side='lower')
Calculate the futility stopping probability in Bayesian response-adaptive randomization with
a control group using the Thall Wathen method for continuous outcomes with unknown variances. The prior distributions
follow Normal-Inverse-Chi-Squared (NIX) distributions and can be specified individually for each treatment group.
pgreater_NIX(par1, par2, delta = 0, side, ...)
pgreater_NIX(par1, par2, delta = 0, side, ...)
par1 |
current parameters including mu, kappa, nu, sigsq of a Normal-Inverse-Chi-Squared distribution from the control group. |
par2 |
current parameters including mu, kappa, nu, sigsq of a Normal-Inverse-Chi-Squared distribution from the compared treatment group. |
delta |
pre-specified minimal effect size expected to be observed between the control group and the compared treatment group. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to stats::integrate() (such as rel.tol) from this function. |
This function calculates the results of for
side
equals to
'upper' and the results of for
side
equals to 'lower'.
The result indicates the posterior probability of stopping a treatment group due to futility around in Bayesian
response-adaptive randomization with a control arm using Thall
Wathen method, with accumulated results
during the conduct of trials. Parameters used in a Normal-Inverse-Gamma (
)
distribution should be converted to parameters equivalent in a Normal-Inverse-Chi-Squared
(
)
distribution using
convert_gamma_to_chisq
before applying this function.
a posterior probability of with
side
equals to 'upper';
a posterior probability of with
side
equals to 'lower'.
Wathen J, Thall P (2017). “A simulation study of outcome adaptive randomization in multi-arm clinical trials.” Clinical Trials, 14, 174077451769230. doi:10.1177/1740774517692302. Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.
para<-list(V=1/2,a=0.5,m=9.1/100,b=0.00002) par<-convert_gamma_to_chisq(para) set.seed(123451) y1<-rnorm(100,0.091,0.009) par1<-update_par_nichisq(y1, par) set.seed(123452) y2<-rnorm(90,0.09,0.009) par2<-update_par_nichisq(y2, par) pgreater_NIX(par1=par1,par2=par2, side='upper') pgreater_NIX(par1=par1,par2=par2, side='lower')
para<-list(V=1/2,a=0.5,m=9.1/100,b=0.00002) par<-convert_gamma_to_chisq(para) set.seed(123451) y1<-rnorm(100,0.091,0.009) par1<-update_par_nichisq(y1, par) set.seed(123452) y2<-rnorm(90,0.09,0.009) par2<-update_par_nichisq(y2, par) pgreater_NIX(par1=par1,par2=par2, side='upper') pgreater_NIX(par1=par1,par2=par2, side='lower')
Calculate the futility stopping probability in Bayesian response-adaptive randomization with
a control group using the Thall Wathen method for continuous outcomes with known variances. The conjugate prior distributions
follow Normal (
) distributions and can be specified individually for each treatment group.
pgreater_normal( mean1 = NULL, sd1 = NULL, mean2 = NULL, sd2 = NULL, delta = 0, side, ... )
pgreater_normal( mean1 = NULL, sd1 = NULL, mean2 = NULL, sd2 = NULL, delta = 0, side, ... )
mean1 , sd1
|
mean and sd in |
mean2 , sd2
|
mean and sd in |
delta |
pre-specified minimal effect size expected to be observed between the control group and the compared treatment group. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to stats::integrate() (such as rel.tol) from this function. |
This function calculates the results of for
side
equals to
'upper' and the results of for
side
equals to 'lower'.
The result indicates the posterior probability of stopping a treatment group due to futility around in Bayesian
response-adaptive randomization with a control arm using Thall
Wathen method, with accumulated results
during the conduct of trials.
a posterior probability of with
side
equals to 'upper';
a posterior probability of with
side
equals to 'lower'.
Wathen J, Thall P (2017). “A simulation study of outcome adaptive randomization in multi-arm clinical trials.” Clinical Trials, 14, 174077451769230. doi:10.1177/1740774517692302. Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.
pgreater_normal(mean1=0.091,sd1=0.09,mean2=0.097,sd2=0.08,delta=0,side='upper') pgreater_normal(mean1=0.091,sd1=0.09,mean2=0.087,sd2=0.1,delta=0,side='lower')
pgreater_normal(mean1=0.091,sd1=0.09,mean2=0.097,sd2=0.08,delta=0,side='upper') pgreater_normal(mean1=0.091,sd1=0.09,mean2=0.087,sd2=0.1,delta=0,side='lower')
Calculate posterior probability that a particular arm is the best in a trial using Bayesian response-adaptive randomization with
a control group (the Thall Wathen method). The conjugate prior distributions follow Beta (
) distributions
for binary outcomes in each arm and can be specified individually.
pmax_beta( armn, a1 = NULL, b1 = NULL, a2 = NULL, b2 = NULL, a3 = NULL, b3 = NULL, a4 = NULL, b4 = NULL, a5 = NULL, b5 = NULL, side, ... )
pmax_beta( armn, a1 = NULL, b1 = NULL, a2 = NULL, b2 = NULL, a3 = NULL, b3 = NULL, a4 = NULL, b4 = NULL, a5 = NULL, b5 = NULL, side, ... )
armn |
number of arms in the trial with values up to 5. When |
a1 , b1
|
|
a2 , b2
|
|
a3 , b3
|
|
a4 , b4
|
|
a5 , b5
|
|
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to |
This function calculates the results of formula for
side
equals to 'upper' and the results of formula for
side
equals to 'lower'. This function returns the probability that the posterior probability of arm
is maximal or minimal in trials with up to five arms.
a probability that a particular arm is the best in trials up to five arms.
pmax_beta(armn=5,a1=8,b1=10,a2=5,b2=19,a3=8,b3=21, a4=6, b4=35, a5=15, b5=4, side='upper') pmax_beta(armn=4,a1=56,b1=98,a2=25,b2=70,a3=87,b3=107, a4=106, b4=202, side='lower') pmax_beta(armn=3,a1=60,b1=46,a2=55,b2=46,a3=35,b3=36,side='upper')
pmax_beta(armn=5,a1=8,b1=10,a2=5,b2=19,a3=8,b3=21, a4=6, b4=35, a5=15, b5=4, side='upper') pmax_beta(armn=4,a1=56,b1=98,a2=25,b2=70,a3=87,b3=107, a4=106, b4=202, side='lower') pmax_beta(armn=3,a1=60,b1=46,a2=55,b2=46,a3=35,b3=36,side='upper')
Calculate posterior probability that a particular arm is the best in a trial using Bayesian response-adaptive randomization with
a control group (the Thall Wathen method). The conjugate prior distributions follow Normal-Inverse-Chi-Squared (NIX)
distributions for continuous outcomes with unknown variance in each arm and can be specified individually.
pmax_NIX( armn, par1 = NULL, par2 = NULL, par3 = NULL, par4 = NULL, par5 = NULL, side, ... )
pmax_NIX( armn, par1 = NULL, par2 = NULL, par3 = NULL, par4 = NULL, par5 = NULL, side, ... )
armn |
number of arms in the trial with values up to 5. When |
par1 |
a vector of parameters including m, V, a, b for the arm with a Normal-Inverse-Chi-Squared prior to calculate the allocation probability of. |
par2 |
a vector of parameters including m, V, a, b for one of the remaining arms with a Normal-Inverse-Chi-Squared prior. |
par3 |
a vector of parameters including m, V, a, b for one of the remaining arms with a Normal-Inverse-Chi-Squared prior. |
par4 |
a vector of parameters including m, V, a, b for one of the remaining arms with a Normal-Inverse-Chi-Squared prior. |
par5 |
a vector of parameters including m, V, a, b for one of the remaining arms with a Normal-Inverse-Chi-Squared prior. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to |
This function calculates the results of formula for
side
equals to 'upper' and the results of formula for
side
equals to 'lower'. This function returns the probability that the posterior probability of arm
is maximal or minimal in trials with up to five arms. Parameters used in a Normal-Inverse-Gamma
(
)
distribution should be converted to parameters equivalent in a Normal-Inverse-Chi-Squared
(
)
distribution using
convert_gamma_to_chisq
before applying this function.
a probability that a particular arm is the best in trials up to five arms.
para<-list(V=1/2,a=0.8,m=9.1,b=1/2) par<-convert_gamma_to_chisq(para) set.seed(123451) y1<-rnorm(100,9.1,1) par11<-update_par_nichisq(y1, par) set.seed(123452) y2<-rnorm(90,9,1) par22<-update_par_nichisq(y2, par) set.seed(123453) y3<-rnorm(110,8.92,1) par33<-update_par_nichisq(y3, par) y4<-rnorm(120,8.82,1) par44<-update_par_nichisq(4, par) pmax_NIX(armn=4,par1=par11,par2=par22,par3=par33,par4=par44,side='upper') pmax_NIX(armn=4,par1=par11,par2=par22,par3=par33,par4=par44,side='lower') para<-list(V=1/2,a=0.5,m=9.1/100,b=0.00002) par<-convert_gamma_to_chisq(para) set.seed(123451) y1<-rnorm(100,0.091,0.009) par11<-update_par_nichisq(y1, par) set.seed(123452) y2<-rnorm(90,0.09,0.009) par22<-update_par_nichisq(y2, par) set.seed(123453) y3<-rnorm(110,0.0892,0.009) par33<-update_par_nichisq(y3, par) pmax_NIX(armn=3,par1=par11,par2=par22,par3=par33,side='upper') pmax_NIX(armn=3,par1=par11,par2=par22,par3=par33,side='lower')
para<-list(V=1/2,a=0.8,m=9.1,b=1/2) par<-convert_gamma_to_chisq(para) set.seed(123451) y1<-rnorm(100,9.1,1) par11<-update_par_nichisq(y1, par) set.seed(123452) y2<-rnorm(90,9,1) par22<-update_par_nichisq(y2, par) set.seed(123453) y3<-rnorm(110,8.92,1) par33<-update_par_nichisq(y3, par) y4<-rnorm(120,8.82,1) par44<-update_par_nichisq(4, par) pmax_NIX(armn=4,par1=par11,par2=par22,par3=par33,par4=par44,side='upper') pmax_NIX(armn=4,par1=par11,par2=par22,par3=par33,par4=par44,side='lower') para<-list(V=1/2,a=0.5,m=9.1/100,b=0.00002) par<-convert_gamma_to_chisq(para) set.seed(123451) y1<-rnorm(100,0.091,0.009) par11<-update_par_nichisq(y1, par) set.seed(123452) y2<-rnorm(90,0.09,0.009) par22<-update_par_nichisq(y2, par) set.seed(123453) y3<-rnorm(110,0.0892,0.009) par33<-update_par_nichisq(y3, par) pmax_NIX(armn=3,par1=par11,par2=par22,par3=par33,side='upper') pmax_NIX(armn=3,par1=par11,par2=par22,par3=par33,side='lower')
Calculate posterior probability that a particular arm is the best in a trial using Bayesian response-adaptive randomization with
a control group (the Thall Wathen method). The conjugate prior distributions follow Normal (
) distributions for
continuous outcomes with known variance in each arm and can be specified individually.
pmax_normal( armn, mean1 = NULL, sd1 = NULL, mean2 = NULL, sd2 = NULL, mean3 = NULL, sd3 = NULL, mean4 = NULL, sd4 = NULL, mean5 = NULL, sd5 = NULL, side, ... )
pmax_normal( armn, mean1 = NULL, sd1 = NULL, mean2 = NULL, sd2 = NULL, mean3 = NULL, sd3 = NULL, mean4 = NULL, sd4 = NULL, mean5 = NULL, sd5 = NULL, side, ... )
armn |
number of arms in the trial with values up to 5. When |
mean1 , sd1
|
mean and sd in Normal(mean,sd) for the arm to calculate the allocation probability of. |
mean2 , sd2
|
mean and sd in Normal(mean,sd) for one of the remaining arms. |
mean3 , sd3
|
mean and sd in Normal(mean,sd) for one of the remaining arms. |
mean4 , sd4
|
mean and sd in Normal(mean,sd) for one of the remaining arms. |
mean5 , sd5
|
mean and sd in Normal(mean,sd) for one of the remaining arms. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to |
This function calculates the results of formula for
side
equals to 'upper' and the results of formula for
side
equals to 'lower'. This function returns the probability that the posterior probability of arm
is maximal or minimal in trials with up to five arms.
a probability that a particular arm is the best in trials up to five arms.
pmax_normal(armn=5,mean1=0.8,sd1=0.2,mean2=0.5,sd2=0.1,mean3=0.8, sd3=0.5,mean4=0.6,sd4=0.2,mean5=0.6,sd5=0.2,side='upper') pmax_normal(armn=4,mean1=8,sd1=2,mean2=8.5,sd2=2,mean3=8.3, sd3=1.8,mean4=8.7,sd4=2,side='lower') pmax_normal(armn=3,mean1=80,sd1=20,mean2=50,sd2=10,mean3=80, sd3=15,side='upper')
pmax_normal(armn=5,mean1=0.8,sd1=0.2,mean2=0.5,sd2=0.1,mean3=0.8, sd3=0.5,mean4=0.6,sd4=0.2,mean5=0.6,sd5=0.2,side='upper') pmax_normal(armn=4,mean1=8,sd1=2,mean2=8.5,sd2=2,mean3=8.3, sd3=1.8,mean4=8.7,sd4=2,side='lower') pmax_normal(armn=3,mean1=80,sd1=20,mean2=50,sd2=10,mean3=80, sd3=15,side='upper')
sim_A_optimal_known_var
simulates a trial for continuous endpoints with known variances,
and allocation ratios are fixed.
sim_A_optimal_known_var( Pats, nMax, TimeToOutcome, enrollrate, N2, armn, mean, sd, alphaa = 0.025, armlabel, side )
sim_A_optimal_known_var( Pats, nMax, TimeToOutcome, enrollrate, N2, armn, mean, sd, alphaa = 0.025, armlabel, side )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N2 |
maximal sample size for the trial. |
armn |
number of total arms in the trial. |
mean |
a vector of actual mean for all arms in the trial, with the first one serving as the control group. |
sd |
a vector of actual standard deviation for all arms in the trial, with the first one serving as the control group. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describes how each arm is labeled in a two-armed trial. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function aims to minimize the criteria
and minimize the overall variance of pairwise comparisons. It is generalized Neyman
allocation, specifically designed for continuous endpoints with known variances. With more
than two arms the one-sided nominal level of each test is
alphaa
divided by
arm*(arm-1)/2
; a Bonferroni correction.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_A_optimal_known_var
returns an object of class "aoptimal". An object of class "aoptimal" is a list containing
final decision based on the Z test statistics with 1 stands for selected and 0 stands for not selected,
Z test statistics, the simulated data set and participants accrued for each arm
at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result.
Chuyao Xu, Thomas Lumley, Alain Vandal
Sverdlov O, Rosenberger W (2013). “On Recent Advances in Optimal Allocation Designs in Clinical Trials.” Journal of Statistical Theory and Practice, 7, 753-773. doi:10.1080/15598608.2013.783726.
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a two-armed trial sim_A_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N2=88,armn=2, mean=c(9.1/100,9.1/100),sd=c(0.009,0.009),alphaa=0.025,armlabel = c(1,2),side='lower') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a two-armed trial sim_A_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N2=88,armn=2, mean=c(9.1/100,8.47/100),sd=c(0.009,0.009),alphaa=0.025,armlabel = c(1,2),side='lower')
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a two-armed trial sim_A_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N2=88,armn=2, mean=c(9.1/100,9.1/100),sd=c(0.009,0.009),alphaa=0.025,armlabel = c(1,2),side='lower') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a two-armed trial sim_A_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N2=88,armn=2, mean=c(9.1/100,8.47/100),sd=c(0.009,0.009),alphaa=0.025,armlabel = c(1,2),side='lower')
sim_A_optimal_unknown_var
simulates a trial for continuous endpoints with unknown variances,
and the allocation probabilities change based on results of accumulated participants in the trial.
sim_A_optimal_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, mean, sd, alphaa = 0.025, armlabel, side )
sim_A_optimal_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, mean, sd, alphaa = 0.025, armlabel, side )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
N2 |
maximal sample size for the trial. |
armn |
number of total arms in the trial. |
mean |
a vector of hypotheses of mean for all arms in the trial, with the first one serving as the control group. |
sd |
a vector of hypotheses of standard deviation for all arms in the trial, with the first one serving as the control group. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describes how each arm is labeled in a two-armed trial. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function aims to minimize the criteria
and to minimize the overall variance of pairwise comparisons. It is generalized Neyman
allocation, specifically designed for continuous endpoints with known variances.
With more than two arms the one-sided nominal level of each test is
alphaa
divided by arm*(arm-1)/2
; a Bonferroni correction.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_A_optimal_unknown_var
returns an object of class "aoptimal". An object of class "aoptimal" is a list containing
final decision based on the T test statistics with 1 stands for selected and 0 stands for not selected,
T test statistics, the simulated data set and participants accrued for each arm
at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result.
Chuyao Xu, Thomas Lumley, Alain Vandal
Sverdlov O, Rosenberger W (2013). “On Recent Advances in Optimal Allocation Designs in Clinical Trials.” Journal of Statistical Theory and Practice, 7, 753-773. doi:10.1080/15598608.2013.783726.
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a three-armed trial sim_A_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.1,N1=12,N2=132,armn=3, mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel = c(1,2,3),side='upper') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a three-armed trial sim_A_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.1,N1=12,N2=132,armn=3, mean=c(9.1/100,9.28/100,9.28/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel = c(1,2,3),side='upper')
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a three-armed trial sim_A_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.1,N1=12,N2=132,armn=3, mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel = c(1,2,3),side='upper') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a three-armed trial sim_A_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.1,N1=12,N2=132,armn=3, mean=c(9.1/100,9.28/100,9.28/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel = c(1,2,3),side='upper')
sim_Aa_optimal_known_var
simulates a trial for continuous endpoints with known variances,
and the allocation probabilities are fixed.
sim_Aa_optimal_known_var( Pats, nMax, TimeToOutcome, enrollrate, N2, armn, mean, sd, alphaa = 0.025, armlabel, side )
sim_Aa_optimal_known_var( Pats, nMax, TimeToOutcome, enrollrate, N2, armn, mean, sd, alphaa = 0.025, armlabel, side )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N2 |
maximal sample size for the trial. |
armn |
number of total arms in the trial. |
mean |
a vector of hypotheses of mean for all arms in the trial, with the first one serving as the control group. |
sd |
a vector of hypotheses of standard deviation for allarms in the trial, with the first one serving as the control group. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describes how each arm is labeled in a two-armed trial. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function aims to minimize the criteria
and minimize the overall variance of pairwise comparisons. It is analogous to Neyman
allocation, favoring a higher allocation ratio to the control group. With more than two treatment
groups the one-sided nominal level of each test is
alphaa
divided by arm*(arm-1)/2
; a Bonferroni correction.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_Aa_optimal_known_var
returns an object of class "Aaoptimal". An object of class "Aaoptimal" is a list containing
final decision based on the Z test statistics with 1 stands for selected and 0 stands for not selected,
Z test statistics, the simulated data set and participants accrued for each arm at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result.
Sverdlov O, Rosenberger W (2013). “On Recent Advances in Optimal Allocation Designs in Clinical Trials.” Journal of Statistical Theory and Practice, 7, 753-773. doi:10.1080/15598608.2013.783726.
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a two-armed trial sim_Aa_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N2=88,armn=2, mean=c(9.1/100,9.1/100),sd=c(0.009,0.009),alphaa=0.025,armlabel = c(1,2),side='lower') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a two-armed trial sim_Aa_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N2=88,armn=2, mean=c(9.1/100,8.47/100),sd=c(0.009,0.009),alphaa=0.025,armlabel = c(1,2),side='lower')
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a two-armed trial sim_Aa_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N2=88,armn=2, mean=c(9.1/100,9.1/100),sd=c(0.009,0.009),alphaa=0.025,armlabel = c(1,2),side='lower') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a two-armed trial sim_Aa_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N2=88,armn=2, mean=c(9.1/100,8.47/100),sd=c(0.009,0.009),alphaa=0.025,armlabel = c(1,2),side='lower')
sim_Aa_optimal_unknown_var
simulates a trial for continuous endpoints with unknown variances,
and the allocation probabilities change based on results of accumulated participants in the trial.
sim_Aa_optimal_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, mean, sd, alphaa = 0.025, armlabel, side )
sim_Aa_optimal_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, mean, sd, alphaa = 0.025, armlabel, side )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
N2 |
maximal sample size for the trial. |
armn |
number of total arms in the trial. |
mean |
a vector of hypotheses of mean for all arms in the trial, with the first one serving as the control group. |
sd |
a vector of hypotheses of standard deviation for allarms in the trial, with the first one serving as the control group. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describes how each arm is labeled in a two-armed trial. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function aims to minimize the criteria
and minimize the overall variance of pairwise comparisons. It is analogous to Neyman
allocation, favoring a higher allocation ratio to the control group. With more than two treatment
groups the one-sided nominal level of each test is
alphaa
divided by arm*(arm-1)/2
; a Bonferroni correction.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_Aa_optimal_known_var
returns an object of class "Aaoptimal". An object of class "Aaoptimal" is a list containing
final decision based on the T test statistics with 1 stands for selected and 0 stands for not selected,
T test statistics, the simulated data set and participants accrued for each arm at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result.
Chuyao Xu, Thomas Lumley, Alain Vandal
Sverdlov O, Rosenberger W (2013). “On Recent Advances in Optimal Allocation Designs in Clinical Trials.” Journal of Statistical Theory and Practice, 7, 753-773. doi:10.1080/15598608.2013.783726.
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a three-armed trial sim_Aa_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.1,N1=12,N2=132,armn=3, mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel = c(1,2,3),side='upper') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a three-armed trial sim_Aa_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.1,N1=12,N2=132,armn=3, mean=c(9.1/100,9.28/100,9.28/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel = c(1,2,3),side='upper')
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a three-armed trial sim_Aa_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.1,N1=12,N2=132,armn=3, mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel = c(1,2,3),side='upper') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a three-armed trial sim_Aa_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.1,N1=12,N2=132,armn=3, mean=c(9.1/100,9.28/100,9.28/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel = c(1,2,3),side='upper')
sim_brar_binary
simulate a trial with two to five arms using Bayesian Response-Adaptive
Randomization with a control group for binary outcomes. The conjugate prior distributions follow Beta
() distributions and can be specified individually for each arm.
sim_brar_binary( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, h, au, N2, tp, armlabel, blocksize, alpha1 = 1, beta1 = 1, alpha2 = alpha1, beta2 = beta1, alpha3 = alpha1, beta3 = beta1, alpha4 = alpha1, beta4 = beta1, alpha5 = alpha1, beta5 = beta1, minstart, deltaa, tpp = 0, deltaa1, side, ... )
sim_brar_binary( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, h, au, N2, tp, armlabel, blocksize, alpha1 = 1, beta1 = 1, alpha2 = alpha1, beta2 = beta1, alpha3 = alpha1, beta3 = beta1, alpha4 = alpha1, beta4 = beta1, alpha5 = alpha1, beta5 = beta1, minstart, deltaa, tpp = 0, deltaa1, side, ... )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
armn |
number of total arms in the trial. |
h |
a vector of success probabilities in hypotheses, for example, as c(0.1,0.1) where 0.1 stands for the success probability for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the success probabilities for the control and the treatment group, respectively. |
au |
a vector of cut-off values in the final selection at the end of the trial, with a length equal to the number of arms minus 1. |
N2 |
maximal sample size for the trial. |
tp |
tuning parameter. Some commonly used numbers are 0.5, 1 and n/2N. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
blocksize |
size of block used for equal randomization regarding participants in the 'initialization' period. Recommend to be an even multiple of the number of total arms. |
alpha1 , beta1
|
|
alpha2 , beta2
|
|
alpha3 , beta3
|
|
alpha4 , beta4
|
|
alpha5 , beta5
|
|
minstart |
a specified number of participants when one starts to check decision rules. |
deltaa |
a vector of minimal effect expected to be observed for early futility stopping in
each arm is approximately |
tpp |
indicator of |
deltaa1 |
a vector of pre-specified minimal effect size expected to be observed at the final stage
for each arm. The length of this parameter is |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to |
This function generates a designed trial using Bayesian response-adaptive randomization with
a control group under no delay and delayed scenarios for binary outcomes. The function can handle trials with up to
5 arms. This function uses the formula
with
side
equals to 'upper',
and
with
side
equals to 'lower', utilizing available data at each step.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_brar_binary
returns an object of class "brar". An object of class "brar" is a list containing
final decision, test statistics, the simulated data set and participants accrued for each arm
at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' results. In the final decision, 'Superiorityfinal' refers to the selected arm,
while 'Not Selected' indicates the arm stopped due to futility, and 'Control Selected' denotes the control arm chosen
because other arms did not meet futility criteria before the final stage or were not deemed effective at the final stage.
Note that before final stage of the trial, test statistics is calculated from deltaa
, and test statistics is
calculated from deltaa1
at the final stage.
Wathen J, Thall P (2017). “A simulation study of outcome adaptive randomization in multi-arm clinical trials.” Clinical Trials, 14, 174077451769230. doi:10.1177/1740774517692302.
#sim_brar_binary with delayed responses follow a normal distribution with a mean #of 30 days and a standard deviation of 3 days, where h1=c(0.2,0.4) and tp=0.5. sim_brar_binary(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)), enrollrate=0.1,N1=24,armn=2,h=c(0.2,0.4),au=0.36,N2=224,tp=0.5,armlabel=c(1,2),blocksize=4, alpha1=1,beta1=1,alpha2=1,beta2=1,minstart=24,deltaa=-0.01,tpp=0,deltaa1=0.1,side='upper')
#sim_brar_binary with delayed responses follow a normal distribution with a mean #of 30 days and a standard deviation of 3 days, where h1=c(0.2,0.4) and tp=0.5. sim_brar_binary(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)), enrollrate=0.1,N1=24,armn=2,h=c(0.2,0.4),au=0.36,N2=224,tp=0.5,armlabel=c(1,2),blocksize=4, alpha1=1,beta1=1,alpha2=1,beta2=1,minstart=24,deltaa=-0.01,tpp=0,deltaa1=0.1,side='upper')
sim_brar_known_var
simulate a trial with two to five arms using Bayesian Response-Adaptive
Randomization with a control group for continuous outcomes with known variances. The conjugate prior distributions follow
Normal () distributions and can be specified individually for each arm.
sim_brar_known_var( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, au, N2, tp, armlabel, blocksize, mean, sd, minstart, deltaa, tpp, deltaa1, mean10 = 0, mean20 = mean10, mean30 = mean10, mean40 = mean10, mean50 = mean10, sd10 = 1, sd20 = sd10, sd30 = sd10, sd40 = sd10, sd50 = sd10, n10 = 1, n20 = n10, n30 = n10, n40 = n10, n50 = n10, side, ... )
sim_brar_known_var( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, au, N2, tp, armlabel, blocksize, mean, sd, minstart, deltaa, tpp, deltaa1, mean10 = 0, mean20 = mean10, mean30 = mean10, mean40 = mean10, mean50 = mean10, sd10 = 1, sd20 = sd10, sd30 = sd10, sd40 = sd10, sd50 = sd10, n10 = 1, n20 = n10, n30 = n10, n40 = n10, n50 = n10, side, ... )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
armn |
number of total arms in the trial. |
au |
a vector of cut-off values in the final selection at the end of the trial, with a length equal to the number of arms minus 1. |
N2 |
maximal sample size for the trial. |
tp |
tuning parameter. Some commonly used numbers are 0.5, 1 and n/2N. |
armlabel |
a vector of treatment labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
blocksize |
size of block used for equal randomization regarding participants in the 'initialization' period. Recommend to be an even multiple of the number of total arms. |
mean |
a vector of means in hypotheses, for example, as c(10,10) where 10 stands for the mean in both groups. Another example is c(10,12) where 10 and 12 stand for the mean for the control and the treatment group, respectively. |
sd |
a vector of standard deviations in hypotheses, for example, as c(2,2) where 2 stands for the standard deviation in both groups. Another example is c(1,2) where 1 and 2 stand for the standard deviation for the control and the treatment group, respectively. |
minstart |
a specified number of participants when one starts to check decision rules. |
deltaa |
a vector of minimal effect expected to be observed for early futility stopping in
each arm is approximately |
tpp |
indicator of |
deltaa1 |
a vector of pre-specified minimal effect size expected to be observed at the final stage
for each arm. The length of this parameter is |
mean10 , sd10
|
prior mean and sd in |
mean20 , sd20
|
prior mean and sd in |
mean30 , sd30
|
prior mean and sd in |
mean40 , sd40
|
prior mean and sd in |
mean50 , sd50
|
prior mean and sd in |
n10 |
explicit prior n of arm 1 in the trial, which stands for the control. Default value is set to 1. |
n20 |
explicit prior n of arm 2 in the trial. Default value is set to |
n30 |
explicit prior n of arm 3 in the trial. Default value is set to |
n40 |
explicit prior n of arm 4 in the trial. Default value is set to |
n50 |
explicit prior n of arm 5 in the trial. Default value is set to |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to |
This function generates a designed trial using Bayesian response-adaptive randomization with
a control group under no delay and delayed scenarios for continuous outcomes with known variances. The function can handle trials with up to
5 arms. This function uses the formula
with
side
equals to 'upper',
and
with
side
equals to 'lower', utilizing available data at each step.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_brar_known_var
returns an object of class "brar". An object of class "brar" is a list containing
final decision, test statistics, the simulated data set and participants accrued for each arm
at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' results. In the final decision, 'Superiorityfinal' refers to the selected arm,
while 'Not Selected' indicates the arm stopped due to futility, and 'Control Selected' denotes the control arm chosen
because other arms did not meet futility criteria before the final stage or were not deemed effective at the final stage.
Note that before final stage of the trial, test statistics is calculated from deltaa
, and test statistics is
calculated from deltaa1
at the final stage.
Wathen J, Thall P (2017). “A simulation study of outcome adaptive randomization in multi-arm clinical trials.” Clinical Trials, 14, 174077451769230. doi:10.1177/1740774517692302.
#sim_brar_known_var with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days, where mean=c(8.9/100,8.74/100,8.74/100), #sd=c(0.009,0.009,0.009), tp=0.5 and the minimal effect size is 0. sim_brar_known_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length(vStartTime),30, 3)),enrollrate=0.1, N1=21,armn=3,au=c(0.973,0.973), N2=189,tp=0.5,armlabel=c(1,2,3),blocksize=6,mean=c(8.9/100,8.74/100,8.74/100), sd=c(0.009,0.009,0.009),minstart=21,deltaa=c(0.0005,0.0005),tpp=0,deltaa1=c(0,0), mean10=0.09,mean20=0.09,mean30=0.09,sd10=0.01,sd20=0.01,sd30=0.01,n10=1,n20=1,n30=1,side='lower')
#sim_brar_known_var with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days, where mean=c(8.9/100,8.74/100,8.74/100), #sd=c(0.009,0.009,0.009), tp=0.5 and the minimal effect size is 0. sim_brar_known_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length(vStartTime),30, 3)),enrollrate=0.1, N1=21,armn=3,au=c(0.973,0.973), N2=189,tp=0.5,armlabel=c(1,2,3),blocksize=6,mean=c(8.9/100,8.74/100,8.74/100), sd=c(0.009,0.009,0.009),minstart=21,deltaa=c(0.0005,0.0005),tpp=0,deltaa1=c(0,0), mean10=0.09,mean20=0.09,mean30=0.09,sd10=0.01,sd20=0.01,sd30=0.01,n10=1,n20=1,n30=1,side='lower')
sim_brar_unknown_var
simulate a trial with two to five arms using Bayesian Response-Adaptive
Randomization with a control group for continuous outcomes with unknown variances. The conjugate prior distributions
follow Normal-Inverse-Gamma (NIG) ()
distributions and can be specified individually for each arm.
sim_brar_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, au, N2, tp, armlabel, blocksize, mean = 0, sd = 1, minstart, deltaa, tpp, deltaa1, V01, a01, b01, m01, V02 = V01, V03 = V01, V04 = V01, V05 = V01, a02 = a01, a03 = a01, a04 = a01, a05 = a01, b02 = b01, b03 = b01, b04 = b01, b05 = b01, m02 = m01, m03 = m01, m04 = m01, m05 = m01, side, ... )
sim_brar_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, armn, au, N2, tp, armlabel, blocksize, mean = 0, sd = 1, minstart, deltaa, tpp, deltaa1, V01, a01, b01, m01, V02 = V01, V03 = V01, V04 = V01, V05 = V01, a02 = a01, a03 = a01, a04 = a01, a05 = a01, b02 = b01, b03 = b01, b04 = b01, b05 = b01, m02 = m01, m03 = m01, m04 = m01, m05 = m01, side, ... )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
armn |
number of total arms in the trial. |
au |
a vector of cut-off values in the final selection at the end of the trial, with a length equal to the number of arms minus 1. |
N2 |
maximal sample size for the trial. |
tp |
tuning parameter. Some commonly used numbers are 0.5, 1 and n/2N. |
armlabel |
a vector of treatment labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
blocksize |
size of block used for equal randomization regarding participants in the 'initialization' period. Recommend to be an even multiple of the number of total arms. |
mean |
a vector of means in hypotheses, for example, as c(10,10) where 10 stands for the mean in both groups. Another example is c(10,12) where 10 and 12 stand for the mean for the control and the other treatment group, respectively. |
sd |
a vector of standard deviations in hypotheses, for example, as c(2,2) where 2 stands for the standard deviation in both groups. Another example is c(1,2) where 1 and 2 stand for the standard deviation for the control and the other treatment group, respectively. |
minstart |
a specified number of participants when one starts to check decision rules. |
deltaa |
a vector of minimal effect expected to be observed for early futility stopping in
each arm is approximately |
tpp |
indicator of |
deltaa1 |
a vector of pre-specified minimal effect size expected to be observed at the final stage
for each arm. The length of this parameter is |
V01 , a01 , b01 , m01
|
prior parameters m, V, a, b in |
V02 , a02 , b02 , m02
|
prior parameters m, V, a, b in |
V03 , a03 , b03 , m03
|
prior parameters m, V, a, b in |
V04 , a04 , b04 , m04
|
prior parameters m, V, a, b in |
V05 , a05 , b05 , m05
|
prior parameters m, V, a, b in |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
... |
additional arguments to be passed to |
This function generates a designed trial using Bayesian response-adaptive randomization with
a control group under no delay and delayed scenarios for continuous outcomes with unknown variances.
The function can handle trials with up to 5 arms. This function uses the formula
with
side
equals to 'upper',
and
with
side
equals to 'lower', utilizing available data at each step.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_brar_unknown_var
returns an object of class "brar". An object of class "brar" is a list containing
final decision, test statistics, the simulated data set and participants accrued for each arm
at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' results. In the final decision, 'Superiorityfinal' refers to the selected arm,
while 'Not Selected' indicates the arm stopped due to futility, and 'Control Selected' denotes the control arm chosen
because other arms did not meet futility criteria before the final stage or were not deemed effective at the final stage.
Note that before final stage of the trial, test statistics is calculated from deltaa
, and test statistics is
calculated from deltaa1
at the final stage.
Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.
#sim_brar_unknown_var with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under the null hypothesis, #where mean=c(9.19/100,8.74/100,8.74/100), sd=c(0.009,0.009,0.009), tp=1 and #the minimal effect size is 0. sim_brar_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length(vStartTime ),30,3)),enrollrate=0.1, N1=48,armn=3,au=c(0.85,0.85), N2=480,tp=1,armlabel=c(1, 2,3),blocksize=6,mean=c(9.19/100,8.74/100,8.74/100), sd=c(0.009,0.009,0.009), minstart=48,deltaa=c(-0.000325,-0.000325), tpp=0,deltaa1=c(0,0),V01=1/2,a01=0.3,m01=9/100,b01=0.00001,side='lower')
#sim_brar_unknown_var with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under the null hypothesis, #where mean=c(9.19/100,8.74/100,8.74/100), sd=c(0.009,0.009,0.009), tp=1 and #the minimal effect size is 0. sim_brar_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length(vStartTime ),30,3)),enrollrate=0.1, N1=48,armn=3,au=c(0.85,0.85), N2=480,tp=1,armlabel=c(1, 2,3),blocksize=6,mean=c(9.19/100,8.74/100,8.74/100), sd=c(0.009,0.009,0.009), minstart=48,deltaa=c(-0.000325,-0.000325), tpp=0,deltaa1=c(0,0),V01=1/2,a01=0.3,m01=9/100,b01=0.00001,side='lower')
sim_dabcd_max_power
can be used for doubly adaptive biased coin design with maximal power
strategy for binary outcomes, targeting generalized Neyman allocation and generalized RSIHR allocation.
sim_dabcd_max_power( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, armlabel, h, BB, type, gamma = 2, alphaa = 0.025, side )
sim_dabcd_max_power( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, armlabel, h, BB, type, gamma = 2, alphaa = 0.025, side )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the burn-in period. Recommend using 10 percent of the total sample size. |
N2 |
maximal sample size for the trial. |
armn |
number of total arms in the trial. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describes how each arm is labeled in a two-armed trial. |
h |
a vector of success probabilities in hypotheses, for example, as c(0.1,0.1) where 0.1 stands for the success probability for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the success probabilities for the control and the treatment group, respectively. |
BB |
the minimal allocation probabilities for each arm, which is within the
range of |
type |
allocation type, with choices from 'RSIHR' and 'Neyman'. |
gamma |
tuning parameter in Hu & Zhang's formula. When dabcd=0, this parameter does not need to be specified. Default value is set to 2. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
The function simulates a trial for doubly adaptive biased coin design with maximal power strategy targeting
generalized Neyman allocation with 2-5 arms which is provided in (Tymofyeyev et al. 2007) and
generalized RSIHR allocation with 2-3 arms which is provided in (Jeon and Feifang 2010), with modifications for typos
in (Sabo and Bello 2016). All of those methods are not smoothed. The output of this function is based on Hu \&
Zhang's formula (Hu and Zhang 2004).
With more than two armd the one-sided nominal level of each test is alphaa
divided by arm*(arm-1)/2
; a Bonferroni correction.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_dabcd_max_power
returns an object of class "dabcd". An object of class "dabcd" is a list containing
final decision based on the Z test statistics with 1 stands for selected and 0 stands for not selected,
Z test statistics, the simulated data set and participants accrued for each arm at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result.
Hu F, Zhang L (2004). “Asymptotic Properties of Doubly Adaptive Biased Coin Designs for Multitreatment Clinical Trials.” The Annals of Statistics, 32(1), 268–301. Tymofyeyev Y, Rosenberger WF, Hu F (2007). “Implementing Optimal Allocation in Sequential Binary Response Experiments.” Journal of the American Statistical Association, 102(477), 224-234. doi:10.1198/016214506000000906. Jeon Y, Feifang H (2010). “Optimal Adaptive Designs for Binary Response Trials With Three Treatments.” Statistics in Biopharmaceutical Research, 2, 310-318. doi:10.1198/sbr.2009.0056. Sabo R, Bello G (2016). “Optimal and lead-in adaptive allocation for binary outcomes: a comparison of Bayesian methodologies.” Communications in Statistics - Theory and Methods, 46.
sim_dabcd_max_power(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.9,N1=30,N2=300,armn=3, armlabel=c(1,2,3),h=c(0.2,0.3,0.2),BB=0.1,type='Neyman', side='upper') sim_dabcd_max_power(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)),enrollrate=0.1,N1=50,N2=500,armn=3, armlabel=c(1,2,3),h=c(0.2,0.3,0.3),BB=0.15,type='RSIHR', side='upper')
sim_dabcd_max_power(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.9,N1=30,N2=300,armn=3, armlabel=c(1,2,3),h=c(0.2,0.3,0.2),BB=0.1,type='Neyman', side='upper') sim_dabcd_max_power(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)),enrollrate=0.1,N1=50,N2=500,armn=3, armlabel=c(1,2,3),h=c(0.2,0.3,0.3),BB=0.15,type='RSIHR', side='upper')
sim_dabcd_min_var
can be used for doubly adaptive biased coin design with minimal variance
strategy for binary outcomes, targeting generalized Neyman allocation and generalized RSIHR allocation
with 2-5 arms.
sim_dabcd_min_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, armlabel, h, type, gamma = 2, alphaa = 0.025, side )
sim_dabcd_min_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, armlabel, h, type, gamma = 2, alphaa = 0.025, side )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
N2 |
maximal sample size for the trial. |
armn |
number of total arms in the trial. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
h |
a vector of success probabilities in hypotheses, for example, as c(0.1,0.1) where 0.1 stands for the success probability for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the success probabilities for the control and the treatment group, respectively. |
type |
allocation type, with choices from 'RSIHR' and 'Neyman'. |
gamma |
tuning parameter in Hu & Zhang's formula ((Hu and Zhang 2004)). When dabcd=0, this parameter does not need to be specified. Default value is set to 2. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
The output of this function is based on Hu \&
Zhang's formula (Hu and Zhang 2004).
With more than two arms the one-sided nominal level of each
test is alphaa
divided by arm*(arm-1)/2
; a Bonferroni correction.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_dabcd_min_var
returns an object of class "dabcd". An object of class "dabcd" is a list containing
final decision based on the Z test statistics with 1 stands for selected and 0 stands for not selected,
Z test statistics, the simulated data set and participants accrued for each arm at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result.
Hu F, Zhang L (2004). “Asymptotic Properties of Doubly Adaptive Biased Coin Designs for Multitreatment Clinical Trials.” The Annals of Statistics, 32(1), 268–301.
sim_dabcd_min_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.9,N1=30,N2=300,armn=3, armlabel=c(1,2,3),h=c(0.2,0.3,0.2),type='Neyman', side='upper') sim_dabcd_min_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)),enrollrate=0.1,N1=50,N2=500,armn=3, armlabel=c(1,2,3),h=c(0.2,0.3,0.3),type='RSIHR', side='lower')
sim_dabcd_min_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.9,N1=30,N2=300,armn=3, armlabel=c(1,2,3),h=c(0.2,0.3,0.2),type='Neyman', side='upper') sim_dabcd_min_var(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)),enrollrate=0.1,N1=50,N2=500,armn=3, armlabel=c(1,2,3),h=c(0.2,0.3,0.3),type='RSIHR', side='lower')
Function for simulating a trial using the forward-looking Gittins Index rule and the controlled forward-looking
Gittins Index rule for binary outcomes in trials with 2-5 arms. The conjugate prior distributions
follow Beta () distributions and should be the same for each arm.
sim_flgi_binary( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, I0, K, noRuns2 = 100, Tsize, ptrue, block, rule, ztype, stopbound, side )
sim_flgi_binary( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, I0, K, noRuns2 = 100, Tsize, ptrue, block, rule, ztype, stopbound, side )
Gittinstype |
type of Gittins indices, should be set to 'binary' in this function. |
df |
discount factor which is the multiplier for loss at each additional patient in the future. Available values are 0, 0.5, 0.7, 0.99 and 0.995. The maximal sample size can be up to 2000. |
gittins |
user specified Gittins indices for calculation in this function. Recommend using the
|
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
I0 |
a matrix with K rows and 2 columns, where the numbers inside are equal to the prior parameters, and K is equal to the total number of arms. For example, matrix(1,nrow=2,ncol=2) means that the prior distributions for two-armed trials are beta(1,1); matrix(c(2,3),nrow=2,ncol=2,byrow = TRUE) means that the prior distributions for two-armed trials are beta(2,3). The first column represents the prior of the number of successes, and the second column represents the prior of the number of failures. |
K |
number of total arms in the trial. |
noRuns2 |
number of simulations for simulated allocation probabilities within each block. Default value is set to 100, which is recommended in (Villar et al. 2015). |
Tsize |
maximal sample size for the trial. |
ptrue |
a vector of hypotheses, for example, as c(0.1,0.1) where 0.1 stands for the success probability for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the success probability for the control and the treatment group, respectively. |
block |
block size. |
rule |
rules can be used in this function, with values 'FLGI PM', 'FLGI PD' or 'CFLGI'. 'FLGI PM' stands for making decision based on posterior mean; 'FLGI PD' stands for making decision based on posterior distribution; 'CFLGI' stands for controlled forward-looking Gittins Index. |
ztype |
Z test statistics, with choice of values from 'pooled' and 'unpooled'. |
stopbound |
the cut-off value for Z test statistics, which is simulated under the null hypothesis. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function simulates a trial using the forward-looking Gittins Index rule or the
controlled forward-looking Gittins Index rule under both no delay and delayed scenarios.
The cut-off value used for stopbound
is obtained by simulations using flgi_stop_bound_binary
.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_flgi_binary
returns an object of class "flgi". An object of class "flgi" is a list containing
final decision based on the Z test statistics with 1 stands for selected and 0 stands for not selected, final decision based on
the maximal Gittins Index value at the final stage, Z test statistics, the simulated data set and participants accrued for each arm
at the time of termination of that group in one trial. The simulated data set includes 5 columns: participant ID number, enrollment time,
observed time of results, allocated arm, and participants' result.
Villar S, Wason J, Bowden J (2015). “Response-Adaptive Randomization for Multi-arm Clinical Trials Using the Forward Looking Gittins Index Rule.” Biometrics, 71. doi:10.1111/biom.12337.
#The forward-looking Gittins Index rule with delayed responses follow a normal distribution #with a mean of 60 days and a standard deviation of 3 days sim_flgi_binary(Gittinstype='Binary',df=0.5,Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),60, 3)),enrollrate=0.9,I0= matrix(1,nrow=2,2), K=2,Tsize=992,ptrue=c(0.6,0.7),block=20,rule='FLGI PM',ztype='unpooled', stopbound=1.9991,side='upper')
#The forward-looking Gittins Index rule with delayed responses follow a normal distribution #with a mean of 60 days and a standard deviation of 3 days sim_flgi_binary(Gittinstype='Binary',df=0.5,Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),60, 3)),enrollrate=0.9,I0= matrix(1,nrow=2,2), K=2,Tsize=992,ptrue=c(0.6,0.7),block=20,rule='FLGI PM',ztype='unpooled', stopbound=1.9991,side='upper')
Function for simulating a trial using the forward-looking Gittins Index rule and the controlled forward-looking
Gittins Index rule for continuous outcomes with known variances in trials with 2-5 arms. The conjugate prior distributions
follow Normal () distributions and should be the same for each arm.
sim_flgi_known_var( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, K, noRuns2, Tsize, block, rule, prior_n, prior_mean, stopbound, mean, sd, side )
sim_flgi_known_var( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, K, noRuns2, Tsize, block, rule, prior_n, prior_mean, stopbound, mean, sd, side )
Gittinstype |
type of Gittins indices, should be set to 'KV' in this function. |
df |
discount factor which is the multiplier for loss at each additional patient in the future. Available values are 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99 and 0.995. The maximal sample size can be up to 10000. |
gittins |
user specified Gittins indices for calculation in this function. If |
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
K |
number of total arms in the trial. |
noRuns2 |
number of simulations for simulated allocation probabilities within each block. Default value is set to 100, which is recommended in (Villar et al. 2015). |
Tsize |
maximal sample size for the trial. |
block |
block size. |
rule |
rules can be used in this function, with values 'FLGI PM', 'FLGI PD' or 'CFLGI'. 'FLGI PM' stands for making decision based on posterior mean; 'FLGI PD' stands for making decision based on posterior distribution; 'CFLGI' stands for controlled forward-looking Gittins Index. |
prior_n |
a vector representing the number of observations assumed in prior distributions, eg: c(1,1) for a two-armed trial. |
prior_mean |
a vector representing mean of observations assumed in prior distributions, eg: c(0,0,0) for a three-armed trial, rep(0,K) can be used to simplify the process. If a negative effect is expected, adjust the mean to a negative value. |
stopbound |
the cut-off value for Z test statistics, which is simulated under the null hypothesis. |
mean |
a vector of mean hypotheses, for example, c(0.1,0.1) where 0.1 stands for the mean for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the mean for the control and a treatment group, respectively. |
sd |
a vector of standard deviation in hypotheses, for example, as c(0.64,0.64) where 0.64 stands for the standard deviation for both groups. Another example is c(0.64,0.4) where 0.64 and 0.4 stand for the standard deviation for the control and a treatment group, respectively. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function simulates a trial using the forward-looking Gittins Index rule or the
controlled forward-looking Gittins Index rule under both no delay and delayed scenarios.
The cut-off value used for stopbound
is obtained by simulations using flgi_stop_bound_flgi_known_var
.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_flgi_known_var
returns an object of class "flgi". An object of class "flgi" is a list containing
final decision based on the Z test statistics with 1 stands for selected and 0 stands for not selected, final decision based on
the maximal Gittins Index value at the final stage, Z test statistics, the simulated data set and participants accrued for each arm
at the time of termination of that group in one trial. The simulated data set includes 5 columns: participant ID number, enrollment time,
observed time of results, allocated arm, and participants' result.
Williamson SF, Villar S (2019). “A Response‐Adaptive Randomization Procedure for Multi‐Armed Clinical Trials with Normally Distributed Outcomes.” Biometrics, 76. doi:10.1111/biom.13119.
#The forward-looking Gittins Index rule with delayed responses follow a normal distribution #with a mean of 30 days and a standard deviation of 3 days sim_flgi_known_var(Gittinstype='KV',df=0.995,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.5, K=3,noRuns2=100,Tsize=852,block=20,rule='FLGI PM',prior_n=rep(1,3), prior_mean=rep(9/100,3),stopbound=(-2.1725),mean=c(9.1/100,8.83/100,8.83/100), sd=c(0.009,0.009,0.009),side='lower') #The controlled forward-looking Gittins Index rule with delayed responses follow a #normal distribution with a mean of 30 days and a standard deviation of 3 days sim_flgi_known_var(Gittinstype='KV',df=0.995,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.1, K=3,noRuns2=100,Tsize=852,block=20,rule='CFLGI',prior_n=rep(1,3), prior_mean=rep(9/100,3),stopbound=(-2.075),mean=c(9.1/100,8.83/100,8.83/100), sd=c(0.009,0.009,0.009),side='lower')
#The forward-looking Gittins Index rule with delayed responses follow a normal distribution #with a mean of 30 days and a standard deviation of 3 days sim_flgi_known_var(Gittinstype='KV',df=0.995,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.5, K=3,noRuns2=100,Tsize=852,block=20,rule='FLGI PM',prior_n=rep(1,3), prior_mean=rep(9/100,3),stopbound=(-2.1725),mean=c(9.1/100,8.83/100,8.83/100), sd=c(0.009,0.009,0.009),side='lower') #The controlled forward-looking Gittins Index rule with delayed responses follow a #normal distribution with a mean of 30 days and a standard deviation of 3 days sim_flgi_known_var(Gittinstype='KV',df=0.995,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)),enrollrate=0.1, K=3,noRuns2=100,Tsize=852,block=20,rule='CFLGI',prior_n=rep(1,3), prior_mean=rep(9/100,3),stopbound=(-2.075),mean=c(9.1/100,8.83/100,8.83/100), sd=c(0.009,0.009,0.009),side='lower')
Function for simulating a trial using the forward-looking Gittins Index rule and the controlled forward-looking
Gittins Index rule for continuous outcomes with unknown variances in trials with 2-5 arms. The prior distributions
follow Normal-Inverse-Gamma (NIG) ()
distributions and should be the same for each arm.
sim_flgi_unknown_var( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, K, noRuns2, Tsize, block, rule, prior_n, prior_mean1, prior_sd1, stopbound, mean, sd, side )
sim_flgi_unknown_var( Gittinstype, df, gittins = NULL, Pats, nMax, TimeToOutcome, enrollrate, K, noRuns2, Tsize, block, rule, prior_n, prior_mean1, prior_sd1, stopbound, mean, sd, side )
Gittinstype |
type of Gittins indices, should be set to 'UNKV' in this function |
df |
discount factor which is the multiplier for loss at each additional patient in the future. Available values are 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99 and 0.995. The maximal sample size can be up to 10000. |
gittins |
user specified Gittins indices for calculation in this function. If |
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
K |
number of total arms in the trial. |
noRuns2 |
number of simulations for simulated allocation probabilities within each block. Default value is set to 100 times, which is recommended in Villar et al., 2015. |
Tsize |
maximal sample size for the trial. |
block |
block size. |
rule |
rules can be used in this function, with values 'FLGI PM', 'FLGI PD' or 'CFLGI'. 'FLGI PM' stands for making decision based on posterior mean; 'FLGI PD' stands for making decision based on posterior distribution; 'CFLGI' stands for controlled forward-looking Gittins Index. |
prior_n |
a vector representing the number of observations assumed in prior distribution, eg: c(1,1) for a two-armed trial. |
prior_mean1 |
a vector representing mean of observations assumed in prior distributions, eg: c(0,0,0) for a three-armed trial, rep(0,K) can be used to simplify the process. If a negative effect is expected, adjust the mean to a negative value. |
prior_sd1 |
a vector representing the standard deviation of observations assumed in prior distribution, eg: rep(1,3) for a three-armed trial. |
stopbound |
the cut-off value for T test statistics, which is simulated under the null hypothesis. |
mean |
a vector of mean hypotheses, for example, as c(0.1,0.1) where 0.1 stands for the mean for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the mean for the control and a treatment group, respectively. |
sd |
a vector of standard deviation hypotheses, for example, as c(0.64,0.64) where 0.64 stands for the standard deviation for both groups. Another example is c(0.64,0.4) where 0.64 and 0.4 stand for the standard deviation for the control and a treatment group, respectively. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function simulates a trial using the forward-looking Gittins Index rule or the
controlled forward-looking Gittins Index rule under both no delay and delayed scenarios.
The cut-off value used for stopbound
is obtained by simulations using flgi_stop_bound_flgi_unk_var
.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_flgi_unknown_var
returns an object of class "flgi". An object of class "flgi" is a list containing
final decision based on the T test statistics with 1 stands for selected and 0 stands for not selected, final decision based on
the maximal Gittins Index value at the final stage, T test statistics, the simulated data set and participants accrued for each arm
at the time of termination of that group in one trial. The simulated data set includes 5 columns: participant ID number, enrollment time,
observed time of results, allocated arm, and participants' result.
Williamson SF, Villar S (2019). “A Response‐Adaptive Randomization Procedure for Multi‐Armed Clinical Trials with Normally Distributed Outcomes.” Biometrics, 76. doi:10.1111/biom.13119.
#The forward-looking Gittins Index rule with delayed responses follow a normal #with a mean of 60 days and a standard deviation of 3 days sim_flgi_unknown_var(Gittinstype='UNKV',df=0.5,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)),enrollrate=0.9, K=3,noRuns2=100,Tsize=852,block=20,rule='FLGI PM',prior_n=rep(2,3), prior_mean1=rep(9/100,3),stopbound=(-1.9298),prior_sd1=rep(0.006324555,3), mean=c(9.1/100,8.83/100,8.83/100),sd=c(0.009,0.009,0.009),side='lower')
#The forward-looking Gittins Index rule with delayed responses follow a normal #with a mean of 60 days and a standard deviation of 3 days sim_flgi_unknown_var(Gittinstype='UNKV',df=0.5,Pats=10,nMax=50000, TimeToOutcome=expression(rnorm( length( vStartTime ),60, 3)),enrollrate=0.9, K=3,noRuns2=100,Tsize=852,block=20,rule='FLGI PM',prior_n=rep(2,3), prior_mean1=rep(9/100,3),stopbound=(-1.9298),prior_sd1=rep(0.006324555,3), mean=c(9.1/100,8.83/100,8.83/100),sd=c(0.009,0.009,0.009),side='lower')
Simulate randomized play-the-winner rule in a two-armed trial with binary endpoint.
sim_RPTW( Pats, nMax, TimeToOutcome, enrollrate, na0, nb0, na1, nb1, h, alphaa = 0.025, N2, side, Z = NULL )
sim_RPTW( Pats, nMax, TimeToOutcome, enrollrate, na0, nb0, na1, nb1, h, alphaa = 0.025, N2, side, Z = NULL )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
na0 , nb0
|
the initial number of balls in the urn represents the control group and the treatment group. |
na1 , nb1
|
additional number of balls represents the control group and the treatment group added to the urn after the result of each participant. |
h |
a vector of hypothesis, for example, as c(0.1,0.1) where 0.1 stands for the success probability for both groups. Another example is c(0.1,0.3) where 0.1 and 0.3 stand for the success probabilities for the control and a treatment group, respectively. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
N2 |
maximal sample size for the trial. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
Z |
the selected cut-off value. Only specified Z when the cut-off value is selected by simulations. |
This function simulates trials using the randomized play-the-winner
rule under both no delay and delayed scenarios. This method is a type of urn design
with the motivation to allocate more participants to the better treatment group.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_RPTW
returns an object of class "rptw". An object of class "rptw" is a list containing
final decision based on the Z test statistics with 1 stands for selected and 0 stands for not selected,
Z test statistics, the simulated data set and participants accrued for each arm at the time of termination
of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result with 1 stand for selected and 0 stand for not selected.
Wei LJ, Durham S (1978). “The Randomized Play-the-Winner Rule in Medical Trials.” Journal of the American Statistical Association, 73(364), 840–843.
#sim_RPTW with no delay responses sim_RPTW(Pats=10,nMax=50000,TimeToOutcome=0,enrollrate=0.9,na0=1,nb0=1,na1=1,nb1=1, h=c(0.1,0.3),alphaa=0.025,N2=168,side='upper') #sim_RPTW with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days sim_RPTW(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)), enrollrate=0.9,na0=1,nb0=1,na1=1,nb1=1,h=c(0.1,0.3),alphaa=0.025,N2=168,side='upper')
#sim_RPTW with no delay responses sim_RPTW(Pats=10,nMax=50000,TimeToOutcome=0,enrollrate=0.9,na0=1,nb0=1,na1=1,nb1=1, h=c(0.1,0.3),alphaa=0.025,N2=168,side='upper') #sim_RPTW with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days sim_RPTW(Pats=10,nMax=50000,TimeToOutcome=expression(rnorm( length( vStartTime ),30, 3)), enrollrate=0.9,na0=1,nb0=1,na1=1,nb1=1,h=c(0.1,0.3),alphaa=0.025,N2=168,side='upper')
sim_RSIHR_optimal_known_var
simulates a trial for continuous endpoints with known variances,
and the allocation probabilities are fixed.
sim_RSIHR_optimal_known_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, mean, sd, alphaa = 0.025, armlabel, cc, side )
sim_RSIHR_optimal_known_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, mean, sd, alphaa = 0.025, armlabel, cc, side )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
N2 |
maximal sample size for the trial. |
armn |
number of total arms in the trial. |
mean |
a vector of hypotheses of mean, with the first one serving as the control group. |
sd |
a vector of hypotheses of standard deviation with the first one serving as the control group. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
cc |
value in the formula of measure of treatment effectiveness, usually take the average
of mean responses in the hypotheses. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function aims to minimize the criteria
with constraints
, where
for some fixed C. It is equivalent to generalized RSIHR allocation for continuous endpoints with known variances.
With more than two arms the one-sided nominal level of each test is
alphaa
divided
by arm*(arm-1)/2
; a Bonferroni correction.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_RSIHR_optimal_known_var
returns an object of class "RSIHRoptimal". An object of class "RSIHRoptimal" is a list containing
final decision based on the Z test statistics with 1 stands for selected and 0 stands for not selected,
Z test statistics, the simulated data set and participants accrued for each arm at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result.
Biswas A, Mandal S, Bhattacharya R (2011). “Multi-treatment optimal response-adaptive designs for phase III clinical trials.” Journal of the Korean Statistical Society, 40(1), 33-44. ISSN 1226-3192, doi:10.1016/j.jkss.2010.04.004.
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a three-armed trial sim_RSIHR_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N1=9,N2=132,armn=3, mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel=c(1,2,3),cc=mean(c(9.1/100,9.1/100,9.1/100)),side='lower') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a three-armed trial sim_RSIHR_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N1=9,N2=132,armn=3, mean=c(9.1/100,8.47/100,8.47/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel=c(1,2,3),cc=mean(c(9.1/100,8.47/100,8.47/100)),side='lower')
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a three-armed trial sim_RSIHR_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N1=9,N2=132,armn=3, mean=c(9.1/100,9.1/100,9.1/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel=c(1,2,3),cc=mean(c(9.1/100,9.1/100,9.1/100)),side='lower') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a three-armed trial sim_RSIHR_optimal_known_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm(length( vStartTime ),30, 3)),enrollrate=0.9,N1=9,N2=132,armn=3, mean=c(9.1/100,8.47/100,8.47/100),sd=c(0.009,0.009,0.009),alphaa=0.025, armlabel=c(1,2,3),cc=mean(c(9.1/100,8.47/100,8.47/100)),side='lower')
sim_RSIHR_optimal_unknown_var
simulates a trial for continuous endpoints with unknown variances,
and the allocation probabilities change based on results of accumulated participants in the trial.
sim_RSIHR_optimal_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, mean, sd, alphaa = 0.025, armlabel, cc, side )
sim_RSIHR_optimal_unknown_var( Pats, nMax, TimeToOutcome, enrollrate, N1, N2, armn, mean, sd, alphaa = 0.025, armlabel, cc, side )
Pats |
the number of patients accrued within a certain time frame indicates the count of individuals who have been affected by the disease during that specific period, for example, a month or a day. If this number is 10, it represents that 10 people have got the disease within the specified time frame. |
nMax |
the assumed maximum accrued number of patients with the disease in the population, this number should be chosen carefully to ensure a sufficient number of patients are simulated, especially when considering the delay mechanism. |
TimeToOutcome |
the distribution of delayed response times or a fixed delay time for responses. The delayed time could be a month, a week or any other time frame. When the unit changes, the number of TimeToOutcome should also change. It can be in the format of expression(rnorm( length( vStartTime ),30, 3)), representing delayed responses with a normal distribution, where the mean is 30 days and the standard deviation is 3 days. |
enrollrate |
probability that patients in the population can enroll in the trial. This parameter is related to the number of people who have been affected by the disease in the population, following an exponential distribution. |
N1 |
number of participants with equal randomization in the 'initialization' period. Recommend using 10 percent of the total sample size. |
N2 |
maximal sample size for the trial. |
armn |
number of total arms in the trial. |
mean |
a vector of hypotheses of mean, with the first one serving as the control group. |
sd |
a vector of hypotheses of standard deviation with the first one serving as the control group. |
alphaa |
the overall type I error to be controlled for the one-sided test. Default value is set to 0.025. |
armlabel |
a vector of arm labels with an example of c(1, 2), where 1 and 2 describe how each arm is labeled in a two-armed trial. |
cc |
value in the formula of measure of treatment effectiveness, usually take the average
of mean responses in the hypotheses. |
side |
direction of a one-sided test, with values 'upper' or 'lower'. |
This function aims to minimize the criteria
with constraints
, where
for some fixed C. It is equivalent to generalized RSIHR allocation for continuous endpoints with unknown variances.
With more than two arms the one-sided nominal level of each test is
alphaa
divided
by arm*(arm-1)/2
; a Bonferroni correction.
Considering the delay mechanism, Pats
(the number of patients accrued within a certain time frame),
nMax
(the assumed maximum accrued number of patients with the disease in the population) and
TimeToOutcome
(the distribution of delayed response times or a fixed delay time for responses)
are parameters in the functions adapted from https://github.com/kwathen/IntroBayesianSimulation.
Refer to the website for more details.
sim_RSIHR_optimal_unknown_var
returns an object of class "RSIHRoptimal". An object of class "RSIHRoptimal" is a list containing
final decision based on the T test statistics with 1 stands for selected and 0 stands for not selected,
T test statistics, the simulated data set and participants accrued for each arm at the time of termination of that group in one trial.
The simulated data set includes 5 columns: participant ID number, enrollment time, observed time of results,
allocated arm, and participants' result.
Biswas A, Mandal S, Bhattacharya R (2011). “Multi-treatment optimal response-adaptive designs for phase III clinical trials.” Journal of the Korean Statistical Society, 40(1), 33-44. ISSN 1226-3192, doi:10.1016/j.jkss.2010.04.004.
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a three-armed trial sim_RSIHR_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.9,N1=8,N2=88,armn=2, mean=c(9.1/100,9.1/100),sd=c(0.009,0.009),alphaa=0.025,armlabel=c(1,2), cc=mean(c(9.1/100,9.1/100)),side='upper') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a three-armed trial sim_RSIHR_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.9,N1=8,N2=88,armn=2, mean=c(9.1/100,8.47/100),sd=c(0.009,0.009),alphaa=0.025,armlabel=c(1,2), cc=mean(c(9.1/100,8.47/100)),side='upper')
#Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under null hypothesis #in a three-armed trial sim_RSIHR_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.9,N1=8,N2=88,armn=2, mean=c(9.1/100,9.1/100),sd=c(0.009,0.009),alphaa=0.025,armlabel=c(1,2), cc=mean(c(9.1/100,9.1/100)),side='upper') #Run the function with delayed responses follow a normal distribution with #a mean of 30 days and a standard deviation of 3 days under alternative hypothesis #in a three-armed trial sim_RSIHR_optimal_unknown_var(Pats=10,nMax=50000,TimeToOutcome=expression( rnorm( length( vStartTime ),30, 3)),enrollrate=0.9,N1=8,N2=88,armn=2, mean=c(9.1/100,8.47/100),sd=c(0.009,0.009),alphaa=0.025,armlabel=c(1,2), cc=mean(c(9.1/100,8.47/100)),side='upper')
Update parameters of a Normal-Inverse-Chi-Squared distribution
update_par_nichisq(y, par)
update_par_nichisq(y, par)
y |
observed data. |
par |
a vector of current parameters including mu, kappa, nu, sigsq from a Normal-Inverse-Chi-Squared distribution. |
This function updates parameters of a Normal-Inverse-Chi-Squared
()
distribution with available data to parameters of a posterior Normal-Inverse-Gamma
(
)distribution.
Those updated parameters can be converted to parameters in a Normal-Inverse-Gamma distribution
for continuous outcomes with unknown variances using
convert_chisq_to_gamma
.
a list of parameters including mu, kappa, nu, sigsq for a posterior Normal-Inverse-Chi-Squared distribution incorporating available data.
Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.
para<-list(V=1/2,a=0.5,m=9.1/100,b=0.00002) par<-convert_gamma_to_chisq(para) set.seed(123451) y1<-rnorm(100,0.091,0.009) update_par_nichisq(y1, par) set.seed(123452) y2<-rnorm(90,0.09,0.009) update_par_nichisq(y2, par)
para<-list(V=1/2,a=0.5,m=9.1/100,b=0.00002) par<-convert_gamma_to_chisq(para) set.seed(123451) y1<-rnorm(100,0.091,0.009) update_par_nichisq(y1, par) set.seed(123452) y2<-rnorm(90,0.09,0.009) update_par_nichisq(y2, par)