rand.test {carat} | R Documentation |
Randomization Test
Description
Performs randomization test on treatment effects.
Usage
rand.test(data, Reps = 200, method = c("HuHuCAR", "PocSimMIN", "StrBCD",
"StrPBR", "DoptBCD", "AdjBCD"),
conf = 0.95, binwidth = 30, ...)
Arguments
data |
a data frame. It consists of patients' profiles, treatment assignments and outputs. See |
Reps |
an integer. It is the number of randomized replications used in the randomization test. The default is |
method |
the randomization procedure to be used for testing. This package provides tests for |
conf |
confidence level of the interval. The default is |
binwidth |
the number of bins for each bar in histogram. The default is 30. |
... |
arguments to be passed to
|
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}
Value
It returns an object of class "htest"
.
An object of class "htest"
is a list containing the following components:
p.value |
p-value of the test, the null hypothesis is rejected if the p-value is less than |
estimate |
the estimated difference in treatment effects between treatment |
conf.int |
a confidence interval under the chosen level |
method |
a character string indicating what type of test was performed. |
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. |
References
Ma W, Ye X, Tu F, Hu F. carat: Covariate-Adaptive Randomization for Clinical Trials[J]. Journal of Statistical Software, 2023, 107(2): 1-47.
Rosenberger W F, Lachin J M. Randomization in clinical trials: theory and practice[M]. John Wiley & Sons, 2015.
Examples
##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,0.5,0.4,0.3,0.2,0.1)
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, binwidth = 30,
p = 0.85)
Strt