Learn R Programming

carat (version 1.1)

evalPower: Evaluation of Tests and Randomization Procedures through Power

Description

Returns powers and a plot of the chosen test and method under different treatment effects.

Usage

evalPower(n, cov_num, level_num, pr, type, beta, di = seq(0,0.5,0.1), sigma = 1,
            Iternum, sl = 0.05, method = HuHuCAR, test, plot = "TRUE", ...)

Arguments

n

number of patients.

cov_num

number of covariates.

level_num

the vector of level numbers for each covariate. Hence the length of level_num should be equal to the number of covariates.

pr

the vector of probabilities. Under the assumption of independence between covariates, pr is a vector containing probabilities for each level of each covariate. The length of pr should correspond to the number of all levels, and the vector sum of pr should be equal to cov_num.

type

the type of models when generating data. Optional input: linear or logit.

beta

the vector of coefficients of covariates. The length of beta must correspond to cov_num.

di

the vector of values of difference in treatment effects. The default value is a sequence from 0 to 0.5 with increment being 0.1.

sigma

the error variance for the linear model. The default value is 1. It is only used when type is linear.

Iternum

an integer. It is the number of iterations required for calculating the average power.

sl

the significance level. If the p-value returned by the test is less than sl, we will reject the null hypothesis. The default value is 0.05.

method

the randomization method to be used in allocating patients. The default randomization HuHuCAR uses Hu and Hu's general covariate-adaptive randomization; the alternatives are PocSimMIN, StrBCD, StrPBR, DoptBCD, and AdjBCD.

test

the test used to verify hypothesis. Optional input: rand.test, boot.test or corr.test, which are the randomization test, the bootstrap t-test and the corrected t-test respectively.

plot

bool. It shows whether to plot or not. Optional input: TRUE or FALSE.

...

arguments to be passed to methods. These depend on the method and test used and the following arguments are accepted:

omega

the vector of weights at the overall, within-stratum, and marginal levels. It is required that at least one element is larger than 0. Note that omega is only needed when HuHuCAR is to be used.

weight

the vector of weights for marginal imbalances. It is required that at least one element is larger than 0. Note that weight is only needed when PocSimMIN is to be used.

p

the probability of assigning one patient to treatment 1, where p should be larger than 1/2 to obtain balance. Note that p is only needed when "HuHuCAR", "PocSimMIN" and "StrBCD" are to be used.

a

a design parameter. As a goes to \(\infty\), the design becomes more deterministic.

bsize

block size for the stratified randomization. It is required to be a multiple of 2. Note that bsize is only needed when "StrPBR" is to be used.

B

an integer. It is the number of bootstrap samplings. It is needed only when test is boot.test.

Reps

an integer. It represents the number of randomized replications. It is needed only when test is rand.test.

nthreads

the number of threads to be used in parallel computation. This is needed only under rand.test and boot.test. The default is 1.

Value

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.

Examples

Run this code
# NOT RUN {
##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
# }

Run the code above in your browser using DataLab