Package 'RARtrials'

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

Help Index


Select au in Bayesian Response-Adaptive Randomization with a Control Group for Binary Endpoint

Description

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 (Beta(α,β)Beta(\alpha,\beta)) distributions and can be specified individually for each arm.

Usage

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,
  ...
)

Arguments

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

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta), prior for arm 1 which stands for the control. Default value is set to 1.

alpha2, beta2

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta), prior for arm 2. Default value is set to alpha1 and beta1.

alpha3, beta3

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta) prior for arm 3. Default value is set to alpha1 and beta1.

alpha4, beta4

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta) prior for arm 4. Default value is set to alpha1 and beta1..

alpha5, beta5

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta) prior for arm 5. Default value is set to alpha1 and beta1.

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 1%1\%. The length of this parameter is armn-1.

tpp

indicator of tp equals to n/2N. When tp is n/2N, tpp should be assigned 1. Default value is set to 0.

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 armn-1.

side

direction of a one-sided test, with values 'upper' or 'lower'.

output

control the output of brar_select_au_binary. If user does not specify anything, the function returns the entire data set 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 integrate (such as rel.tol) from this function.

Details

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 Pr(pk=max{p1,...,pK})tpk=1KPr(pk=max{p1,...,pK})tp\frac{Pr(p_k=max\{p_1,...,p_K\})^{tp}} {\sum_{k=1}^{K}{Pr(p_k=max\{p_1,...,p_K\})^{tp}}} with side equals to 'upper', and Pr(pk=min{p1,...,pK})tpk=1KPr(pk=min{p1,...,pK})tp\frac{Pr(p_k=min\{p_1,...,p_K\})^{tp}} {\sum_{k=1}^{K}{Pr(p_k=min\{p_1,...,p_K\}){tp}}} 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.

Value

A list of results generated from formula Pr(pk>pcontrol+δdatat1)Pr(p_k>p_{control}+\delta|data_{t-1}) 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.

References

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.

Examples

#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.

Select au in Bayesian Response-Adaptive Randomization with a Control Group for Continuous Endpoint with Known Variances

Description

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 (N(mean,sd)N(mean,sd)) distributions and can be specified individually for each arm.

Usage

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,
  ...
)

Arguments

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 1%1\%. The length of this parameter is armn-1.

tpp

indicator of tp equals to n/2N. When tp is n/2N, tpp should be assigned 1. Default value is set to 0.

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 armn-1.

mean10, sd10

prior mean and sd in N(mean,sd)N(mean,sd) of arm 1 in the trial, which stands for the control. Default value is set to 1.

mean20, sd20

prior mean and sd in N(mean,sd)N(mean,sd) of arm 2 in the trial. Default value is set to mean10 and sd10.

mean30, sd30

prior mean and sd in N(mean,sd)N(mean,sd) of arm 3 in the trial. Default value is set to mean10 and sd10.

mean40, sd40

prior mean and sd in N(mean,sd)N(mean,sd) of arm 4 in the trial. Default value is set to mean10 and sd10.

mean50, sd50

prior mean and sd in N(mean,sd)N(mean,sd) of arm 5 in the trial. Default value is set to mean10 and sd10.

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 n10.

n30

explicit prior n of arm 3 in the trial. Default value is set to n10.

n40

explicit prior n of arm 4 in the trial. Default value is set to n10.

n50

explicit prior n of arm 5 in the trial. Default value is set to n10.

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 integrate (such as rel.tol) from this function.

Details

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 Pr(μk=max{μ1,...,μK})tpk=1KPr(μk=max{μ1,...,μK})tp\frac{Pr(\mu_k=max\{\mu_1,...,\mu_K\})^{tp}} {\sum_{k=1}^{K}{Pr(\mu_k=max\{\mu_1,...,\mu_K\})^{tp}}} with side equals to 'upper', and Pr(μk=min{μ1,...,μK})tpk=1KPr(μk=min{μ1,...,μK})tp\frac{Pr(\mu_k=min\{\mu_1,...,\mu_K\})^{tp}} {\sum_{k=1}^{K}{Pr(\mu_k=min\{\mu_1,...,\mu_K\}){tp}}} 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.

Value

A list of results generated from formula Pr(μk>μcontrol+δdatat1)Pr(\mu_k>\mu_{control}+\delta|data_{t-1}) 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.

References

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.

Examples

#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.

Select au in Bayesian Response-Adaptive Randomization with a Control Group for Continuous Endpoint with Unknown Variances

Description

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) ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)) distributions and can be specified individually for each arm.

Usage

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,
  ...
)

Arguments

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 1%1\%. The length of this parameter is armn-1.

tpp

indicator of tp equals to n/2N. When tp is n/2N, tpp should be assigned 1. Default value is set to 0.

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 armn-1.

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 NIG(V,m,a,b)NIG(V,m,a,b) of arm 1 in the trial, which stands for the control.

V02, a02, b02, m02

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 2 in the trial. Default value is set to V01, a01, b01 and m01.

V03, a03, b03, m03

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 3 in the trial. Default value is set to V01, a01, b01 and m01.

V04, a04, b04, m04

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 4 in the trial. Default value is set to V01, a01, b01 and m01.

V05, a05, b05, m05

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 5 in the trial. Default value is set to V01, a01, b01 and m01.

...

additional arguments to be passed to integrate (such as rel.tol) from this function.

Details

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 Pr(μk=max{μ1,...,μK})tpk=1KPr(μk=max{μ1,...,μK})tp\frac{Pr(\mu_k=max\{\mu_1,...,\mu_K\})^{tp}} {\sum_{k=1}^{K}{Pr(\mu_k=max\{\mu_1,...,\mu_K\})^{tp}}} with side equals to 'upper', and Pr(μk=min{μ1,...,μK})tpk=1KPr(μk=min{μ1,...,μK})tp\frac{Pr(\mu_k=min\{\mu_1,...,\mu_K\})^{tp}} {\sum_{k=1}^{K}{Pr(\mu_k=min\{\mu_1,...,\mu_K\}){tp}}} 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.

Value

A list of results generated from formula Pr(μk>μcontrol+δdatat1)Pr(\mu_k>\mu_{control}+\delta|data_{t-1}) 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.

References

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.

Examples

#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

Description

Convert parameters from a Normal-Inverse-Chi-Squared distribution to a Normal-Inverse-Gamma distribution.

Usage

convert_chisq_to_gamma(cpar)

Arguments

cpar

a list of parameters including mu, kappa, nu, sigsq from a Normal-Chi-Squared distribution.

Details

This function convert parameters from a Normal-Inverse-Chi-Squared ((μ,σ2)NIX(mean=μ,effectivesamplesize=κ,degreesoffreedom=ν,variance=σ2/κ)(\mu,\sigma^2) \sim NIX(mean=\mu,effective sample size=\kappa,degrees of freedom=\nu,variance=\sigma^2/\kappa)) distribution to a Normal-Inverse-Gamma ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)) distribution.

Value

a list of parameters including m, V, a, b from a Normal-Inverse-Gamma distribution.

References

Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.

Examples

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

Description

Convert parameters from a Normal-Inverse-Gamma distribution to a Normal-Inverse-Chi-Squared distribution.

Usage

convert_gamma_to_chisq(gpar)

Arguments

gpar

a list of parameters including m, V, a, b from a Normal-Inverse-Gamma distribution.

Details

This function convert parameters from a Normal-Inverse-Gamma ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)) distribution to a Normal-Inverse-Chi-Squared ((μ,σ2)NIX(mean=μ,effectivesamplesize=κ,degreesoffreedom=ν,variance=σ2/κ)(\mu,\sigma^2) \sim NIX(mean=\mu,effective sample size=\kappa,degrees of freedom=\nu,variance=\sigma^2/\kappa)) distribution.

Value

a list of parameters including mu, kappa, nu, sigsq from a Normal-Inverse-Chi-Squared distribution.

References

Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.

Examples

convert_gamma_to_chisq(list(V=1/2,a=0.5,m=9.1/100,b=0.00002))

Allocation Probabilities Using Doubly Adaptive Biased Coin Design with Maximal Power Strategy for Binary Endpoint

Description

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.

Usage

dabcd_max_power(NN, Ntotal1, armn, BB, type, dabcd = FALSE, gamma = 2)

Arguments

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 [0,1/armn][0,1/armn].

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 dabcd=FALSE, this parameter does not need to be specified. Default value is set to 2.

Details

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.

Value

A vector of allocation probabilities to each arm.

Author(s)

Chuyao Xu, Thomas Lumley, Alain Vandal

References

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.

Examples

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')

Allocation Probabilities Using Doubly Adaptive Biased Coin Design with Minimal Variance Strategy for Binary Endpoint

Description

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.

Usage

dabcd_min_var(NN, Ntotal1, armn, type, dabcd = FALSE, gamma = 2)

Arguments

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 dabcd=FALSE, this parameter does not need to be specified. Default value is set to 2.

Details

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.

Value

A vector of allocation probabilities to each arm.

Author(s)

Chuyao Xu, Thomas Lumley, Alain Vandal

References

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.

Examples

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')

Cut-off Value of the Forward-looking Gittins Index Rule in Binary Endpoint

Description

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 (Beta(α,β)Beta(\alpha,\beta)) distributions and should be the same for each arm.

Usage

flgi_cut_off_binary(
  Gittinstype,
  df,
  gittins = NULL,
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  I0,
  K,
  noRuns2 = 100,
  Tsize,
  ptrue,
  block,
  rule,
  ztype
)

Arguments

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 bmab_gi_multiple_ab function from gittins package. If gittins is provided, Gittinstype and df should be 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.

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'.

Details

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

Value of Z test statistics for one trial.

References

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.

Examples

#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.

Cut-off Value of the Forward-looking Gittins Index Rule in Continuous Endpoint with Known Variances

Description

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 (N(mean,sd)N(mean,sd)) distributions and should be the same for each arm.

Usage

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
)

Arguments

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 gittins is provided, Gittinstype and df should be 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.

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'.

Details

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

Value of Z test statistics for one trial.

References

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.

Examples

#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.

Cut-off Value of the Forward-looking Gittins Index rule in Continuous Endpoint with Unknown Variances

Description

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) ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)) distributions and should be the same for each arm.

Usage

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
)

Arguments

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 gittins is provided, Gittinstype and df should be 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.

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'.

Details

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

Value of T test statistics for one trial.

References

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.

Examples

#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 Indices

Description

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.

Usage

Gittins(Gittinstype, df)

Arguments

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 Gittinstype in 'UNKV' and 'KV'; 0, 0.5, 0.7, 0.99 and 0.995 for Gittinstype in 'binary'.

Details

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).

Value

A vector of Gittins indices for Gittinstype in 'UNKV' and 'KV'. A matrix of Gittins indices for Gittinstype in 'Binary'.

References

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.

Examples

Gittins(Gittinstype='KV',df=0.5)

Gittins(Gittinstype='Binary',df=0.995)
Gittins(Gittinstype='UNKV',df=0.99)

Calculate the Futility Stopping Probability for Binary Endpoint with Beta Distribution

Description

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 (Beta(α,β)Beta(\alpha,\beta)) distributions and can be specified individually for each treatment group.

Usage

pgreater_beta(a1, b1, a2, b2, delta, side, ...)

Arguments

a1, b1

α\alpha and β\beta in Beta(α,β)Beta(\alpha,\beta), current estimated α\alpha for the control group.

a2, b2

α\alpha and β\beta in Beta(α,β)Beta(\alpha,\beta), current estimated α\alpha for the treatment group which is compared to the control group.

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.

Details

This function calculates the results of Pr(pk>pcontrol+δdata)Pr(p_k>p_{control}+\delta|data) for side equals to 'upper' and the results of Pr(pcontrol>pk+δdata)Pr(p_{control}>p_k+\delta|data) for side equals to 'lower'. The result indicates the posterior probability of stopping a treatment group due to futility around 1%1\% in Bayesian response-adaptive randomization with a control arm using Thall &\& Wathen method, with accumulated results during the conduct of trials.

Value

a posterior probability of Pr(pk>pcontrol+δdata)Pr(p_k>p_{control}+\delta|data) with side equals to 'upper'; a posterior probability of Pr(pcontrol>pk+δdata)Pr(p_{control}>p_k+\delta|data) with side equals to 'lower'.

References

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.

Examples

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 for Continuous Endpoint with Unknown Variances Using a Normal-Inverse-Chi-Squared Distribution

Description

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.

Usage

pgreater_NIX(par1, par2, delta = 0, side, ...)

Arguments

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.

Details

This function calculates the results of Pr(μk>μcontrol+δdata)Pr(\mu_k>\mu_{control}+\delta|data) for side equals to 'upper' and the results of Pr(μcontrol>μk+δdata)Pr(\mu_{control}>\mu_k+\delta|data) for side equals to 'lower'. The result indicates the posterior probability of stopping a treatment group due to futility around 1%1\% 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 ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)) distribution should be converted to parameters equivalent in a Normal-Inverse-Chi-Squared ((μ,σ2)NIX(mean=μ,effectivesamplesize=κ,degreesoffreedom=ν,variance=σ2/κ)(\mu,\sigma^2) \sim NIX(mean=\mu,effective sample size=\kappa,degrees of freedom=\nu,variance=\sigma^2/\kappa)) distribution using convert_gamma_to_chisq before applying this function.

Value

a posterior probability of Pr(μk>μcontrol+δdata)Pr(\mu_k>\mu_{control}+\delta|data) with side equals to 'upper'; a posterior probability of Pr(μcontrol>μk+δdata)Pr(\mu_{control}>\mu_k+\delta|data) with side equals to 'lower'.

References

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.

Examples

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 for Continuous Endpoint with Known Variances Using Normal Distribution

Description

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 (N(mean,sd)N(mean,sd)) distributions and can be specified individually for each treatment group.

Usage

pgreater_normal(
  mean1 = NULL,
  sd1 = NULL,
  mean2 = NULL,
  sd2 = NULL,
  delta = 0,
  side,
  ...
)

Arguments

mean1, sd1

mean and sd in N(mean,sd)N(mean,sd), current estimated mean and sd for the control group.

mean2, sd2

mean and sd in N(mean,sd)N(mean,sd), current estimated mean and sd for the treatment group which is compared to the control 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.

Details

This function calculates the results of Pr(μk>μcontrol+δdata)Pr(\mu_k>\mu_{control}+\delta|data) for side equals to 'upper' and the results of Pr(μcontrol>μk+δdata)Pr(\mu_{control}>\mu_k+\delta|data) for side equals to 'lower'. The result indicates the posterior probability of stopping a treatment group due to futility around 1%1\% in Bayesian response-adaptive randomization with a control arm using Thall &\& Wathen method, with accumulated results during the conduct of trials.

Value

a posterior probability of Pr(μk>μcontrol+δdata)Pr(\mu_k>\mu_{control}+\delta|data) with side equals to 'upper'; a posterior probability of Pr(μcontrol>μk+δdata)Pr(\mu_{control}>\mu_k+\delta|data) with side equals to 'lower'.

References

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.

Examples

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')

Posterior Probability that a Particular Arm is the Best for Binary Endpoint

Description

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 (Beta(α,β)Beta(\alpha,\beta)) distributions for binary outcomes in each arm and can be specified individually.

Usage

pmax_beta(
  armn,
  a1 = NULL,
  b1 = NULL,
  a2 = NULL,
  b2 = NULL,
  a3 = NULL,
  b3 = NULL,
  a4 = NULL,
  b4 = NULL,
  a5 = NULL,
  b5 = NULL,
  side,
  ...
)

Arguments

armn

number of arms in the trial with values up to 5. When armn=2, only a1 to a2 and b1 to b2 need to be specified. When armn=3, only a1 to a3 and b1 to b3 need to be specified. When armn=4, only a1 to a4 and b1 to b4 need to be specified. When armn=5, a1 to a5 and b1 to b5 need to be specified.

a1, b1

α\alpha and β\beta in Beta(α,β)Beta(\alpha,\beta) for the arm to calculate the allocation probability of.

a2, b2

α\alpha and β\beta in Beta(α,β)Beta(\alpha,\beta) for one of the remaining arms.

a3, b3

α\alpha and β\beta in Beta(α,β)Beta(\alpha,\beta) for one of the remaining arms.

a4, b4

α\alpha and β\beta in Beta(α,β)Beta(\alpha,\beta) for one of the remaining arms.

a5, b5

α\alpha and β\beta in Beta(α,β)Beta(\alpha,\beta) for one of the remaining arms.

side

direction of a one-sided test, with values 'upper' or 'lower'.

...

additional arguments to be passed to integrate (such as rel.tol) from this function.

Details

This function calculates the results of formula Pr(pk=max{p1,...,pK})Pr(p_k=max\{p_1,...,p_K\}) for side equals to 'upper' and the results of formula Pr(pk=min{p1,...,pK})Pr(p_k=min\{p_1,...,p_K\}) for side equals to 'lower'. This function returns the probability that the posterior probability of arm kk is maximal or minimal in trials with up to five arms.

Value

a probability that a particular arm is the best in trials up to five arms.

Examples

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')

Posterior Probability that a Particular Arm is the Best for Continuous Endpoint with Unknown Variances

Description

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.

Usage

pmax_NIX(
  armn,
  par1 = NULL,
  par2 = NULL,
  par3 = NULL,
  par4 = NULL,
  par5 = NULL,
  side,
  ...
)

Arguments

armn

number of arms in the trial with values up to 5. When armn=2, only par1 to par2 need to be specified. When par1 to par3 need to be specified. When par1 to par4 need to be specified. When par1 to par5 need to be specified.

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 integrate (such as rel.tol) from this function.

Details

This function calculates the results of formula Pr(μk=max{μ1,...,μk})Pr(\mu_k=max\{\mu_1,...,\mu_k\}) for side equals to 'upper' and the results of formula Pr(μk=min{μ1,...,μk})Pr(\mu_k=min\{\mu_1,...,\mu_k\}) for side equals to 'lower'. This function returns the probability that the posterior probability of arm kk is maximal or minimal in trials with up to five arms. Parameters used in a Normal-Inverse-Gamma ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)) distribution should be converted to parameters equivalent in a Normal-Inverse-Chi-Squared ((μ,σ2)NIX(mean=μ,effectivesamplesize=κ,degreesoffreedom=ν,variance=σ2/κ)(\mu,\sigma^2) \sim NIX(mean=\mu,effective sample size=\kappa,degrees of freedom=\nu,variance=\sigma^2/\kappa)) distribution using convert_gamma_to_chisq before applying this function.

Value

a probability that a particular arm is the best in trials up to five arms.

Examples

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')

Posterior Probability that a Particular Arm is the Best for Continuous Endpoint with Known Variances

Description

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 (N(mean,sd)N(mean,sd)) distributions for continuous outcomes with known variance in each arm and can be specified individually.

Usage

pmax_normal(
  armn,
  mean1 = NULL,
  sd1 = NULL,
  mean2 = NULL,
  sd2 = NULL,
  mean3 = NULL,
  sd3 = NULL,
  mean4 = NULL,
  sd4 = NULL,
  mean5 = NULL,
  sd5 = NULL,
  side,
  ...
)

Arguments

armn

number of arms in the trial with values up to 5. When armn=2, only mean1 to mean2 and sd1 to sd2 need to be specified. When armn=3, only mean1 to mean3 and sd1 to sd3 need to be specified. When armn=4, only mean1 to mean4 and sd1 to sd4 need to be specified. When armn=5, mean1 to mean5 and sd1 to sd5 need to be specified.

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 integrate (such as rel.tol) from this function.

Details

This function calculates the results of formula Pr(μk=max{μ1,...,μK})Pr(\mu_k=max\{\mu_1,...,\mu_K\}) for side equals to 'upper' and the results of formula Pr(μk=min{μ1,...,μK})Pr(\mu_k=min\{\mu_1,...,\mu_K\}) for side equals to 'lower'. This function returns the probability that the posterior probability of arm kk is maximal or minimal in trials with up to five arms.

Value

a probability that a particular arm is the best in trials up to five arms.

Examples

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')

Simulate a Trial Using A-Optimal Allocation for Continuous Endpoint with Known Variances

Description

sim_A_optimal_known_var simulates a trial for continuous endpoints with known variances, and allocation ratios are fixed.

Usage

sim_A_optimal_known_var(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  N2,
  armn,
  mean,
  sd,
  alphaa = 0.025,
  armlabel,
  side
)

Arguments

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'.

Details

This function aims to minimize the criteria tr[M1(ρ)]tr[M^{-1}(\mathbf{\rho})] 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.

Value

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.

Author(s)

Chuyao Xu, Thomas Lumley, Alain Vandal

References

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.

Examples

#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')

Simulate a Trial Using A-Optimal Allocation for Continuous Endpoint with Unknown Variances

Description

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.

Usage

sim_A_optimal_unknown_var(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  N1,
  N2,
  armn,
  mean,
  sd,
  alphaa = 0.025,
  armlabel,
  side
)

Arguments

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'.

Details

This function aims to minimize the criteria tr[M1(ρ)]tr[M^{-1}(\mathbf{\rho})] 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.

Value

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.

Author(s)

Chuyao Xu, Thomas Lumley, Alain Vandal

References

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.

Examples

#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')

Simulate a Trial Using Aa-Optimal Allocation for Continuous Endpoint with Known Variances

Description

sim_Aa_optimal_known_var simulates a trial for continuous endpoints with known variances, and the allocation probabilities are fixed.

Usage

sim_Aa_optimal_known_var(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  N2,
  armn,
  mean,
  sd,
  alphaa = 0.025,
  armlabel,
  side
)

Arguments

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'.

Details

This function aims to minimize the criteria tr[ATM1(ρ)A]tr[A^TM^{-1}(\rho)A] 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.

Value

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.

References

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.

Examples

#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')

Simulate a Trial Using Aa-Optimal Allocation for Continuous Endpoint with Unknown Variances

Description

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.

Usage

sim_Aa_optimal_unknown_var(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  N1,
  N2,
  armn,
  mean,
  sd,
  alphaa = 0.025,
  armlabel,
  side
)

Arguments

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'.

Details

This function aims to minimize the criteria tr[ATM1(ρ)A]tr[A^TM^{-1}(\rho)A] 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.

Value

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.

Author(s)

Chuyao Xu, Thomas Lumley, Alain Vandal

References

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.

Examples

#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')

Simulate a Trial Using Bayesian Response-Adaptive Randomization with a Control Group for Binary Outcomes

Description

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 (Beta(α,β)Beta(\alpha,\beta)) distributions and can be specified individually for each arm.

Usage

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,
  ...
)

Arguments

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

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta), prior for arm 1 which stands for the control. Default value is set to 1.

alpha2, beta2

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta), prior for arm 2. Default value is set to alpha1 and beta1.

alpha3, beta3

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta) prior for arm 3. Default value is set to alpha1 and beta1.

alpha4, beta4

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta) prior for arm 4. Default value is set to alpha1 and beta1..

alpha5, beta5

α\alpha and β\beta in the Beta(α,β)Beta(\alpha,\beta) prior for arm 5. Default value is set to alpha1 and beta1.

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 1%1\%. The length of this parameter is armn-1.

tpp

indicator of tp equals to n/2N. When tp is n/2N, tpp should be assigned 1. Default value is set to 0.

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 armn-1.

side

direction of a one-sided test, with values 'upper' or 'lower'.

...

additional arguments to be passed to integrate (such as rel.tol) from this function.

Details

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 Pr(pk=max{p1,...,pK})tpk=1KPr(pk=max{p1,...,pK})tp\frac{Pr(p_k=max\{p_1,...,p_K\})^{tp}} {\sum_{k=1}^{K}{Pr(p_k=max\{p_1,...,p_K\})^{tp}}} with side equals to 'upper', and Pr(pk=min{p1,...,pK})tpk=1KPr(pk=min{p1,...,pK})tp\frac{Pr(p_k=min\{p_1,...,p_K\})^{tp}} {\sum_{k=1}^{K}{Pr(p_k=min\{p_1,...,p_K\}){tp}}} 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.

Value

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.

References

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.

Examples

#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')

Simulate a Trial Using Bayesian Response-Adaptive Randomization with a Control Group for Continuous Endpoint with Known Variances

Description

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 (N(mean,sd)N(mean,sd)) distributions and can be specified individually for each arm.

Usage

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,
  ...
)

Arguments

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 1%1\%. The length of this parameter is armn-1.

tpp

indicator of tp equals to n/2N. When tp is n/2N, tpp should be assigned 1. Default value is set to 0.

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 armn-1.

mean10, sd10

prior mean and sd in N(mean,sd)N(mean,sd) of arm 1 in the trial, which stands for the control. Default value is set to 1.

mean20, sd20

prior mean and sd in N(mean,sd)N(mean,sd) of arm 2 in the trial. Default value is set to mean10 and sd10.

mean30, sd30

prior mean and sd in N(mean,sd)N(mean,sd) of arm 3 in the trial. Default value is set to mean10 and sd10.

mean40, sd40

prior mean and sd in N(mean,sd)N(mean,sd) of arm 4 in the trial. Default value is set to mean10 and sd10.

mean50, sd50

prior mean and sd in N(mean,sd)N(mean,sd) of arm 5 in the trial. Default value is set to mean10 and sd10.

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 n10.

n30

explicit prior n of arm 3 in the trial. Default value is set to n10.

n40

explicit prior n of arm 4 in the trial. Default value is set to n10.

n50

explicit prior n of arm 5 in the trial. Default value is set to n10.

side

direction of a one-sided test, with values 'upper' or 'lower'.

...

additional arguments to be passed to integrate (such as rel.tol) from this function.

Details

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 Pr(μk=max{μ1,...,μK})tpk=1KPr(μk=max{μ1,...,μK})tp\frac{Pr(\mu_k=max\{\mu_1,...,\mu_K\})^{tp}} {\sum_{k=1}^{K}{Pr(\mu_k=max\{\mu_1,...,\mu_K\})^{tp}}} with side equals to 'upper', and Pr(μk=min{μ1,...,μK})tpk=1KPr(μk=min{μ1,...,μK})tp\frac{Pr(\mu_k=min\{\mu_1,...,\mu_K\})^{tp}} {\sum_{k=1}^{K}{Pr(\mu_k=min\{\mu_1,...,\mu_K\}){tp}}} 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.

Value

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.

References

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.

Examples

#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')

Simulate a Trial Using Bayesian Response-Adaptive Randomization with a Control Group for Continuous Endpoint with Unknown Variances

Description

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) ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)) distributions and can be specified individually for each arm.

Usage

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,
  ...
)

Arguments

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 1%1\%. The length of this parameter is armn-1.

tpp

indicator of tp equals to n/2N. When tp is n/2N, tpp should be assigned 1. Default value is set to 0.

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 armn-1.

V01, a01, b01, m01

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 1 in the trial, which stands for the control.

V02, a02, b02, m02

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 2 in the trial. Default value is set to V01, a01, b01 and m01.

V03, a03, b03, m03

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 3 in the trial. Default value is set to V01, a01, b01 and m01.

V04, a04, b04, m04

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 4 in the trial. Default value is set to V01, a01, b01 and m01.

V05, a05, b05, m05

prior parameters m, V, a, b in NIG(V,m,a,b)NIG(V,m,a,b) of arm 5 in the trial. Default value is set to V01, a01, b01 and m01.

side

direction of a one-sided test, with values 'upper' or 'lower'.

...

additional arguments to be passed to integrate (such as rel.tol) from this function.

Details

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 Pr(μk=max{μ1,...,μK})tpk=1KPr(μk=max{μ1,...,μK})tp\frac{Pr(\mu_k=max\{\mu_1,...,\mu_K\})^{tp}} {\sum_{k=1}^{K}{Pr(\mu_k=max\{\mu_1,...,\mu_K\})^{tp}}} with side equals to 'upper', and Pr(μk=min{μ1,...,μK})tpk=1KPr(μk=min{μ1,...,μK})tp\frac{Pr(\mu_k=min\{\mu_1,...,\mu_K\})^{tp}} {\sum_{k=1}^{K}{Pr(\mu_k=min\{\mu_1,...,\mu_K\}){tp}}} 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.

Value

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.

References

Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.

Examples

#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')

Simulate a Trial Using Doubly Adaptive Biased Coin Design with Maximal Power Strategy for Binary Endpoint

Description

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.

Usage

sim_dabcd_max_power(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  N1,
  N2,
  armn,
  armlabel,
  h,
  BB,
  type,
  gamma = 2,
  alphaa = 0.025,
  side
)

Arguments

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 [0,1/armn][0,1/armn].

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'.

Details

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.

Value

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.

References

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.

Examples

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')

Simulate a Trial Using Doubly Adaptive Biased Coin Design with Minmial Variance Strategy for Binary Endpoint

Description

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.

Usage

sim_dabcd_min_var(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  N1,
  N2,
  armn,
  armlabel,
  h,
  type,
  gamma = 2,
  alphaa = 0.025,
  side
)

Arguments

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'.

Details

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.

Value

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.

References

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.

Examples

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')

Simulate a Trial Using Forward-Looking Gittins Index for Binary Endpoint

Description

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 (Beta(α,β)Beta(\alpha,\beta)) distributions and should be the same for each arm.

Usage

sim_flgi_binary(
  Gittinstype,
  df,
  gittins = NULL,
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  I0,
  K,
  noRuns2 = 100,
  Tsize,
  ptrue,
  block,
  rule,
  ztype,
  stopbound,
  side
)

Arguments

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 bmab_gi_multiple_ab function from gittins package. If gittins is provided, Gittinstype and df should be 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.

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'.

Details

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.

Value

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.

References

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.

Examples

#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')

Simulate a Trial Using Forward-Looking Gittins Index for Continuous Endpoint with Known Variances

Description

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 (N(mean,sd)N(mean,sd)) distributions and should be the same for each arm.

Usage

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
)

Arguments

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 gittins is provided, Gittinstype and df should be 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.

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'.

Details

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.

Value

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.

References

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.

Examples

#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')

Simulate a Trial Using Forward-Looking Gittins Index for Continuous Endpoint with Unknown Variances

Description

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) ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)) distributions and should be the same for each arm.

Usage

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
)

Arguments

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 gittins is provided, Gittinstype and df should be 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.

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'.

Details

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.

Value

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.

References

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.

Examples

#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 a Trial Using Randomized Play-the-Winner Rule for Binary Endpoint

Description

Simulate randomized play-the-winner rule in a two-armed trial with binary endpoint.

Usage

sim_RPTW(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  na0,
  nb0,
  na1,
  nb1,
  h,
  alphaa = 0.025,
  N2,
  side,
  Z = NULL
)

Arguments

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.

Details

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.

Value

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.

References

Wei LJ, Durham S (1978). “The Randomized Play-the-Winner Rule in Medical Trials.” Journal of the American Statistical Association, 73(364), 840–843.

Examples

#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')

Simulate a Trial Using Generalized RSIHR Allocation for Continuous Endpoint with Known Variances

Description

sim_RSIHR_optimal_known_var simulates a trial for continuous endpoints with known variances, and the allocation probabilities are fixed.

Usage

sim_RSIHR_optimal_known_var(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  N1,
  N2,
  armn,
  mean,
  sd,
  alphaa = 0.025,
  armlabel,
  cc,
  side
)

Arguments

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. cc is the same as C in the details.

side

direction of a one-sided test, with values 'upper' or 'lower'.

Details

This function aims to minimize the criteria i=1KniΨi\sum_{i=1}^{K}n_i\Psi_i with constraints σ12n1+σk2nkC\frac{\sigma_1^2}{n_1}+\frac{\sigma_k^2}{n_k}\leq C, where k=2,...,Kk=2,...,K 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.

Value

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.

References

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.

Examples

#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')

Simulate a Trial Using Generalized RSIHR Allocation for Continuous Endpoint with Unknown Variances

Description

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.

Usage

sim_RSIHR_optimal_unknown_var(
  Pats,
  nMax,
  TimeToOutcome,
  enrollrate,
  N1,
  N2,
  armn,
  mean,
  sd,
  alphaa = 0.025,
  armlabel,
  cc,
  side
)

Arguments

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. cc is the same as C in the details.

side

direction of a one-sided test, with values 'upper' or 'lower'.

Details

This function aims to minimize the criteria i=1KniΨi\sum_{i=1}^{K}n_i\Psi_i with constraints σ12n1+σk2nkC\frac{\sigma_1^2}{n_1}+\frac{\sigma_k^2}{n_k}\leq C, where k=2,...,Kk=2,...,K 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.

Value

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.

References

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.

Examples

#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 with Available Data

Description

Update parameters of a Normal-Inverse-Chi-Squared distribution

Usage

update_par_nichisq(y, par)

Arguments

y

observed data.

par

a vector of current parameters including mu, kappa, nu, sigsq from a Normal-Inverse-Chi-Squared distribution.

Details

This function updates parameters of a Normal-Inverse-Chi-Squared ((μ,σ2)NIX(mean=μ,effectivesamplesize=κ,degreesoffreedom=ν,variance=σ2/κ)(\mu,\sigma^2) \sim NIX(mean=\mu,effective sample size=\kappa,degrees of freedom=\nu,variance=\sigma^2/\kappa)) distribution with available data to parameters of a posterior Normal-Inverse-Gamma ((μ,σ2)NIG(mean=m,variance=V×σ2,shape=a,rate=b)(\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b))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.

Value

a list of parameters including mu, kappa, nu, sigsq for a posterior Normal-Inverse-Chi-Squared distribution incorporating available data.

References

Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.

Examples

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)