Description Usage Arguments Value Examples
View source: R/test_Rfunction.R
Returns powers and a plot of the chosen test and method under different treatment effects.
1 2 3 4 
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 p value returned by the test is less than 
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  ##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

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.