evalPower {carat}  R Documentation 
Returns powers and a plot of the chosen test and method under different treatment effects.
evalPower(n, cov_num, level_num, pr, type, beta, di = seq(0,0.5,0.1), sigma = 1,
Iternum, sl = 0.05, method = c("HuHuCAR", "PocSimMIN", "StrBCD", "StrPBR",
"DoptBCD","AdjBCD"),
test = c("rand.test", "boot.test", "corr.test"), plot = TRUE, ...)
n 
the number of patients. 
cov_num 
the number of covariates. 
level_num 
a vector of level numbers for each covariate. Hence the length of 
pr 
a vector of probabilities. Under the assumption of independence between covariates, 
type 
a datagenerating method. Optional input: 
beta 
a vector of coefficients of covariates. The length of 
di 
a value or a vector of values of difference in treatment effects. The default value is a sequence from 
sigma 
the error variance for the linear model. The default is 1. This should be a positive value and is only used when 
Iternum 
an integer. It is the number of iterations required for power calculation. 
sl 
the significance level. If the 
method 
the randomization procedure to be used for power calculation. This package provides power calculation for 
test 
a character string specifying the alternative tests used to verify hypothesis, must be one of 
plot 
a bool. It indicates whether to plot or not. Optional input: 
... 
arguments to be passed to

This function returns a list. The first element is a dataframe representing the powers of the chosen test under different values of treatment effects. The second element is the execution time. An optional element is the plot of power in which di
forms the vertical axis.
##settings
set.seed(2019)
n = 100#<<for demonstration,it is suggested to be larger than 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)
omega = c(0.1, 0.1, rep(0.8 / 5, times = 5))
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
Reps = 10#<<for demonstration,it is suggested to be 200
#Evaluation of Power
library("ggplot2")
Strtp=evalPower(n,cov_num,level_num,pr,type,beta,di,sigma,
Iternum,sl,"HuHuCAR","rand.test",TRUE,omega,p,Reps, nthreads = 1)
Strtp