evalPower {carat}R Documentation

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 = c("HuHuCAR", "PocSimMIN", "StrBCD", "StrPBR", 
                                         "DoptBCD","AdjBCD"), 
          test = c("boot.test", "corr.test", "rand.test"), plot = TRUE, ...)

Arguments

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 level_num should be equal to the number of covariates.

pr

a 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 sum of the probabilities for each margin should be 1.

type

a data-generating method. Optional input: "linear" or "logit".

beta

a vector of coefficients of covariates. The length of beta must correspond to the sum of all covariates' levels.

di

a value or a vector of values of difference in treatment effects. The default value is a sequence from 0 to 0.5 with increments of 0.1. The value(s) forms the horizontal axis of the plot.

sigma

the error variance for the linear model. The default is 1. This should be a positive value and is only used when type = linear.

Iternum

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

sl

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

method

the randomization procedure to be used for power calculation. This package provides power calculation for "HuHuCAR", "PocSimMIN", "StrBCD", "StrPBR", "AdjBCD", and "DoptBCD".

test

a character string specifying the alternative tests used to verify hypothesis, must be one of "boot.test", "corr.test" or "rand.test", which are the bootstrap t test, the corrected t test, and the randomization test, respectively. The arguments associated with the testing function can be specified; otherwise, the default value will be used.

plot

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

...

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

omega

a vector of weights at the overall, within-stratum, and within-covariate-margin 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

a vector of weights for within-covariate-margin 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 biased coin probability. p should be larger than 1/2 and less than 1. Note that p is only needed when "HuHuCAR", "PocSimMIN" and "StrBCD" are to be used.

a

a design parameter governing the degree of randomness. Note that a is only needed when "AdjBCD" is to be used.

bsize

the 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 samples. It is needed only when test is boot.test.

Reps

an integer. It is the number of randomized replications used in the randomization test. 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

##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,0.5,0.4,0.3,0.2,0.1)
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

[Package carat version 2.2.1 Index]