Description Usage Arguments Value References Examples
This function can calculate required budget for desired power, power or minimum detectable effect size (MDES) under fixed budget for individual randomized controlled trials (RCTs). It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).
1 2 3 4 5 
cost.model 
logical; power analyses accommodating costs and budget (e.g., required budget for desired power, power/MDES under fixed budget) if TRUE, otherwise conventional power analyses (e.g., required sample size, power, or MDES calculation); default value is TRUE. 
expr 
returned object from function 
constraint 
specify the constrained value of

sig.level 
significance level or type I error rate, default value is 0.05. 
two.tailed 
logical; twotailed tests if TRUE, otherwise onetailed tests; default value is TRUE. 
d 
effect size. 
power 
statistical power. 
m 
total budget. 
n 
the total sample size. 
p 
the proportion of individuals to be assigned to treatment. 
r12 
the proportion of outcome variance explained by covariates. 
q 
the number of covariates. 
c1 
the cost of sampling one unit in control condition. 
c1t 
the cost of sampling one unit in treatment condition. 
dlim 
the range for searching the root of effect size ( 
powerlim 
the range for searching the root of power ( 
nlim 
the range for searching the root of sample size ( 
mlim 
the range for searching the root of budget ( 
rounded 
logical; round 
Required budget (or required sample size), statistical power, or MDES depending on the specification of parameters. The function also returns the function name, design type, and parameters used in the calculation.
Shen, Z. (in progress). Using optimal sample allocation to improve statistical precision and design efficiency for multilevel randomized trials (Unpublished doctoral dissertation). University of Cincinnati, Cincinnati, OH.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46  # unconstrained optimal design
myod1 < od.1(r12 = 0.5, c1 = 1, c1t = 5, varlim = c(0, 0.2))
myod1$out # p = 0.31
#  power analyses by default considering costs and budget 
# required budget and sample size
mym.1 < power.1(expr = myod1, d = 0.2, q = 1, power = 0.8)
mym.1$out # m = 1032 n = 461
# mym.1$par # parameters and their values used for the function
# or equivalently, specify every argument in the function
mym.1 < power.1(d = 0.2, power = 0.8, c1 = 1, c1t = 5,
r12 = 0.5, p = 0.31, q = 1)
# required budget and sample size with constrained p
mym.2 < power.1(expr = myod1, d = 0.2, q = 1, power = 0.8,
constraint = list(p = 0.5))
mym.2$out # m = 1183, n = 394
# Power calculation
mypower < power.1(expr = myod1, q = 1, d = 0.2, m = 1032)
mypower$out # power = 0.80
# Power calculation under constrained p (p = 0.5)
mypower.1 < power.1(expr = myod1, q = 1, d = 0.2, m = 1032,
constraint = list(p = 0.5))
mypower.1$out # power = 0.74
# MDES calculation
mymdes < power.1(expr = myod1, q = 1, power = 0.80, m = 1032)
mymdes$out # d = 0.20
#  conventional power analyses with cost.model = FALSE
# Required sample size n
myn < power.1(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8)
myn$out # n = 461
# myn$par # parameters and their values used for the function
# or equivalently, specify every argument in the function
myn < power.1(cost.model = FALSE, d = 0.2, power = 0.8,
r12 = 0.5, p = 0.31, q = 1)
# Power calculation
mypower1 < power.1(cost.model = FALSE, expr = myod1, n = 461, d = 0.2, q = 1)
mypower1$out # power = 0.80
# MDES calculation
mymdes1 < power.1(cost.model = FALSE, expr = myod1, n = 461, power = 0.8, q = 1)
mymdes1$out # d = 0.20

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