Learn R Programming

carat (version 1.1)

rand.test: Randomization Test

Description

Performs randomization test on treatment effects.

Usage

rand.test(data, Reps = 200, method = HuHuCAR, conf = 0.95, 
                         plot = TRUE, binwidth = 30, …)

Arguments

data

a dataframe. It consists of patients' profiles, treatment assignments and outputs. See getData.

Reps

an integer. It represents the number of randomized replications. It is suggested to be 200.

method

the randomization to be used in allocating patients. The default randomization HuHuCAR uses Hu and Hu's general covariate-adaptive randomization; the alternatives are PocSimMIN, StrBCD, StrPBR, DoptBCD and AdjBCD.

conf

confidence level of the interval. Default is 0.95.

plot

bool. It shows whether plot or not. Optional input: TRUE or FALSE.

binwidth

the number of bins for each bar in histogram. The default is 30.

arguments to be passed to methods. These depends on the method used and the following arguments are accepted:

omega

the vector of weights at the overall, within-stratum, and marginal levels. It is required that at least one element is larger than 0. Note that omega is only needed when HuHuCAR is to be used.

weight

the vector of weights for marginal imbalances. It is required that at least one element is larger than 0. Note that weight is only needed when PocSimMIN is to be used.

p

the probability of assigning one patient to treatment 1. p should be larger than 1/2 to obtain balance. Note that p is only needed when "HuHuCAR", "PocSimMIN" and "StrBCD" are to be used.

a

a design parameter. As a goes to \(\infty\), the design becomes more deterministic.

bsize

the block size for stratified randomization. It is required to be a multiple of 2. Note that bsize is only needed when "StrPBR" is to be used.

Value

It returns an object of class "htest".

The function print is used to obtain results.The generic accessor functions statistic, p.value and others extract various useful features of the value returned by rand.test.

An object of class "htest" is a list containing at least the following components:

data.name

a character string giving the name(s) of the data.

statistic

the value of the t-statistic. As the randomization test is a nonparametric method, we cannot calculate the t-statistic, so it is hidden in this result.

p.value

p-value of the test, the null hypothesis is rejected if the p-value is less than sl.

conf.int

a confidence interval under the chosen level conf for the difference in treatment effect between treatment 1 and treatment 2. As the randomization test is a nonparametric method, we cannot calculate the confidence interval, so it is hidden in this result.

estimate

the estimated difference in treatment effects between treatment 1 and treatment 2.

method

a character string indicating what type of test was performed.

Details

The randomization test is described as follows: 1) For the observed responses \(Y_1,\dots,Y_n\) and the treatment assignments \(T_1,T_2,\dots,T_n\), compute the observed test statistic $$S_{obs} = \frac{-\sum_{i=1}^nY_i*(T_i-2)}{n_1}-\frac{\sum_{i=1}^n Y_i*(T_i-1)}{n_0}$$ where \(n_1\) is the number of patients assigned to treatment \(1\) and \(n_0\) is the number of patients assigned to treatment \(2\);

2) Perform the covariate-adaptive randomization procedure to obtain the new treatment assignments and calculate the corresponding test statistic \(S_i\). And repeat this process \(L\) times;

3) Calculate the two-sided Monte Carlo p-value estimator $$p = \frac{\sum_{l=1}^L I(|S_l|\ge |S_{obs}|)}{L}$$

References

Rosenberger W F, Lachin J M. Randomization in clinical trials: theory and practice[M]. John Wiley & Sons, 2015.

Examples

Run this code
# NOT RUN {
##generate data
set.seed(100)
n = 1000
cov_num = 5
level_num = c(2,2,2,2,2)
pr = rep(0.5,10)
beta = c(0.1,0.4,0.3,0.2,0.5)
mu1 = 0
mu2 = 0.01
sigma = 1
type = "linear"
p = 0.85

dataS = getData(n, cov_num, level_num, pr, type,
               beta, mu1, mu2, sigma, StrBCD, p)

#run the randomization test
library("ggplot2")
Strt = rand.test(data = dataS, Reps = 200,method = StrBCD, 
                conf = 0.95, plot = TRUE, binwidth = 30,
                p = 0.85)
Strt
# }

Run the code above in your browser using DataLab