# a simple use
## Real Data
## create a dataframe
df <- data.frame("gender" = sample(c("female", "male"), 1000, TRUE, c(1 / 3, 2 / 3)),
"age" = sample(c("0-30", "30-50", ">50"), 1000, TRUE),
"jobs" = sample(c("stu.", "teac.", "others"), 1000, TRUE),
stringsAsFactors = TRUE)
Res <- AdjBCD(df, a = 2)
## view the output
Res
# \donttest{
## view all patients' profile and assignments
Res$Cov_Assig
# }
## Simulated Data
n <- 1000
cov_num <- 3
level_num <- c(2, 3, 5)
# Set pr to follow two tips:
#(1) length of pr should be sum(level_num);
#(2) sum of probabilities for each margin should be 1.
pr <- c(0.4, 0.6, 0.3, 0.4, 0.3, rep(0.2, times = 5))
# set the design parameter
a <- 1.8
# obtain result
Res.sim <- AdjBCD.sim(n, cov_num, level_num, pr, a)
# \donttest{
# view the assignments of patients
Res.sim$Cov_Assig[cov_num + 1, ]
# view the differences between treatment 1 and treatment 2 at all levels
Res.sim$Diff
# }
Run the code above in your browser using DataLab