compPower {carat} | R Documentation |
Compares the power of tests under different randomization methods and treatment effects through matrices and plots.
compPower(powers, diffs, testname)
powers |
a list. Each argument consists the power generated by |
diffs |
a vector. It contains values of group treatment effect differences. The length of this argument and the length of each argument of |
testname |
a vector. Each element is the name of test and the randomization method used. For example, when applying |
This function returns a list. The first element is a matrix consisting of powers of chosen tests under different values of treatment effects. The second element of the list is a plot of powers. diffs
forms the vertical axis of the plot.
##settings
set.seed(100)
n = 1000
cov_num = 5
level_num = c(2,2,2,2,2)
pr = rep(0.5,10)
beta = c(1,4,3,2,5,5,4,3,2,1)
di = seq(0,0.5,0.1)
sigma = 1
type = "linear"
p=0.85
Iternum = 10 #<<for demonstration,it is suggested to be around 1000
sl = 0.05
weight = rep(0.1,5)
#comparison of corrected t-test under StrBCD and PocSim
##data generation
library("ggplot2")
Strctp=evalPower(n,cov_num,level_num,pr,type,beta,di,
sigma,Iternum,sl,"StrBCD","corr.test",FALSE,p)
PSctp=evalPower(n,cov_num,level_num,pr,type,beta,di,sigma,
Iternum,sl,"PocSimMIN","corr.test",FALSE,weight,p)
powers = list(Strctp,PSctp)
testname = c("StrBCD.corr","PocSimMIN.corr")
#get plot and matrix for comparison
cp = compPower(powers,di,testname)
cp