Type: Package
Title: Response Adaptive Randomization with 'Frequentist' Approaches
Version: 0.1.5
Description: Provides functions and command-line user interface to generate allocation sequence by response-adaptive randomization for clinical trials. The package currently supports two families of frequentist response-adaptive randomization procedures, Doubly Adaptive Biased Coin Design ('DBCD') and Sequential Estimation-adjusted Urn Model ('SEU'), for binary and normal endpoints. One-sided proportion (or mean) difference and Chi-square (or 'ANOVA') hypothesis testing methods are also available in the package to facilitate the inference for treatment effect. Additionally, the package provides comprehensive and efficient tools to allow one to evaluate and compare the performance of randomization procedures and tests based on various criteria. For example, plots for relationship among assumed treatment effects, sample size, and power are provided. Five allocation functions for 'DBCD' and six addition rule functions for 'SEU' are implemented to target allocations such as 'Neyman', 'Rosenberger' Rosenberger et al. (2001) <doi:10.1111/j.0006-341X.2001.00909.x> and 'Urn' allocations.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.2.3
Imports: dplyr, ggplot2, latex2exp, magrittr, patchwork, stats, tidyr, data.table, reshape2, Rdpack
RdMacros: Rdpack
Suggests: spelling, testthat (≥ 3.0.0)
Config/testthat/edition: 3
Language: en-US
NeedsCompilation: no
Packaged: 2024-05-07 11:10:39 UTC; HUANGXX6
Author: Mengjia Yu [aut], Xiu Huang [aut, cre], Li Wang [aut], Hongjian Zhu [aut]
Maintainer: Xiu Huang <xiu.huang@aya.yale.edu>
Repository: CRAN
Date/Publication: 2024-05-07 12:40:03 UTC

Doubly Adaptive Biased Coin Design (Binary Responses)

Description

Allocates patients to one of treatments based on doubly adaptive biased coin design on summary level data.

Usage

DBCD_BINARY(S_RK, N_RK, group_allo, rho_func_index, rho_func, alpha)

Arguments

S_RK

A vector of current success rates for each treatment arm.

N_RK

A vector of current enrolled subjects in each arm. The length must be the same as 'S_RK'.

group_allo

An integer of the size of group allocation. The default is 1.

rho_func_index

Supply a number of 1, 2 or 3 indicting the allocation function to use. 1 = Wei's allocation; 2 = Neyman allocation; 3 = Rosenberger allocation. The default is 3.

rho_func

Supply a user-specified allocation function of S_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2.

Details

'DBCD_BINARY' assigns the next subject to a group given the observed success rates, enrolled subjects and allocation function.

Value

Number of the arm that the next subject is assigned to.

Examples

# There are 3 arms each of which receives 25 patients.
# The observed response rates are 40%, 28% and 60%, respectively.
# The following command returns the number of arm that the next patient will
# be assigned to.
DBCD_BINARY(S_RK = c(0.4, 0.28, 0.6),
            N_RK = c(25, 25, 25),
            rho_func_index = 3, alpha=2)

# Urn allocation
DBCD_BINARY(S_RK = c(0.4, 0.3),
            N_RK = c(25, 25),
            group_allo = 1,
            rho_func_index = NULL,
            rho_func = function(x) rev(1-x)/sum(1-x),
            alpha=2)


Doubly Adaptive Biased Coin Design (Binary Data Frame)

Description

Allocates patients to one of treatments based on doubly adaptive biased coin design on individual data.

Usage

DBCD_BINARY_raw(X.df, group_allo, rho_func_index, rho_func, alpha)

Arguments

X.df

A data frame of two columns: treatment arm and response value.

group_allo

An integer of the size of group allocation. The default is 1.

rho_func_index

Supply a number of 1, 2 or 3 indicting the allocation function to use. 1 = Wei's allocation 2 = Neyman allocation; 3 = Rosenberger allocation. The default is 3.

rho_func

Supply a user-specified allocation function of sample response rates when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2.

Details

'DBCD_BINARY_raw' assigns the next subject to a group given the observed success rates, enrolled subjects and allocation function.

Value

Code of the arm that the next subject is assigned to.

Examples

X.df = data.frame(
ARM = sample(LETTERS[1:3],50,replace = TRUE),
RESPONSE = sample(c(0,1),50,replace = TRUE)
)
DBCD_BINARY_raw(X.df, rho_func_index = 3, alpha=2)

X.df = data.frame(
ARM = sample(LETTERS[1:2],40,replace = TRUE),
RESPONSE = sample(c(0,1),40,replace = TRUE)
)
DBCD_BINARY_raw(
X.df, rho_func_index = NULL,
rho_func = function(x) rev(1-x)/sum(1-x), alpha=2
)


Doubly Adaptive Biased Coin Design (Gaussian Responses)

Description

Allocates patients to one of treatments based on doubly adaptive biased coin design on summarized data.

Usage

DBCD_GAUSSIAN(Mean_RK,SD_RK, N_RK, group_allo, rho_func_index,
rho_func, alpha)

Arguments

Mean_RK

A vector of current response means for each treatment arm.

SD_RK

A vector of current response standard deviations for each treatment arm.

N_RK

A vector of current enrolled subjects in each arm. The length must be the same as 'Mean_RK'.

group_allo

An integer of the size of group allocation. The default is 1.

rho_func_index

Supply a number of 1 or 2 indicting the allocation function to use. 1 = Zhang-Rosenberger allocation; 2 = Neyman allocation. The default is 2.

rho_func

Supply a user-specified allocation function of Mean_RK and SD_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2.

Details

'DBCD_GAUSSIAN' assigns the next subject to a group given the observed success rates, enrolled subjects and allocation function.

Value

Number of the arm that the next subject is assigned to.

Examples

# There are 2 arms each of which receives 10 patients.
# The observed response means are 4.5 and 5, respectively.
# The following command returns the number of arm that the next patient will
# be assigned to.
DBCD_GAUSSIAN(Mean_RK = c(4.5,5),
SD_RK = c(1.32,0.72),
N_RK = c(10,10),
rho_func_index = 2, alpha=2)

DBCD_GAUSSIAN(Mean_RK = c(4.5,5),
SD_RK = c(1.32,0.72),
N_RK = c(10,10),
rho_func_index = 1, alpha=2)


Doubly Adaptive Biased Coin Design (Gaussian Responses)

Description

Allocates patients to one of treatments based on doubly adaptive biased coin design on summarized data.

Usage

DBCD_GAUSSIAN_raw(X.df, group_allo, rho_func_index, rho_func, alpha)

Arguments

X.df

A data frame of two columns: treatment arm and response value.

group_allo

An integer of the size of group allocation. The default is 1.

rho_func_index

Supply a number of 1, 2 or 3 indicting the allocation function to use. (TODO: add reference) 1 = Zhang-Rosenberger allocation; 2 = Neyman allocation. The default is 2.

rho_func

Supply a user-specified allocation function of Mean_RK and SD_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2. (Hu and Zhang 2004)

Details

'DBCD_GAUSSIAN' assigns the next subject to a group given the observed success rates, enrolled subjects and allocation function.

Value

Number of the arm that the next subject is assigned to.

References

Hu F, Zhang L (2004). “Asymptotic Properties of Doubly Adaptive Biased Coin Designs for Multitreatment Clinical Trials.” The Annals of Statistics. doi: 10.1214/aos/1079120137.

Examples

X.df = data.frame(
ARM = sample(LETTERS[1:2],50,replace = TRUE),
RESPONSE = rnorm(50)
)

DBCD_GAUSSIAN_raw(X.df)


Sequential Estimation-adjusted Urn Model (Binary Data)

Description

Allocates patients to one of treatments based on sequential estimation-adjusted urn model (SEU) on summarized data.

Usage

SEU_BINARY_raw(x.df, urn_comp, arms, group_allo, add_rule_index,
add_rule)

Arguments

x.df

A data frame of two columns: treatment arm and response value.

urn_comp

A vector of current urn composition.

arms

A vector of arm names. If it is not provided, the arms occurred in x.df will be assumed as all possible arms. Suggest to always assign arms.

group_allo

An integer of the size of group allocation. The default is 1.

add_rule_index

Supply a number of 1, 2 or 3 indicting the addition rules to target allocation functions. 1 = randomized play-the-winner (RPW) rule that targets the urn allocation 2 = the SEU model that targets Neyman allocation; 3 = the SEU model that targets Rosenberger allocation;' 4 = the SEU model that assigns probability of 0.6+1/K to winner at each step. The default is 1.

add_rule

Supply a user-specified addition rules function of x.df and arms when add_rule_index is NULL. Default is NULL.

Details

'SEU_BINARY_raw' assigns the next subject to a group given the observed data, current urn composition, full list of arm codes, number of group allocation and addition rule function.

Value

Code of arms that the next group of subjects assigned to and the updated urn composition.

Examples

x.df = data.frame(
ARM = sample(LETTERS[1:3],50,replace = TRUE),
RESPONSE = sample(c(0,1),50,replace = TRUE)
)
SEU_BINARY_raw(x.df, urn_comp=c(0,0,0), arms=c("A","B","C"))

x.df = data.frame(
ARM = sample(LETTERS[1:2],40,replace = TRUE),
RESPONSE = sample(c(0,1),40,replace = TRUE)
)
SEU_BINARY_raw(x.df,
urn_comp=c(0,0),
arms=c("A","B"),
group_allo = 1,
add_rule_index = 3)


Sequential Estimation-adjusted Urn Model (Gaussian Responses)

Description

Allocates patients to one of treatments based on sequential estimation-adjusted urn model (SEU) on summarized data.

Usage

SEU_GAUSSIAN_raw(x.df, urn_comp, arms, group_allo,
add_rule_index, add_rule)

Arguments

x.df

A data frame of two columns: treatment arm and response value. treatment arm.

urn_comp

A vector of current urn composition.

arms

A vector of arm names. If it is not provided, the arms occurred in x.df will be assumed as all possible arms. Suggest to always assign arms.

group_allo

An integer of the size of group allocation. The default is 1.

add_rule_index

Supply a number of 1 or 2 indicting the addition rules to target allocation functions. 1 = the SEU model targeting Neyman allocation; 2 = the SEU model that assigns probability of 0.6+1/K to winner at each step. The default is 1.

add_rule

Supply a user-specified addition rules function of x.df and arms when add_rule_index is NULL. Default is NULL.

Details

'SEU_GAUSSIAN' assigns the next subject to a group given the observed success rates, enrolled subjects and allocation function.

Value

Number of the arm that the next subject is assigned to.

Examples

x.df = data.frame(
ARM = sample(LETTERS[1:2],50,replace = TRUE),
RESPONSE = rnorm(50)
)

SEU_GAUSSIAN_raw(x.df,
urn_comp=c(0,0),
arms=c("A","B"),
group_allo = 1,
add_rule_index = 1)


Comparison of Powers for Treatment Effects under Different SEU Randomization Methods (Binary Responses)

Description

Compares the power of a 2-arm design under different treatment effects for the same sample size and placebo effect through matrices and plots.

Usage

SEU_power_comparison_Power_vs_Trt(n, nstart, p_pbo, p_trt, urn_comp,
nstop, replication, group_allo, add_rule_index, add_rule, add_rule_full,
sig_level)

Arguments

n

The number of patients. The default is 100.

nstart

Burn-in sample size of each arm. The default is n/20.

p_pbo

Success rate of placebo (control) arm. The default is 0.3.

p_trt

A vector containing success rates of treatment arm.

urn_comp

A vector of current urn composition. The default is NULL, which indicates no ball in the urn.

nstop

A vector of stopping cap of sample size for each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

add_rule_index

Supply a number of 1, 2 or 3 indicting the addition rules to target allocation functions. 1 = randomized play-the-winner (RPW) rule that targets the urn allocation 2 = the SEU model that targets Neyman allocation; 3 = the SEU model that targets Rosenberger allocation;' 4 = the SEU model that assigns probability of 0.6+1/K to winner at each step. The default is 1.

add_rule

Supply a user-specified addition rules function of x.df and arms when add_rule_index is NULL. Default is NULL. (See SEU_BINARY_raw for details on x.df and arms.)

add_rule_full

Indicator of reference data for updating addition rule. If TRUE, the addition rule is updated by full observation at each group allocation. If FALSE,the addition rule is updated by each group observation. The default is FALSE for add_rule_index=1 and TRUE otherwise.

sig_level

Significant level (one-sided). The default is 0.05.

Details

'SEU_power_comparison_Power_vs_Trt' reads different treatment effects and outputs allocation, estimated rates and powers.

Value

Examples


## Default setting
SEU_power_comparison_Power_vs_Trt(
n = 40,
nstart = round(40/20),
p_pbo = 0.3,
p_trt = seq(0,0.3,0.1)+0.3,
urn_comp = NULL,
nstop = NULL,
replication = 5,
group_allo = 1,
add_rule_index = 3,
add_rule = NULL,
add_rule_full = FALSE,
sig_level = 0.05
)


Comparison of Powers for Treatment Effects under Different SEU Randomization Methods (Gaussian Responses)

Description

Compares the power of a 2-arm design under different treatment effects for the same sample size and placebo effect through matrices and plots.

Usage

SEU_power_comparison_Power_vs_Trt_GAUSSIAN(n, nstart, mu_pbo, sd_pbo,
mu_trt, sd_trt, urn_comp, nstop, replication, group_allo, add_rule_index,
add_rule, add_rule_full, sig_level)

Arguments

n

The number of patients. The default is 100.

nstart

Burn-in sample size of each arm. The default is n/20.

mu_pbo

Mean response of placebo (control) arm. Default is 4.5.

sd_pbo

Response standard deviation of placebo (control) arm. Default is 1.32.

mu_trt

A vector containing mean responses of treatment.

sd_trt

A vector containing response standard deviations of treatment.

urn_comp

A vector of current urn composition. The default is NULL, which indicates no ball in the urn.

nstop

A vector of stopping cap of sample size for each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

add_rule_index

Supply a number of 1 or 2 indicting the addition rules to target allocation functions. 1 = the SEU model targeting Neyman allocation; 2 = the SEU model that assigns probability of 0.6+1/K to winner at each step. The default is 1.

add_rule

Supply a user-specified addition rules function of x.df and arms when add_rule_index is NULL. Default is NULL. (See SEU_GAUSSIAN_raw for details on x.df and arms.)

add_rule_full

Indicator of reference data for updating addition rule. If TRUE, the addition rule is updated by full observation at each group allocation. If FALSE,the addition rule is updated by each group observation. The default is TRUE.

sig_level

Significant level (one-sided). The default is 0.05.

Details

'SEU_power_comparison_Power_vs_Trt_GAUSSIAN' reads different treatment effects and outputs allocation, estimated rates and powers.

Value

Examples


## Default setting
SEU_power_comparison_Power_vs_Trt_GAUSSIAN(
n = 40,
nstart = round(40/20),
urn_comp = NULL,
nstop = NULL,
replication = 5,
group_allo = 1,
add_rule_index = 1,
add_rule = NULL,
add_rule_full = TRUE,
sig_level = 0.05
)



Comparison of Powers for Sample Sizes under Different SEU Randomization Methods (Binary Responses)

Description

Compares the power of tests under different sample sizes for the same treatment effects and design through matrices and plots.

Usage

SEU_power_comparison_Power_vs_n(n_seq, nstart_seq, p, urn_comp,
nstop_mat, replication, group_allo, add_rule_index, add_rule, add_rule_full,
sig_level)

Arguments

n_seq

A sequence of settings' number of patients. The default is c(50, 100, 150, 200).

nstart_seq

The burn-in sample size of each arm. The default is n_seq/20 = c(2, 5, 8, 10).

p

A vector of probabilities containing probabilities for each treatment arm (where the first element refers to the control arm). The length of p should correspond to the number of treatment arms. The default is p = c(0.3, 0.3, 0.6).

urn_comp

A vector of current urn composition. The default is NULL, which indicates no ball in the urn.

nstop_mat

A matrix of sample size stopping caps for each arm. Each row corresponds to each n in n_seq, and each column represents each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. The group_allo will be applied to all n (from each n_seq). Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

add_rule_index

Supply a number of 1, 2 or 3 indicting the addition rules to target allocation functions. 1 = randomized play-the-winner (RPW) rule that targets the urn allocation 2 = the SEU model that targets Neyman allocation; 3 = the SEU model that targets Rosenberger allocation;' 4 = the SEU model that assigns probability of 0.6+1/K to winner at each step. The default is 1.

add_rule

Supply a user-specified addition rules function of x.df and arms when add_rule_index is NULL. Default is NULL. (See SEU_BINARY_raw for details on x.df and arms.)

add_rule_full

Indicator of reference data for updating addition rule. If TRUE, the addition rule is updated by full observation at each group allocation. If FALSE,the addition rule is updated by each group observation. The default is FALSE for add_rule_index=1 and TRUE otherwise.

sig_level

Significant level (one-sided). The default is 0.05.

Details

'SEU_power_comparison_Power_vs_n' reads different sample sizes as well as the corresponding burn-in size and outputs allocation, estimated rates and powers.

Value

Examples


## Default setting
SEU_power_comparison_Power_vs_n(
n_seq = seq(from = 50, to = 200, by = 50),
nstart_seq = round(seq(from = 50, to = 200, by = 50) / 20),
p = c(0.3, 0.3, 0.6),
urn_comp = NULL,
nstop_mat = NULL,
replication = 4,
group_allo = 1,
add_rule_index = 1,
add_rule = NULL,
add_rule_full = FALSE,
sig_level = 0.05
)



Comparison of Powers for Sample Sizes under Different SEU Randomization Methods (Gaussian Responses)

Description

Compares the power of tests under different sample sizes for the same treatment effects and design through matrices and plots.

Usage

SEU_power_comparison_Power_vs_n_GAUSSIAN(n_seq, nstart_seq, mu, sd,
 urn_comp, nstop_mat, replication, group_allo, add_rule_index, add_rule,
 add_rule_full, sig_level)

Arguments

n_seq

A sequence of settings' number of patients. The default is c(50, 100, 150, 200).

nstart_seq

The burn-in sample size of each arm. The default is n_seq/20 = c(2, 5, 8, 10).

mu

A vector of mean response for each treatment arm (where the first element refers to the control arm). The length of mu should correspond to the number of arms. The default is mu = c(4.5,5).

sd

A vector of response standard deviations for each treatment arm. (where the first element refers to the control arm). The length of sd should correspond to the number of arms. The default is sd = c(1.32, 0.72).

urn_comp

A vector of current urn composition. The default is NULL, which indicates no ball in the urn.

nstop_mat

A matrix of sample size stopping caps for each arm. Each row corresponds to each n in n_seq, and each column represents each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. The group_allo will be applied to all n (from each n_seq). Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

add_rule_index

Supply a number of 1 or 2 indicting the addition rules to target allocation functions. 1 = the SEU model targeting Neyman allocation; 2 = the SEU model that assigns probability of 0.6+1/K to winner at each step. The default is 1.

add_rule

Supply a user-specified addition rules function of x.df and arms when add_rule_index is NULL. Default is NULL. (See SEU_GAUSSIAN_raw for details on x.df and arms.)

add_rule_full

Indicator of reference data for updating addition rule. If TRUE, the addition rule is updated by full observation at each group allocation. If FALSE,the addition rule is updated by each group observation. The default is TRUE.

sig_level

Significant level (one-sided). The default is 0.05.

Details

'SEU_power_comparison_Power_vs_n_GAUSSIAN' reads different sample sizes as well as the corresponding burn-in size and outputs allocation, estimated rates and powers.

Value

Examples


## Default setting
SEU_power_comparison_Power_vs_n_GAUSSIAN(
n_seq = seq(from = 50, to = 100, by = 50),
nstart_seq = round(seq(from = 50, to = 100, by = 50) / 20),
mu = c(4.5,5),
sd = c(1.32,0.72),
urn_comp = NULL,
nstop_mat = NULL,
replication = 5,
group_allo = 1,
add_rule_index = 1,
add_rule = NULL,
add_rule_full = NULL,
sig_level = 0.05
)



Sequential Estimation-adjusted Urn Model with Simulated Data (Binary Data)

Description

Allocates patients to one of treatments based on sequential estimation-adjusted urn model (SEU) with simulated data.

Usage

SEU_simulation_main(n, nstart, p, urn_comp, nstop, replication, group_allo,
 add_rule_index, add_rule, add_rule_full, sig_level)

Arguments

n

The number of patients. The default is 500.

nstart

Burn-in sample size of each arm. The default is n/20.

p

A vector containing response probabilities for each treatment arm (where the first element refers to the control arm). The length of p should correspond to the number of arms. The default is p = c(0.3, 0.3, 0.6).

urn_comp

A vector of current urn composition. The default is NULL, which indicates no ball in the urn.

nstop

A vector of stopping cap of sample size for each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

add_rule_index

Supply a number of 1, 2 or 3 indicting the addition rules to target allocation functions. 1 = randomized play-the-winner (RPW) rule that targets the urn allocation 2 = the SEU model that targets Neyman allocation; 3 = the SEU model that targets Rosenberger allocation;' 4 = the SEU model that assigns probability of 0.6+1/K to winner at each step. The default is 1.

add_rule

Supply a user-specified addition rules function of x.df and arms when add_rule_index is NULL. Default is NULL. (See SEU_BINARY_raw for details on x.df and arms.)

add_rule_full

Indicator of reference data for updating addition rule. If TRUE, the addition rule is updated by full observation at each group allocation. If FALSE,the addition rule is updated by each group observation. The default is FALSE for add_rule_index=1 and TRUE otherwise.

sig_level

Significant level (one-sided). The default is 0.05.

Details

'SEU_simulation_main' can sample response and adaptively randomize subjects group by group.

Value

Examples


## Default method
SEU_simulation_main(n = 500,
nstart = round(500 / 20),
p = c(0.3, 0.3, 0.6),
nstop=c(500,500,500),
urn_comp = c(0,0,0),
replication = 5,
group_allo = 1,
add_rule_index = 1,
add_rule_full = FALSE,
sig_level = 0.05
)


Sequential Estimation-adjusted Urn Model with Simulated Data (Gaussian Responses)

Description

Allocates patients to one of treatments based on sequential estimation-adjusted urn model (SEU) with simulated data.

Usage

SEU_simulation_main_GAUSSIAN(n, nstart, mu, sd, urn_comp, nstop,
 replication, group_allo, add_rule_index, add_rule,
 add_rule_full, sig_level)

Arguments

n

The number of patients. The default is 500.

nstart

Burn-in sample size of each arm. The default is n/20.

mu

A vector of mean response for each treatment arm (where the first element refers to the control arm). The length of mu should correspond to the number of arms. The default is mu = c(4.5,5).

sd

A vector of response standard deviations for each treatment arm. (where the first element refers to the control arm). The length of sd should correspond to the number of arms. The default is sd = c(1.32, 0.72).

urn_comp

A vector of current urn composition. The default is NULL, which indicates no ball in the urn.

nstop

A vector of stopping cap of sample size for each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

add_rule_index

Supply a number of 1 or 2 indicting the addition rules to target allocation functions. 1 = the SEU model targeting Neyman allocation; 2 = the SEU model that assigns probability of 0.6+1/K to winner at each step. The default is 1.

add_rule

Supply a user-specified addition rules function of x.df and arms when add_rule_index is NULL. Default is NULL. (See SEU_GAUSSIAN_raw for details on x.df and arms.)

add_rule_full

Indicator of reference data for updating addition rule. If TRUE, the addition rule is updated by full observation at each group allocation. If FALSE,the addition rule is updated by each group observation. The default is TRUE.

sig_level

Significant level (one-sided). The default is 0.05.

Details

'SEU_simulation_main_GAUSSIAN' can sample response and adaptively randomize subjects group by group.

Value

Examples


## Default method
SEU_simulation_main_GAUSSIAN(
n = 50,
nstart = round(50 / 20),
mu = c(4.5,5),
sd = c(1.32,0.72),
urn_comp = c(0,0),
nstop=c(50,50),
replication = 5,
group_allo = 1,
add_rule_index = 1,
add_rule = NULL,
add_rule_full = TRUE,
sig_level = 0.05
)


Comparison of Powers for Treatment Effects under Different DBCD Randomization Methods (Binary Responses)

Description

Compares the power of a 2-arm design under different treatment effects for the same sample size and placebo effect through matrices and plots.

Usage

power_comparison_Power_vs_Trt(n, nstart, p_pbo, p_trt, nstop,
replication, group_allo, rho_func_index, rho_func, alpha, sig_level)

Arguments

n

The number of patients. The default is 100.

nstart

Burn-in sample size of each arm. The default is n/20.

p_pbo

Success rate of placebo (control) arm. The default is 0.3.

p_trt

A vector containing success rates of treatment arm.

nstop

A vector of stopping cap of sample size for each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

rho_func_index

Supply a number of 1, 2 or 3 indicting the allocation function to use. 1 = Wei's allocation 2 = Neyman allocation; 3 (default) = Rosenberger allocation;

rho_func

Supply a user-specified allocation function of Mean_RK and SD_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2.

sig_level

Significant level. The default is 0.05.

Details

'power_comparison_Power_vs_Trt' reads different treatment effects and outputs allocation, estimated rates and powers.

Value

Examples

## Default setting
power_comparison_Power_vs_Trt(
n = 100,
nstart = round(100/20),
p_pbo = 0.3,
p_trt = seq(0,0.3,0.1)+0.3,
nstop = NULL,
replication = 5,
group_allo = 1,
rho_func_index = 3,
rho_func = NULL,
alpha = 2,
sig_level = 0.05
)



Comparison of Powers for Treatment Effects under Different DBCD Randomization methods (Gaussian Responses)

Description

Compares the power of a 2-arm design under different treatment effects for the same sample size and placebo effect through matrices and plots.

Usage

power_comparison_Power_vs_Trt_GAUSSIAN(n, nstart, mu_pbo, sd_pbo,
mu_trt, sd_trt, nstop, replication, group_allo, rho_func_index, rho_func,
alpha, sig_level)

Arguments

n

The number of patients. Default is 100.

nstart

Burn-in sample size of each arm. Default is n/20.

mu_pbo

Mean response of placebo (control) arm. Default is 4.5.

sd_pbo

Response standard deviation of placebo (control) arm. Default is 1.32.

mu_trt

A vector containing mean responses of treatment.

sd_trt

A vector containing response standard deviations of treatment.

nstop

A vector of stopping cap of sample size for each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

rho_func_index

Supply a number of 1 or 2 indicting the allocation function to use. 1 = Zhang-Rosenberger allocation (2-arm allocation only); 2 (default) = Neyman allocation.

rho_func

Supply a user-specified allocation function of Mean_RK and SD_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. Default is 2.

sig_level

Significant level. Default is 0.05.

Details

'power_comparison_Power_vs_Trt_GAUSSIAN' reads different treatment effects and outputs allocation, estimated rates and powers.

Value

Examples

## Default setting
power_comparison_Power_vs_Trt_GAUSSIAN(
n = 100,
nstart = round(100/20),
mu_pbo = 4.5,
sd_pbo = 1.32,
mu_trt = seq(0,0.6,0.2)+4.5,
sd_trt = rep(1.32,4),
nstop = NULL,
replication = 5,
group_allo = 1,
rho_func_index = 2,
rho_func = NULL,
alpha = 2,
sig_level = 0.05
)



Comparison of Powers for Different Tests under Different DBCD Randomization Methods (Binary Responses)

Description

Compares the power of tests under different sample sizes for the same treatment effect and design through matrices and plots.

Usage

power_comparison_Power_vs_n(n_seq, nstart_seq, p, nstop_mat,
replication, group_allo, rho_func_index, rho_func, alpha, sig_level)

Arguments

n_seq

A sequence of numbers of patients. The default is c(50, 100, 150, 200).

nstart_seq

The burn-in sample size of each arm. If NULL, n_seq/20 will be used.

p

A vector of probabilities containing probabilities for each treatment arm (where the first element refers to the control arm). The length of p should correspond to the number of treatment arms. The default is p = c(0.3, 0.3, 0.6).

nstop_mat

A matrix of sample size stopping caps for each arm. Each row corresponds to each n in n_seq, and each column represents each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. The group_allo will be applied to all n (from each n_seq). Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

rho_func_index

Supply a number of 1, 2 or 3 indicting the allocation function to use. 1 = Wei's allocation 2 = Neyman allocation; 3 (default) = Rosenberger allocation.

rho_func

Supply a user-specified allocation function of S_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2.

sig_level

Significant level. The default is 0.05.

Details

'power_comparison_Power_vs_n' reads different sample sizes as well as the corresponding burn-in size and outputs allocation, estimated rates and powers.

Value

Examples


## Default setting
power_comparison_Power_vs_n(
n_seq = seq(from = 50, to = 200, by = 50),
nstart_seq = round(seq(from = 50, to = 200, by = 50) / 20),
p = c(0.3, 0.3, 0.6),
nstop_mat = NULL,
replication = 5,
group_allo = 1,
rho_func_index = 3,
rho_func = NULL,
alpha = 2,
sig_level = 0.05
)



Comparison of Powers for Different Tests under Different DBCD Randomization Methods (Gaussian Responses)

Description

Compares the power of tests under different sample sizes for the same treatment effects and design through matrices and plots.

Usage

power_comparison_Power_vs_n_GAUSSIAN(n_seq, nstart_seq, mu, sd,
nstop_mat, replication, group_allo, rho_func_index, rho_func, alpha,
sig_level)

Arguments

n_seq

A sequence of numbers of patients. The default is c(50, 100, 150, 200).

nstart_seq

burn-in sample size of each arm. If NULL, n_seq/20 will be used.

mu

A vector of mean response for each treatment arm (where the first element refers to the control arm). The length of mu should correspond to the number of arms. The default is mu = c(4.5,5).

sd

A vector of response standard deviations for each treatment arm. (where the first element refers to the control arm). The length of sd should correspond to the number of arms. The default is sd = c(1.32, 0.72).

nstop_mat

A matrix of sample size stopping caps for each arm. Each row corresponds to each n in n_seq, and each column represents each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. The group_allo will be applied to all n (from each n_seq). Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

rho_func_index

Supply a number of 1 or 2 indicting the allocation function to use. 1 = Zhang-Rosenberger allocation; 2 (default) = Neyman allocation.

rho_func

Supply a user-specified allocation function of Mean_RK and SD_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2.

sig_level

Significant level. The default is 0.05.

Details

'power_comparison_Power_vs_n_GAUSSIAN' reads different sample sizes as well as the corresponding burn-in size and outputs allocation, estimated rates and powers.

Value

Examples


## Default setting
power_comparison_Power_vs_n_GAUSSIAN(
n_seq = seq(from = 50, to = 200, by = 50),
nstart_seq = round(seq(from = 50, to = 200, by = 50) / 20),
mu = c(4.5,5),
sd = c(1.32,0.72),
nstop_mat = NULL,
replication = 5,
group_allo = 1,
rho_func_index = 2,
rho_func = NULL,
alpha = 2,
sig_level = 0.05
)



Doubly Adaptive Biased Coin Design with Simulated Data (Binary Responses)

Description

Allocates patients to one of treatments based on the doubly adaptive biased coin design with simulated data.

Usage

simulation_main(n, nstart, p, nstop, replication, group_allo, rho_func_index,
rho_func, alpha, sig_level)

Arguments

n

The number of patients. The default is 500.

nstart

Burn-in sample size of each arm. The default is n/20.

p

A vector containing response probabilities for each treatment arm (where the first element refers to the control arm). The length of p should correspond to the number of arms. The default is p = c(0.3, 0.3, 0.6).

nstop

A vector of stopping cap of sample size for each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

rho_func_index

Supply a number of 1, 2 or 3 indicting the allocation function to use; default to 3. * 1 = Wei's allocation (Urn allocation); * 2 = Neyman allocation; * 3 (default) = Rosenberger allocation;

rho_func

Supply a user-specified allocation function of S_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2.

sig_level

Significant level (one-sided). The default is 0.05.

Details

'simulation_main' can sample response and adaptively randomize subjects group by group.

Value

Examples


## Default method
simulation_main(n = 500,
nstart = round(500 / 20),
p = c(0.3, 0.3, 0.6),
nstop=c(500,500,500),
replication = 5,
group_allo = 1,
rho_func_index = 3,
alpha = 2,
sig_level = 0.05
)


Doubly Adaptive Biased Coin Design with Simulated Data (Gaussian Responses)

Description

Allocates patients to one of treatments based on the doubly adaptive biased coin design with simulated data.

Usage

simulation_main_GAUSSIAN(n, nstart, mu, sd, nstop, replication, group_allo,
 rho_func_index, rho_func, alpha, sig_level)

Arguments

n

The number of patients. The default is 500.

nstart

Burn-in sample size of each arm. The default is n/20.

mu

A vector of mean response for each treatment arm (where the first element refers to the control arm). The length of mu should correspond to the number of arms. The default is mu = c(4.5,5).

sd

A vector of response standard deviations for each treatment arm. (where the first element refers to the control arm). The length of sd should correspond to the number of arms. The default is sd = c(1.32, 0.72).

nstop

A vector of stopping cap of sample size for each arm. The trial stops if at least one arm reaches the corresponding cap. The default is NULL, which means no cap.

replication

the number of replications of the simulation. The default is 100.

group_allo

A number or a vector of group size(s) for allocation. If a number is given, the allocation ratios will be updated for each batch of group_allo samples. If a vector is given, the allocation ratios will be updated sequentially in group according to the vector. Any value greater than n will be omitted. The default is group_allo=1, which is the same as group_allo = seq(nstart*length(p)+1,n).

rho_func_index

Supply a number of 1 or 2 indicting the allocation function to use. 1 = Zhang-Rosenberger allocation (2-arm allocation only); 2 (default) = Neyman allocation.

rho_func

Supply a user-specified allocation function of Mean_RK and SD_RK when rho_func_index is NULL. Default is NULL.

alpha

Supply a number indicating the subscripts of the probability function. The default is 2.

sig_level

Significant level. The default is 0.05.

Details

'simulation_main_GAUSSIAN' can sample response and adaptively randomize subjects group by group.

Value

Examples


## Default method
simulation_main_GAUSSIAN(
n = 500,
nstart = round(500 / 20),
mu = c(4.5,5),
sd = c(1.32,0.72),
nstop=c(500,500),
replication = 5,
group_allo = 1,
rho_func_index = 2,
rho_func = NULL,
alpha = 2,
sig_level = 0.05
)