boot.test {carat}  R Documentation 
Performs bootstrap ttest on treatment effects. This test is proposed by Shao et al. (2010) <doi:10.1093/biomet/asq014>.
boot.test(data, B = 200, method = c("HuHuCAR", "PocSimMIN", "StrBCD",
"StrPBR", "DoptBCD", "AdjBCD"),
conf = 0.95, ...)
data 
a data frame. It consists of patients' profiles, treatment assignments and outputs. See 
B 
an integer. It is the number of bootstrap samples. 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 
... 
arguments to be passed to

The bootstrap ttest is described as follows:
1) Generate bootstrap data (Y_1^*,Z_1^*), \dots, (Y_n^*,Z_n^*)
as a simple random sample with replacement from the original data (Y_1,Z_1), \dots,(Y_n,Z_n)
, where Y_i
denotes the outcome and Z_i
denotes the profile of the i
th patient.
2) Perform covariateadaptive procedures on the patients' profiles to obtain new treatment assignments T_1^*,\dots,T_n^*
, and define
\hat{\theta}^* = \frac{1}{n_1^*}\sum\limits_{i=1}^n (T_i^*2) \times Y_i^*  \frac{1}{n_0^*}\sum\limits_{i=1}^n (T_i^*1) \times Y_i
where n_1^*
is the number of patients assigned to treatment 1
and n_0^*
is the number of patients assigned to treatment 2
.
3) Repeat step 2 B
times to generate B
independent boostrap samples to obtain \hat{\theta}^*_b
, b = 1,\dots,B
. The variance of \bar{Y}_1  \bar{Y}_0
can then be approximated by the sample variance of \hat{\theta}^*_b
.
It returns an object of class "htest"
.
An object of class "htest"
is a list containing the following components:
statistic 
the value of the tstatistic. 
p.value 
the pvalue of the test,the null hypothesis is rejected if pvalue is less than the predetermined significance level. 
conf.int 
a confidence interval under the chosen level 
estimate 
the estimated treatment effect difference between treatment 
stderr 
the standard error of the mean (difference), used as denominator in the tstatistic formula. 
method 
a character string indicating what type of test was performed. 
data.name 
a character string giving the name(s) of the data. 
Shao J, Yu X, Zhong B. A theory for testing hypotheses under covariateadaptive randomization[J]. Biometrika, 2010, 97(2): 347360.
#Suppose the data used is patients' profile from real world,
# while it is generated here. Data needs to be preprocessed
# and then get assignments following certain randomization.
set.seed(100)
df< data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)),
"age" = sample(c("030", "3050", ">50"), 100, TRUE),
"jobs" = sample(c("stu.", "teac.", "other"), 100, TRUE, c(0.4, 0.2, 0.4)),
stringsAsFactors = TRUE)
##data preprocessing
data.pd < StrPBR(data = df, bsize = 4)$Cov_Assig
#Then we need to combine patients' profiles and outcomes after randomization and treatments.
outcome = runif(100)
data.combined = data.frame(rbind(data.pd,outcome), stringsAsFactors = TRUE)
#run the bootstrap ttest
B = 200
Strbt = boot.test(data.combined, B, "StrPBR", bsize = 4)
Strbt