Title: | Optimal Design and Statistical Power for Experimental Studies Investigating Main, Mediation, and Moderation Effects |
---|---|
Description: | Calculate the optimal sample size allocation that produces the highest statistical power for experimental studies under a budget constraint, and perform power analyses with and without accommodating cost structures of sampling. The designs cover single-level and multilevel experiments detecting main, mediation, and moderation effects (and some combinations). The references for the proposed methods include: (1) Shen, Z., & Kelcey, B. (2020). Optimal sample allocation under unequal costs in cluster-randomized trials. Journal of Educational and Behavioral Statistics, 45(4): 446-474. <doi:10.3102/1076998620912418>. (2) Shen, Z., & Kelcey, B. (2022b). Optimal sample allocation for three-level multisite cluster-randomized trials. Journal of Research on Educational Effectiveness, 15 (1), 130-150. <doi:10.1080/19345747.2021.1953200>. (3) Shen, Z., & Kelcey, B. (2022a). Optimal sample allocation in multisite randomized trials. The Journal of Experimental Education. <doi:10.1080/00220973.2020.1830361>. (4) Champely, S. (2020). pwr: Basic functions for power analysis (Version 1.3-0) [Software]. Available from <https://CRAN.R-project.org/package=pwr>. |
Authors: | Zuchao Shen [aut, cre] , Benjamin Kelcey [aut] |
Maintainer: | Zuchao Shen <[email protected]> |
License: | GPL-3 |
Version: | 1.4.4 |
Built: | 2024-11-04 21:43:12 UTC |
Source: | https://github.com/zuchaoshen/odr |
This package is to help researchers design cost-efficient and well-powered experimental studies investigating main, mediation, and moderation effects (and some combinations). Specifically, this package can (a) identify optimal sample allocations, (b) compare design efficiency between different sample allocations, and (c) perform power analyses with and without accommodating costs and budget.
The package covers seven types of experiments aiming to detect main, moderation, and mediation effects. These experiments are individual randomized controlled trials (RCTs), two-, three-, and four-level cluster-randomized trials (CRTs), two-, three-, and four-level multisite randomized trials (MRTs). The two categorical functions are 'od' and 'power'. The 'od' function can calculate the optimal sample allocation with and without constraint for each type of experiments. The 'power' function by default can calculate required budget (and required sample size) for desired power, minimum detectable effect size (MDES) under a fixed budget, statistical power under a fixed budget. The 'power' function can perform conventional power analyses (e.g., required sample size, power, MDES calculation). The uniform function 're' (or 'rpe') is to compare the relative (precision and) efficiency between two designs with different sample allocations (limited to main effects).
Zuchao Shen, Benjamin Kelcey
Maintainer: Zuchao Shen [email protected] (University of Georgia)
This function can generate a set of optimal design parameters based on given distributions of the rank of optimization target (or budget).
gen.design.pars( dist.mean, dist.rank, n.of.ants, nl, q = 1e-04, n.of.archive = 100, xi = 0.5 )
gen.design.pars( dist.mean, dist.rank, n.of.ants, nl, q = 1e-04, n.of.archive = 100, xi = 0.5 )
dist.mean |
List of means - coordinates |
dist.rank |
Rank of the archived values of objective function |
n.of.ants |
Number of ants used in each iteration after the initialization of power analysis for calculating required budget, default value is 10. |
nl |
Neighborhood of the search area |
q |
Locality of the search (0,1), default is 0.0001. |
n.of.archive |
Size of the solution archive, default is 100. |
xi |
Convergence pressure (0, Inf), suggested: (0, 1), default is 0.5. |
Generated optimal design parameter value(s) (i.e., a matrix with n.of.ants rows and n.of.design.pars columns)
Socha, K., & Dorigo, M. (2008). Ant colony optimization for continuous domains. European Journal of Operational Research, 185(3), 1155-1173.
We thank Dr. Krzysztof Socha for providing us the original code (http://iridia.ulb.ac.be/supp/IridiaSupp2008-001/) for this function.
The optimal design of single-level experiments detecting main effects
is to choose
the optimal sample allocation that minimizes the variance of
a treatment effect under a fixed budget, which is approximately the optimal
sample allocation that maximizes statistical power under a fixed budget.
The optimal design parameter is
the proportion of individuals to be assigned to treatment (p
).
od.1( p = NULL, r12 = NULL, c1 = NULL, c1t = NULL, m = NULL, plots = TRUE, plim = NULL, varlim = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE )
od.1( p = NULL, r12 = NULL, c1 = NULL, c1t = NULL, m = NULL, plots = TRUE, plim = NULL, varlim = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE )
p |
The proportion of individuals to be assigned to treatment. |
r12 |
The proportion of outcome variance explained by covariates. |
c1 |
The cost of sampling one unit in control condition. |
c1t |
The cost of sampling one unit in treatment condition. |
m |
Total budget, default value is the total costs of sampling 60 individuals across treatment conditions. |
plots |
Logical, provide variance plots if TRUE, otherwise not; default value is TRUE. |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
plab |
The plot label for |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
verbose |
Logical; print the value of |
Unconstrained or constrained optimal sample allocation (p
).
The function also returns the variance of the treatment effect,
function name, design type,
and parameters used in the calculation.
# Unconstrained optimal design #--------- myod1 <- od.1(r12 = 0.5, c1 = 1, c1t = 5, varlim = c(0, 0.2)) myod1$out # output # Constrained p, no calculation performed #--------- myod2 <- od.1(r12 = 0.5, c1 = 1, c1t = 5, varlim = c(0, 0.2), p = 0.5) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.87 # When sampling costs are equal, a balanced design with p = 0.5 is the best #--------- myod3 <- od.1(r12 = 0.5, c1 = 1, c1t = 1, varlim = c(0, 0.2)) myod3$out # output
# Unconstrained optimal design #--------- myod1 <- od.1(r12 = 0.5, c1 = 1, c1t = 5, varlim = c(0, 0.2)) myod1$out # output # Constrained p, no calculation performed #--------- myod2 <- od.1(r12 = 0.5, c1 = 1, c1t = 5, varlim = c(0, 0.2), p = 0.5) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.87 # When sampling costs are equal, a balanced design with p = 0.5 is the best #--------- myod3 <- od.1(r12 = 0.5, c1 = 1, c1t = 1, varlim = c(0, 0.2)) myod3$out # output
The optimal design of single-level RCTs
probing mediation effects is to identify the optimal sample
allocation that use the minimum budget to achieve a fixed level of
statistical power. The optimal design parameter is the proportion of
individuals/units to be assigned to the experimental condition.
This function identifies the optimal p
.
od.1.111( a = NULL, b = NULL, c1 = NULL, c1t = NULL, m = NULL, r.yx = 0, r.mx = 0, r.mw = 0, q.a = 0, q.b = 0, test = "joint", p = NULL, n = NULL, tol = 1e-11, power = 0.8, d.p = c(0.1, 0.5), sig.level = 0.05, two.tailed = TRUE, plim = c(0.01, 0.99), varlim = c(0, 0.001), plab = NULL, varlab = NULL, vartitle = NULL, nlim = c(6, 1e+06), verbose = TRUE, max.value = Inf, max.iter = 300, e = 1e-10, n.of.ants = 10, n.of.archive = 20, q = 1e-04, xi = 0.5 )
od.1.111( a = NULL, b = NULL, c1 = NULL, c1t = NULL, m = NULL, r.yx = 0, r.mx = 0, r.mw = 0, q.a = 0, q.b = 0, test = "joint", p = NULL, n = NULL, tol = 1e-11, power = 0.8, d.p = c(0.1, 0.5), sig.level = 0.05, two.tailed = TRUE, plim = c(0.01, 0.99), varlim = c(0, 0.001), plab = NULL, varlab = NULL, vartitle = NULL, nlim = c(6, 1e+06), verbose = TRUE, max.value = Inf, max.iter = 300, e = 1e-10, n.of.ants = 10, n.of.archive = 20, q = 1e-04, xi = 0.5 )
a |
The treatment effect on the mediator. |
b |
The within-treatment correlation between the outcome and the mediator. |
c1 |
The cost of sampling an individual in the control group. |
c1t |
The cost of sampling an individual in the treated group. |
m |
Total budget. |
r.yx |
The within-treatment correlation between the outcome and the covariate(s) in the outcome model. |
r.mx |
The within-treatment correlation between the mediator and the covariate(s) in the outcome model. |
r.mw |
The within-treatment correlation between the mediator and the covariate(s) in the mediator model. |
q.a |
The number of covariates at the mediator model (except the treatment indicator), the default value is zero. |
q.b |
The number of covariates in the outcome model (except the treatment indicator and the mediator), the default value is zero. |
test |
The type of test will be used to detect mediation effects. The default is the joint significance test (i.e., test = "joint", "Joint","JOINT"). Another choice is the Sobel test by specifying the argument as test = "sobel", "Sobel", or "SOBEL". |
p |
The proportion of level-4 clusters/units to be assigned to treatment. |
n |
Total number of individuals in the experimental study, the default value is NULL. |
tol |
convergence tolerance. |
power |
Statistical power specified, default is .80. |
d.p |
The initial sampling domains for p. Default is c(0.10, 0.50). |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Two tailed test, the default value is TRUE. |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
plab |
The plot label for |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
nlim |
The interval/range used to numerically solve for n, the default values are c(6, 1e7). |
verbose |
Print out evaluation process if TRUE, default is TRUE. |
max.value |
Maximal value of optimization when used as the stopping criterion. Default is infinite. |
max.iter |
Maximal number of function evaluations when used as the stopping criterion. Default is 200. |
e |
Maximum error value used when solution quality used as the stopping criterion, default is 1e-10. |
n.of.ants |
Number of ants used in each iteration after the initialization stage, the default value is 10. |
n.of.archive |
Size of the solution archive, default is 20. |
q |
Locality of the search (0,1), default is 0.0001. |
xi |
Convergence pressure (0, Inf), suggested: (0, 1), default is 0.5. |
Unconstrained or constrained optimal sample allocation p
).
The function also returns statistical power,
function name, design type,
and parameters used in the calculation.
myod <- od.1.111(a = .3, b = .5, c1 = 10, c1t = 100) myod
myod <- od.1.111(a = .3, b = .5, c1 = 10, c1t = 100) myod
The optimal design of two-level
cluster randomized trials (CRTs) detecting main effects is to calculate
the optimal sample allocation that minimizes the variance of
a treatment effect under a fixed budget, which is approximately the optimal
sample allocation that maximizes statistical power under a fixed budget.
The optimal design parameters include
the level-1 sample size per level-2 unit (n
)
and the proportion of level-2 clusters/groups to be assigned to treatment (p
).
This function solves the optimal n
and/or p
with and without constraints.
od.2( n = NULL, p = NULL, icc = NULL, r12 = NULL, r22 = NULL, c1 = NULL, c2 = NULL, c1t = NULL, c2t = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, plim = NULL, varlim = NULL, nlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE )
od.2( n = NULL, p = NULL, icc = NULL, r12 = NULL, r22 = NULL, c1 = NULL, c2 = NULL, c1t = NULL, c2t = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, plim = NULL, varlim = NULL, nlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE )
n |
The level-1 sample size per level-2 unit. |
p |
The proportion of level-2 clusters/units to be assigned to treatment. |
icc |
The unconditional intraclass correlation coefficient (ICC) in population or in each treatment condition. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
m |
Total budget, default value is the total costs of sampling 60 level-2 units across treatment conditions. |
plots |
Logical, provide variance plots if TRUE, otherwise not; default value is TRUE. |
plot.by |
Plot the variance by |
nlim |
The plot range for n, default value is c(2, 50). |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
nlab |
The plot label for |
plab |
The plot label for p, default value is "Proportion Level-2 Units in Treatment: p". |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
verbose |
Logical; print the values of |
Unconstrained or constrained optimal sample allocation (n
and p
).
The function also returns the variance of the treatment effect,
function name, design type,
and parameters used in the calculation.
Shen, Z., & Kelcey, B. (2020). Optimal sample allocation under unequal costs in cluster-randomized trials. Journal of Educational and Behavioral Statistics, 45(4): 446–474. <https://doi.org/10.3102/1076998620912418>
# Unconstrained optimal design #--------- myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, varlim = c(0.01, 0.02)) myod1$out # output # Plot by p myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, varlim = c(0.01, 0.02), plot.by = list(p = 'p')) # Constrained optimal design with n = 20 #--------- myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, n = 20, varlim = c(0.005, 0.025)) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.88 # Constrained optimal design with p = 0.5 #--------- myod3 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, p = 0.5, varlim = c(0.005, 0.025)) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.90 # Constrained n and p, no calculation performed #--------- myod4 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, n = 20, p = 0.5, varlim = c(0.005, 0.025)) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.83
# Unconstrained optimal design #--------- myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, varlim = c(0.01, 0.02)) myod1$out # output # Plot by p myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, varlim = c(0.01, 0.02), plot.by = list(p = 'p')) # Constrained optimal design with n = 20 #--------- myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, n = 20, varlim = c(0.005, 0.025)) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.88 # Constrained optimal design with p = 0.5 #--------- myod3 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, p = 0.5, varlim = c(0.005, 0.025)) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.90 # Constrained n and p, no calculation performed #--------- myod4 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, n = 20, p = 0.5, varlim = c(0.005, 0.025)) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.83
The optimal design of two-level
cluster randomized trials (CRTs) probing mediation effects with
cluster-level mediators is to to identify
the optimal sample allocation that requires the minimum budget
to achieve certain power level.
The optimal design parameters include
the level-1 sample size per level-2 unit (n
)
and the proportion of level-2 clusters/groups to be assigned to
treatment (p
).
This function solves the optimal n
and/or p
with and without a constraint.
od.2.221( a = NULL, b = NULL, n = NULL, p = NULL, icc = NULL, c1 = NULL, c1t = NULL, c2 = NULL, c2t = NULL, m = NULL, r2m = 0, r.yx = 0, r.mw = 0, r.yw = 0, q.a = 0, q.b = 0, test = "joint", tol = 1e-11, power = 0.8, d.p = c(0.1, 0.5), d.n = c(2, 100), sig.level = 0.05, two.tailed = TRUE, Jlim = c(max(q.a, q.b) + 4, 1e+06), verbose = TRUE, nrange = c(1.5, 10000), max.value = Inf, max.iter = 300, e = 1e-10, n.of.ants = 10, n.of.archive = 50, q = 1e-04, xi = 0.5 )
od.2.221( a = NULL, b = NULL, n = NULL, p = NULL, icc = NULL, c1 = NULL, c1t = NULL, c2 = NULL, c2t = NULL, m = NULL, r2m = 0, r.yx = 0, r.mw = 0, r.yw = 0, q.a = 0, q.b = 0, test = "joint", tol = 1e-11, power = 0.8, d.p = c(0.1, 0.5), d.n = c(2, 100), sig.level = 0.05, two.tailed = TRUE, Jlim = c(max(q.a, q.b) + 4, 1e+06), verbose = TRUE, nrange = c(1.5, 10000), max.value = Inf, max.iter = 300, e = 1e-10, n.of.ants = 10, n.of.archive = 50, q = 1e-04, xi = 0.5 )
a |
The treatment effect on the mediator. |
b |
The within treatment correlation between the outcome and the mediator at the cluster level. |
n |
The level-1 sample size per level-2 unit. |
p |
The proportion of level-2 clusters/units to be assigned to treatment. |
icc |
The unconditional intraclass correlation coefficient (ICC) in population or in each treatment condition. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
m |
Total budget. |
r2m |
The proportion of mediator variance explained by covariates in the mediator model. |
r.yx |
The correlation between the outcome and the covariate at the individual level. |
r.mw |
The correlation between the mediator and the covariate at the cluster level. |
r.yw |
The correlation between the outcome and the covariate at the cluster level. |
q.a |
The number of covariates in the mediator model (except the treatment indicator). |
q.b |
The number of covariates in the outcome model at the cluster level (except the treatment indicator and the mediator). |
test |
The type of test will be used to detect mediation effects. Default is the joint significance test (i.e., test = "joint"). The other choice is the Sobel test by specifying the argument as test = "sobel". |
tol |
convergence tolerance. |
power |
Statistical power specified. The default value is .80. |
d.p |
The initial sampling domains for p. Default is c(0.1, 0.5). |
d.n |
The initial sampling domain for n. Default is c(2, 100). |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Two tailed test, the default value is TRUE. |
Jlim |
The range for J to solve for a numerical solution. Default is c(max(q.a, q.b)+4, 1e6). |
verbose |
Print out evaluation process if TRUE, default is TRUE. |
nrange |
The range of the individual-level sample size per cluster that used to exclude unreasonable values. Default value is c(1.5, 10000). |
max.value |
Maximal value of optimization when used as the stopping criterion. Default is -Inf. |
max.iter |
Maximal number of function evaluations when used as the stopping criterion. |
e |
Maximum error value used when solution quality used as the stopping criterion, default is 1e-10. |
n.of.ants |
Number of ants used in each iteration after the initialization of power analysis for calculating required budget, default value is 10. |
n.of.archive |
Size of the solution archive, default is 100. |
q |
Locality of the search (0,1), default is 0.0001. |
xi |
Convergence pressure (0, Inf), suggested: (0, 1), default is 0.5. |
Unconstrained or constrained optimal sample allocation
(n
and p
).
The function also returns the variance of a mediation effect
or statistical power,
function name, design type,
and parameters used in the calculation.
The optimal design of two-level
multisite randomized trials (MRTs) detecting main effects is to calculate
the sample allocation that minimizes the variance of a
treatment effect under a fixed budget, which is approximately the optimal
sample allocation that maximizes statistical power under a fixed budget.
The optimal design parameters include
the level-one sample size per site (n
)
and the proportion of level-one unit to be assigned to treatment (p
).
This function solves the optimal n
and/or p
with and without a constraint.
od.2m( n = NULL, p = NULL, icc = NULL, r12 = NULL, r22m = NULL, c1 = NULL, c2 = NULL, c1t = NULL, omega = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, plim = NULL, varlim = NULL, nlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
od.2m( n = NULL, p = NULL, icc = NULL, r12 = NULL, r22m = NULL, c1 = NULL, c2 = NULL, c1t = NULL, omega = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, plim = NULL, varlim = NULL, nlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
n |
The level-1 sample size per level-2 unit. |
p |
The proportion of level-4 clusters/units to be assigned to treatment. |
icc |
The unconditional intraclass correlation coefficient (ICC) in population or in each treatment condition. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22m |
The proportion of variance of site-specific treatment effect explained by covariates. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
omega |
The standardized variance of site-specific treatment effect. |
m |
Total budget, default is the total costs of sampling 60 sites. |
plots |
Logical, provide variance plots if TRUE, otherwise not; default value is TRUE. |
plot.by |
Plot the variance by |
nlim |
The plot range for n, default value is c(2, 50). |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
nlab |
The plot label for |
plab |
The plot label for |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
verbose |
Logical; print the values of |
iter |
Number of iterations; default value is 100. |
tol |
Tolerance for convergence; default value is 1e-10. |
Unconstrained or constrained optimal sample allocation
(n
and p
).
The function also returns the variance of the treatment effect,
function name, design type,
and parameters used in the calculation.
Shen, Z., & Kelcey, B. (in press). Optimal sample allocation in multisite randomized trials. The Journal of Experimental Education. <https://doi.org/10.1080/00220973.2020.1830361>
# Unconstrained optimal design #--------- myod1 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005)) myod1$out # n = 20, p =0.37 # Plots by p myod1 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005), plot.by = list(p = 'p')) # Constrained optimal design with p = 0.5 #--------- myod2 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005), p = 0.5) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.86 # Constrained optimal design with n = 5 #--------- myod3 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005), n = 5) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.79 # Constrained n and p, no calculation performed #--------- myod4 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005), p = 0.5, n = 10) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.84
# Unconstrained optimal design #--------- myod1 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005)) myod1$out # n = 20, p =0.37 # Plots by p myod1 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005), plot.by = list(p = 'p')) # Constrained optimal design with p = 0.5 #--------- myod2 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005), p = 0.5) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.86 # Constrained optimal design with n = 5 #--------- myod3 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005), n = 5) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.79 # Constrained n and p, no calculation performed #--------- myod4 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005), p = 0.5, n = 10) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.84
The optimal design of two-level
multisite-randomized trials (MRTs) probing mediation effects with
individual-level mediators, for the
Sobel test, is to calculate
the optimal sample allocation that minimizes the variance of
a mediation effect under a fixed budget. For the joint significance test, it is to identify
the optimal sample allocation that requires the minimum budget
to achieve certain power level.
The optimal design parameters include
the level-1 sample size per level-2 unit (n
)
and the proportion of level-1 individuals/units to be assigned to treatment (p
).
This function solves the optimal n
and/or p
with and without a constraint.
od.2m.111( a = NULL, b = NULL, icc.m = NULL, icc = NULL, c1 = NULL, c1t = NULL, c2 = NULL, m = NULL, r12m = 0, r22m = 0, r12 = 0, omega = 0.01, q.a = 0, q.b = 3, test = "joint", n = NULL, p = NULL, iter = 100, tol = 1e-11, power = 0.8, d.p = c(0.1, 0.5), d.n = c(5, 50), sig.level = 0.05, two.tailed = TRUE, plots = TRUE, nlim = c(4, 100), plim = c(0.01, 0.99), varlim = c(0, 0.001), nlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, Jlim = c(3, 1e+05), verbose = TRUE, max.value = Inf, max.iter = 300, e = 1e-10, n.of.ants = 10, n.of.archive = 50, q = 1e-04, xi = 0.5, plot.by = list(n = "n", p = "p") )
od.2m.111( a = NULL, b = NULL, icc.m = NULL, icc = NULL, c1 = NULL, c1t = NULL, c2 = NULL, m = NULL, r12m = 0, r22m = 0, r12 = 0, omega = 0.01, q.a = 0, q.b = 3, test = "joint", n = NULL, p = NULL, iter = 100, tol = 1e-11, power = 0.8, d.p = c(0.1, 0.5), d.n = c(5, 50), sig.level = 0.05, two.tailed = TRUE, plots = TRUE, nlim = c(4, 100), plim = c(0.01, 0.99), varlim = c(0, 0.001), nlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, Jlim = c(3, 1e+05), verbose = TRUE, max.value = Inf, max.iter = 300, e = 1e-10, n.of.ants = 10, n.of.archive = 50, q = 1e-04, xi = 0.5, plot.by = list(n = "n", p = "p") )
a |
The treatment effect on the mediator. |
b |
The within treatment correlation between the outcome and the mediator. |
icc.m |
The intraclass correlation coefficient for the mediator. |
icc |
The unconditional intraclass correlation coefficient (ICC) in population or in each treatment condition. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2 |
The cost of sampling one level-2 unit. |
m |
Total budget. |
r12m |
The proportion of within treatment mediator variance at the level one explained by covariates. |
r22m |
The proportion of treatment-by-site variance explained by covariates. |
r12 |
The proportion of within treatment individual-level outcome variance explained by covariates. |
omega |
The treatment-by-site variance of the outcome. |
q.a |
The number of covariates at the individual level of the mediator model (except the treatment indicator). |
q.b |
The number of covariates in the outcome model (except the treatment indicator and the mediator). |
test |
The type of test will be used to detect mediation effects. Default is the joint significance test (i.e., test = "joint"). Another choice is the Sobel test by specifying the argument as test = "sobel". |
n |
The level-1 sample size per level-2 unit. |
p |
The proportion of level-1 units to be assigned to treatment. |
iter |
number of iteration used for solving roots in the Sobel test. |
tol |
convergence tolerance. |
power |
Statistical power specified, default is .80. |
d.p |
The initial sampling domains for p. Default is c(0.10, 0.50). |
d.n |
The initial sampling domain for n. Default is c(4, 500). |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Logical; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
plots |
Logical, provide variance plots if TRUE, otherwise not; default value is TRUE. |
nlim |
The plot range for n, default value is c(2, 50). |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
nlab |
The plot label for |
plab |
The plot label for |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
Jlim |
The range for J to search for a numerical solution. Default is c(3, 10e4). |
verbose |
Print out evaluation process if TRUE, default is TRUE. |
max.value |
Maximal value of optimization when used as the stopping criterion. Default is infinite. |
max.iter |
Maximal number of function evaluations when used as the stopping criterion. Default is 200. |
e |
Maximum error value used when solution quality used as the stopping criterion, default is 1e-10. |
n.of.ants |
Number of ants used in each iteration after the initialization of power analysis for calculating required budget, default value is 10. |
n.of.archive |
Size of the solution archive, default is 100. |
q |
Locality of the search (0,1), default is 0.0001. |
xi |
Convergence pressure (0, Inf), suggested: (0, 1), default is 0.5. |
plot.by |
Plot the variance by |
Unconstrained or constrained optimal sample allocation (n
and p
).
The function also returns statistical power,
function name, design type,
and parameters used in the calculation.
The optimal design of three-level
cluster randomized trials (CRTs) is to calculate
the optimal sample allocation that minimizes the variance of
treatment effect under fixed budget, which is approximately the optimal
sample allocation that maximizes statistical power under a fixed budget.
The optimal design parameters include
the level-1 sample size per level-2 unit (n
),
the level-2 sample size per level-3 unit (J
),
and the proportion of level-3 clusters/groups to be assigned to treatment (p
).
This function solves the optimal n
, J
and/or p
with and without constraints.
od.3( n = NULL, J = NULL, p = NULL, icc2 = NULL, icc3 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, Jlim = NULL, plim = NULL, varlim = NULL, nlab = NULL, Jlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
od.3( n = NULL, J = NULL, p = NULL, icc2 = NULL, icc3 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, Jlim = NULL, plim = NULL, varlim = NULL, nlab = NULL, Jlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
n |
The level-1 sample size per level-2 unit. |
J |
The level-2 sample size per level-3 unit. |
p |
The proportion of level-3 clusters/units assigned to treatment. |
icc2 |
The unconditional intraclass correlation coefficient (ICC) at level 2. |
icc3 |
The unconditional intraclass correlation coefficient (ICC) at level 3. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
r32 |
The proportion of level-3 variance explained by covariates. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c3 |
The cost of sampling one level-3 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
c3t |
The cost of sampling one level-3 unit in treatment condition. |
m |
Total budget, default is the total costs of sampling 60 level-3 units across treatment conditions. |
plots |
Logical, provide variance plots if TRUE, otherwise not; default value is TRUE. |
plot.by |
Plot the variance by |
nlim |
The plot range for n, default value is c(2, 50). |
Jlim |
The plot range for J, default value is c(2, 50). |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
nlab |
The plot label for |
Jlab |
The plot label for |
plab |
The plot label for p, default is "Proportion Level-3 Units in Treatment: p". |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
verbose |
Logical; print the values of |
iter |
Number of iterations; default value is 100. |
tol |
Tolerance for convergence; default value is 1e-10. |
Unconstrained or constrained optimal sample allocation
(n
, J
, and p
).
The function also returns the variance of the treatment effect,
function name, design type,
and parameters used in the calculation.
Shen, Z., & Kelcey, B. (2020). Optimal sample allocation under unequal costs in cluster-randomized trials. Journal of Educational and Behavioral Statistics, 45(4): 446–474. <https://doi.org/10.3102/1076998620912418>
# Unconstrained optimal design #--------- myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025)) myod1$out # output # Plots by p and J myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025), plot.by = list(p = 'p', J = 'J')) # Constrained optimal design with J = 20 #--------- myod2 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, J = 20, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0, 0.025)) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.53 # Constrained optimal design with p = 0.5 #--------- myod3 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, p = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025)) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.84 # Constrained n, J and p, no calculation performed #--------- myod4 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, n = 10, J = 10, p = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0, 0.025)) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.61
# Unconstrained optimal design #--------- myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025)) myod1$out # output # Plots by p and J myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025), plot.by = list(p = 'p', J = 'J')) # Constrained optimal design with J = 20 #--------- myod2 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, J = 20, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0, 0.025)) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.53 # Constrained optimal design with p = 0.5 #--------- myod3 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, p = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025)) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.84 # Constrained n, J and p, no calculation performed #--------- myod4 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, n = 10, J = 10, p = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0, 0.025)) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.61
The optimal design of three-level
multisite randomized trials (MRTs) is to calculate
the optimal sample allocation that minimizes the variance of
treatment effect under fixed budget, which is approximately the optimal
sample allocation that maximizes statistical power under a fixed budget.
The optimal design parameters include
the level-1 sample size per level-2 unit (n
),
the level-2 sample size per level-3 unit (J
),
and the proportion of level-2 unit to be assigned to treatment (p
).
This function solves the optimal n
, J
and/or p
with and without constraints.
od.3m( n = NULL, J = NULL, p = NULL, icc2 = NULL, icc3 = NULL, r12 = NULL, r22 = NULL, r32m = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c1t = NULL, c2t = NULL, omega = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, Jlim = NULL, plim = NULL, varlim = NULL, nlab = NULL, Jlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
od.3m( n = NULL, J = NULL, p = NULL, icc2 = NULL, icc3 = NULL, r12 = NULL, r22 = NULL, r32m = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c1t = NULL, c2t = NULL, omega = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, Jlim = NULL, plim = NULL, varlim = NULL, nlab = NULL, Jlab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
n |
The level-1 sample size per level-2 unit. |
J |
The level-2 sample size per level-3 unit. |
p |
The proportion of level-4 clusters/units to be assigned to treatment. |
icc2 |
The unconditional intraclass correlation coefficient (ICC) at level 2. |
icc3 |
The unconditional intraclass correlation coefficient (ICC) at level 3. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
r32m |
The proportion of variance of site-specific treatment effect explained by covariates. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c3 |
The cost of sampling one level-3 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
omega |
The standardized variance of site-specific treatment effect. |
m |
Total budget, default is the total costs of sampling 60 level-3 units. |
plots |
Logical, provide variance plots if TRUE, otherwise not; default value is TRUE. |
plot.by |
Plot the variance by |
nlim |
The plot range for n, default value is c(2, 50). |
Jlim |
The plot range for J, default value is c(2, 50). |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
nlab |
The plot label for |
Jlab |
The plot label for |
plab |
The plot label for |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
verbose |
Logical; print the values of |
iter |
Number of iterations; default value is 100. |
tol |
Tolerance for convergence; default value is 1e-10. |
Unconstrained or constrained optimal sample allocation
(n
, J
, and p
).
The function also returns the variance of the treatment effect,
function name, design type,
and parameters used in the calculation.
Shen, Z., & Kelcey, B. (2022). Optimal sampling ratios in three-level multisite experiments. Journal of Research on Educational Effectiveness.
# Unconstrained optimal design #--------- myod1 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005)) myod1$out # output # Plots by p and J myod1 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005), plot.by = list(p = 'p', J = 'J')) # Constrained optimal design with p = 0.5 #--------- myod2 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005), p = 0.5) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.81 # Constrained optimal design with n = 5 #--------- myod3 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005), n = 5) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.89 # Constrained n, J and p, no calculation performed #--------- myod4 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005), p = 0.5, n = 15, J = 20) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.75
# Unconstrained optimal design #--------- myod1 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005)) myod1$out # output # Plots by p and J myod1 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005), plot.by = list(p = 'p', J = 'J')) # Constrained optimal design with p = 0.5 #--------- myod2 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005), p = 0.5) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.81 # Constrained optimal design with n = 5 #--------- myod3 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005), n = 5) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.89 # Constrained n, J and p, no calculation performed #--------- myod4 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005), p = 0.5, n = 15, J = 20) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.75
The optimal design of four-level
cluster randomized trials (CRTs) is to calculate
the optimal sample allocation that minimizes the variance of
treatment effect under fixed budget, which is approximately the optimal
sample allocation that maximizes statistical power under a fixed budget.
The optimal design parameters include
the level-1 sample size per level-2 unit (n
),
the level-2 sample size per level-3 unit (J
),
the level-3 sample size per level-4 unit (K
),
and the proportion of level-4 clusters/groups to be assigned to treatment (p
).
This function solves the optimal n
, J
, K
and/or p
with and without constraints.
od.4( n = NULL, J = NULL, K = NULL, p = NULL, icc2 = NULL, icc3 = NULL, icc4 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, r42 = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c4 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, c4t = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, Jlim = NULL, Klim = NULL, plim = NULL, varlim = NULL, nlab = NULL, Jlab = NULL, Klab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
od.4( n = NULL, J = NULL, K = NULL, p = NULL, icc2 = NULL, icc3 = NULL, icc4 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, r42 = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c4 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, c4t = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, Jlim = NULL, Klim = NULL, plim = NULL, varlim = NULL, nlab = NULL, Jlab = NULL, Klab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
n |
The level-1 sample size per level-2 unit. |
J |
The level-2 sample size per level-3 unit. |
K |
The level-3 sample size per level-4 unit. |
p |
The proportion of level-4 clusters/units to be assigned to treatment. |
icc2 |
The unconditional intraclass correlation coefficient (ICC) at level 2. |
icc3 |
The unconditional intraclass correlation coefficient (ICC) at level 3. |
icc4 |
The unconditional intraclass correlation coefficient (ICC) at level 4. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
r32 |
The proportion of level-3 variance explained by covariates. |
r42 |
The proportion of level-4 variance explained by covariates. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c3 |
The cost of sampling one level-3 unit in control condition. |
c4 |
The cost of sampling one level-4 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
c3t |
The cost of sampling one level-3 unit in treatment condition. |
c4t |
The cost of sampling one level-4 unit in treatment condition. |
m |
Total budget, default value is the total costs of sampling 60 level-4 units across treatment conditions. |
plots |
Logical, provide variance plots if TRUE, otherwise not; default value is TRUE. |
plot.by |
Plot the variance by |
nlim |
The plot range for n, default value is c(2, 50). |
Jlim |
The plot range for J, default value is c(2, 50). |
Klim |
The plot range for K, default value is c(2, 50). |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
nlab |
The plot label for |
Jlab |
The plot label for |
Klab |
The plot label for |
plab |
The plot label for |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
verbose |
Logical; print the values of |
iter |
Number of iterations; default value is 100. |
tol |
Tolerance for convergence; default value is 1e-10. |
Unconstrained or constrained optimal sample allocation
(n
, J
, K
, and p
).
The function also returns the variance of the treatment effect,
function name, design type,
and parameters used in the calculation.
# Unconstrained optimal design #--------- myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) myod1$out # output # Plots by p and K myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01), plot.by = list(p = 'p', K = 'K')) # Constrained optimal design with p = 0.5 #--------- myod2 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, p = 0.5, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.78 # Constrained optimal design with K = 20 #--------- myod3 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, K = 20, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.67 # Constrained n, J, K and p, no calculation performed #--------- myod4 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, n = 10, J = 10, K = 20, p = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.27
# Unconstrained optimal design #--------- myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) myod1$out # output # Plots by p and K myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01), plot.by = list(p = 'p', K = 'K')) # Constrained optimal design with p = 0.5 #--------- myod2 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, p = 0.5, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.78 # Constrained optimal design with K = 20 #--------- myod3 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, K = 20, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.67 # Constrained n, J, K and p, no calculation performed #--------- myod4 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, n = 10, J = 10, K = 20, p = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.27
The optimal design of four-level
multisite randomized trials (MRTs) is to calculate
the optimal sample allocation that minimizes the variance of
treatment effect under fixed budget, which is approximately the optimal
sample allocation that maximizes statistical power under a fixed budget.
The optimal design parameters include
the level-1 sample size per level-2 unit (n
),
the level-2 sample size per level-3 unit (J
),
the level-3 sample size per level-4 unit (K
),
and the proportion of level-3 units to be assigned to treatment (p
).
This function solves the optimal n
, J
, K
and/or p
with and without constraints.
od.4m( n = NULL, J = NULL, K = NULL, p = NULL, icc2 = NULL, icc3 = NULL, icc4 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, r42m = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c4 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, omega = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, Jlim = NULL, Klim = NULL, plim = NULL, varlim = NULL, nlab = NULL, Jlab = NULL, Klab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
od.4m( n = NULL, J = NULL, K = NULL, p = NULL, icc2 = NULL, icc3 = NULL, icc4 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, r42m = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c4 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, omega = NULL, m = NULL, plots = TRUE, plot.by = NULL, nlim = NULL, Jlim = NULL, Klim = NULL, plim = NULL, varlim = NULL, nlab = NULL, Jlab = NULL, Klab = NULL, plab = NULL, varlab = NULL, vartitle = NULL, verbose = TRUE, iter = 100, tol = 1e-10 )
n |
The level-1 sample size per level-2 unit. |
J |
The level-2 sample size per level-3 unit. |
K |
The level-3 sample size per level-4 unit. |
p |
The proportion of level-3 units to be assigned to treatment. |
icc2 |
The unconditional intraclass correlation coefficient (ICC) at level 2. |
icc3 |
The unconditional intraclass correlation coefficient (ICC) at level 3. |
icc4 |
The unconditional intraclass correlation coefficient (ICC) at level 4. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
r32 |
The proportion of level-3 variance explained by covariates. |
r42m |
The proportion of variance of site-specific treatment effect explained by covariates. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c3 |
The cost of sampling one level-3 unit in control condition. |
c4 |
The cost of sampling one level-4 unit. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
c3t |
The cost of sampling one level-3 unit in treatment condition. |
omega |
The standardized variance of site-specific treatment effect. |
m |
Total budget, default is the total costs of sampling 60 level-4 units. |
plots |
Logical, provide variance plots if TRUE, otherwise not; default value is TRUE. |
plot.by |
Plot the variance by |
nlim |
The plot range for n, default value is c(2, 50). |
Jlim |
The plot range for J, default value is c(2, 50). |
Klim |
The plot range for K, default value is c(2, 50). |
plim |
The plot range for p, default value is c(0, 1). |
varlim |
The plot range for variance, default value is c(0, 0.05). |
nlab |
The plot label for |
Jlab |
The plot label for |
Klab |
The plot label for |
plab |
The plot label for |
varlab |
The plot label for variance, default value is "Variance". |
vartitle |
The title of variance plot, default value is NULL. |
verbose |
Logical; print the values of |
iter |
Number of iterations; default value is 100. |
tol |
Tolerance for convergence; default value is 1e-10. |
Unconstrained or constrained optimal sample allocation
(n
, J
, K
, and p
).
The function also returns the variance of the treatment effect,
function name, design type,
and parameters used in the calculation.
# Unconstrained optimal design #--------- myod1 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005)) myod1$out # output # Plots by p and K myod1 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005), plot.by = list(p = 'p', K = 'K')) # Constrained optimal design with p = 0.5 #--------- myod2 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005), p = 0.5) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.88 # Constrained optimal design with J = 20 #--------- myod3 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005), J = 20) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.58 # Constrained n, J, K and p, no calculation performed #--------- myod4 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005), p = 0.5, n = 15, J = 20, K = 5) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.46
# Unconstrained optimal design #--------- myod1 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005)) myod1$out # output # Plots by p and K myod1 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005), plot.by = list(p = 'p', K = 'K')) # Constrained optimal design with p = 0.5 #--------- myod2 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005), p = 0.5) myod2$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.88 # Constrained optimal design with J = 20 #--------- myod3 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005), J = 20) myod3$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod3) myre$re # RE = 0.58 # Constrained n, J, K and p, no calculation performed #--------- myod4 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005), p = 0.5, n = 15, J = 20, K = 5) myod4$out # Relative efficiency (RE) myre <- re(od = myod1, subod= myod4) myre$re # RE = 0.46
This function can calculate required budget for desired power, power or minimum detectable effect size (MDES) under fixed budget for single-level experiments. It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).
power.1( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, p = NULL, r12 = NULL, q = NULL, c1 = NULL, c1t = NULL, dlim = NULL, powerlim = NULL, nlim = NULL, mlim = NULL, rounded = TRUE )
power.1( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, p = NULL, r12 = NULL, q = NULL, c1 = NULL, c1t = NULL, dlim = NULL, powerlim = NULL, nlim = NULL, mlim = NULL, rounded = TRUE )
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; two-tailed tests if TRUE, otherwise one-tailed 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 solving the root of effect size ( |
powerlim |
The range for solving 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.
# 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
# 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
This function can calculate required budget for desired power and power under a fixed budget for multisite-randomized trials (MRTs) with individual mediators probing mediation effects. It also can perform conventional power analyses (e.g., required sample size and power calculation).
power.1.111( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, a = NULL, b = NULL, power = NULL, m = NULL, test = NULL, n = NULL, p = NULL, c1 = NULL, c1t = NULL, r.yx = 0, r.mx = 0, r.mw = 0, q.a = 0, q.b = 0, max.iter = 300, alim = c(0, 4), blim = c(0.01, 0.99), powerlim = NULL, nlim = c(6, 1e+07), mlim = NULL )
power.1.111( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, a = NULL, b = NULL, power = NULL, m = NULL, test = NULL, n = NULL, p = NULL, c1 = NULL, c1t = NULL, r.yx = 0, r.mx = 0, r.mw = 0, q.a = 0, q.b = 0, max.iter = 300, alim = c(0, 4), blim = c(0.01, 0.99), powerlim = NULL, nlim = c(6, 1e+07), mlim = NULL )
cost.model |
Logical; power analyses accommodating costs and budget (e.g., required budget for a desired power, power under fixed budget) if TRUE. Otherwise, conventional power analyses are performed (e.g., required sample size and power calculation); default value is TRUE. |
expr |
Returned object from function |
constraint |
If specified, the constrained value of
|
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Two tailed test, the default value is TRUE. |
a |
The treatment effect on the mediator. |
b |
The within-treatment correlation between the outcome and the mediator. |
power |
Statistical power specified, default is .80. |
m |
Total budget. |
test |
The type of test will be used to detect mediation effects. The default is the NULL or the one used in the expr Choices are the joint significance test (i.e., test = "joint", "Joint","JOINT") or the Sobel test (test = "sobel", "Sobel", or "SOBEL"). |
n |
Total number of individuals in the experimental study, the default value is NULL. |
p |
The proportion of level-4 clusters/units to be assigned to treatment. |
c1 |
The cost of sampling an individual in the control group. |
c1t |
The cost of sampling an individual in the treated group. |
r.yx |
The within-treatment correlation between the outcome and the covariate(s) in the outcome model. |
r.mx |
The within-treatment correlation between the mediator and the covariate(s) in the outcome model. |
r.mw |
The within-treatment correlation between the mediator and the covariate(s) in the mediator model. |
q.a |
The number of covariates at the mediator model (except the treatment indicator), the default value is zero. |
q.b |
The number of covariates in the outcome model (except the treatment indicator and the mediator), the default value is zero. |
max.iter |
Maximal number of function evaluations when used as the stopping criterion. Default is 200. |
alim |
The range for identifying the root of a path
effect ( |
blim |
The range for identifying the root of b path within-treatment
correlation between the mediator and outcome ( |
powerlim |
The range for solving the root of power ( |
nlim |
The interval/range used to numerically solve for n, the default values are c(6, 1e7). |
mlim |
The range for identifying the root of budget ( |
Required budget (or required sample size), statistical power,
(a
) , or (b
) depending on the specification of parameters.
The function also returns the function name, design type,
and parameters used in the calculation.
# Optimal design and power analyses accommodating costs and budget myod <- od.1.111(a = .3, b = .5, c1 = 10, c1t = 100) # myod mypower <- power.1.111(expr = myod, power = .8) #mypower # Conventional power analyses mypower <- power.1.111(cost.model = FALSE, a = .3, b = .5, test = "joint", power = .8, p =.5) #mypower mypower <- power.1.111(cost.model = FALSE, n = 350, b = .5, test = "joint", power = .8, p =.5) #mypower
# Optimal design and power analyses accommodating costs and budget myod <- od.1.111(a = .3, b = .5, c1 = 10, c1t = 100) # myod mypower <- power.1.111(expr = myod, power = .8) #mypower # Conventional power analyses mypower <- power.1.111(cost.model = FALSE, a = .3, b = .5, test = "joint", power = .8, p =.5) #mypower mypower <- power.1.111(cost.model = FALSE, n = 350, b = .5, test = "joint", power = .8, p =.5) #mypower
This function can calculate required budget for desired power, power or minimum detectable effect size (MDES) under fixed budget for two-level cluster randomized trials (CRTs). It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).
power.2( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, p = NULL, icc = NULL, r12 = NULL, r22 = NULL, q = NULL, c1 = NULL, c2 = NULL, c1t = NULL, c2t = NULL, dlim = NULL, powerlim = NULL, Jlim = NULL, mlim = NULL, rounded = TRUE )
power.2( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, p = NULL, icc = NULL, r12 = NULL, r22 = NULL, q = NULL, c1 = NULL, c2 = NULL, c1t = NULL, c2t = NULL, dlim = NULL, powerlim = NULL, Jlim = NULL, mlim = NULL, rounded = TRUE )
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 values of |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Logical; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
d |
Effect size. |
power |
Statistical power. |
m |
Total budget. |
n |
The level-1 sample size per level-2 unit. |
J |
The total level-2 sample size. |
p |
The proportion of level-2 clusters/units to be assigned to treatment. |
icc |
The unconditional intraclass correlation coefficient (ICC) in population or in each treatment condition. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
q |
The number of level-2 covariates. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
dlim |
The range for solving the root of effect size ( |
powerlim |
The range for solving the root of power ( |
Jlim |
The range for searching the root of level-2 sample size ( |
mlim |
The range for searching the root of budget ( |
rounded |
Logical; round |
Required budget (and/or required level-2 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., & Kelcey, B. (2020). Optimal sample allocation under unequal costs in cluster-randomized trials. Journal of Educational and Behavioral Statistics, 45(4): 446–474. <https://doi.org/10.3102/1076998620912418>
# Unconstrained optimal design myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50) myod1$out # n = 8.9, p = 0.33 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.2(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 3755, J = 130.2 #mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.2(d = 0.2, power = 0.8, icc = 0.2, c1 = 1, c2 = 5, c1t = 1, c2t = 50, r12 = 0.5, r22 = 0.5, n = 9, p = 0.33, q = 1) # Required budget and sample size with constrained p mym.2 <- power.2(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 4210, J = 115.3 # Required budget and sample size with constrained p and n mym.3 <- power.2(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, n = 20)) mym.3$out # m = 4568, J = 96.2 # Power calculation mypower <- power.2(expr = myod1, q = 1, d = 0.2, m = 3755) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.2(expr = myod1, q = 1, d = 0.2, m = 3755, constraint = list(p = 0.5)) mypower.1$out # power = 0.75 # MDES calculation mymdes <- power.2(expr = myod1, q = 1, power = 0.80, m = 3755) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required J myJ <- power.2(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myJ$out # J = 130.2 #myJ$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myJ <- power.2(cost.model = FALSE, d = 0.2, power = 0.8, icc = 0.2, r12 = 0.5, r22 = 0.5, n = 9, p = 0.33, q = 1) # Power calculation mypower1 <- power.2(cost.model = FALSE, expr = myod1, J = 130, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.2(cost.model = FALSE, expr = myod1, J = 130, power = 0.8, q = 1) mymdes1$out # d = 0.20
# Unconstrained optimal design myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50) myod1$out # n = 8.9, p = 0.33 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.2(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 3755, J = 130.2 #mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.2(d = 0.2, power = 0.8, icc = 0.2, c1 = 1, c2 = 5, c1t = 1, c2t = 50, r12 = 0.5, r22 = 0.5, n = 9, p = 0.33, q = 1) # Required budget and sample size with constrained p mym.2 <- power.2(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 4210, J = 115.3 # Required budget and sample size with constrained p and n mym.3 <- power.2(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, n = 20)) mym.3$out # m = 4568, J = 96.2 # Power calculation mypower <- power.2(expr = myod1, q = 1, d = 0.2, m = 3755) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.2(expr = myod1, q = 1, d = 0.2, m = 3755, constraint = list(p = 0.5)) mypower.1$out # power = 0.75 # MDES calculation mymdes <- power.2(expr = myod1, q = 1, power = 0.80, m = 3755) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required J myJ <- power.2(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myJ$out # J = 130.2 #myJ$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myJ <- power.2(cost.model = FALSE, d = 0.2, power = 0.8, icc = 0.2, r12 = 0.5, r22 = 0.5, n = 9, p = 0.33, q = 1) # Power calculation mypower1 <- power.2(cost.model = FALSE, expr = myod1, J = 130, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.2(cost.model = FALSE, expr = myod1, J = 130, power = 0.8, q = 1) mymdes1$out # d = 0.20
This function can calculate required budget for desired power and power under a fixed budget for experimental studies with group mediators probing mediation effects. It also can perform conventional power analyses (e.g., required sample size and power calculation).
power.2.221( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, a = NULL, b = NULL, test = "joint", n = NULL, p = NULL, power = NULL, J = NULL, m = NULL, c1 = NULL, c1t = NULL, c2 = NULL, c2t = NULL, r2m = r2m, r.yx = 0, r.mw = 0, r.yw = 0, icc = NULL, q = 0, q.a = 0, q.b = 0, powerlim = NULL, Jlim = NULL, mlim = NULL )
power.2.221( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, a = NULL, b = NULL, test = "joint", n = NULL, p = NULL, power = NULL, J = NULL, m = NULL, c1 = NULL, c1t = NULL, c2 = NULL, c2t = NULL, r2m = r2m, r.yx = 0, r.mw = 0, r.yw = 0, icc = NULL, q = 0, q.a = 0, q.b = 0, powerlim = NULL, Jlim = NULL, mlim = NULL )
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; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
a |
The treatment effect on the mediator. |
b |
The within treatment correlation between the outcome and the mediator at the cluster level. |
test |
The type of test will be used to detect mediation effects. Default is the joint significance test (i.e., test = "joint"). The other choice is the Sobel test by specifying the argument as test = "sobel". |
n |
The level-1 sample size per level-2 unit. |
p |
The proportion of level-2 clusters/units to be assigned to treatment. |
power |
Statistical power. |
J |
The total level-2 sample size. |
m |
Total budget. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
r2m |
The proportion of mediator variance explained by covariates in the mediator model. |
r.yx |
The correlation between the outcome and the covariate at the individual level. |
r.mw |
The correlation between the mediator and the covariate at the cluster level. |
r.yw |
The correlation between the outcome and the covariate at the cluster level. |
icc |
The unconditional intraclass correlation coefficient (ICC) in population or in each treatment condition. |
q |
The number of level-2 covariates. |
q.a |
The number of covariates in the mediator model (except the treatment indicator). |
q.b |
The number of covariates in the outcome model at the cluster level (except the treatment indicator and the mediator). |
powerlim |
The range for solving the root of power ( |
Jlim |
The range for searching the root of level-2 sample size ( |
mlim |
the range for searching the root of budget ( |
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.
This function can calculate required budget for desired power, power or minimum detectable effect size (MDES) under fixed budget for two-level multisite randomized trials (MRTs). It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).
power.2m( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, p = NULL, icc = NULL, r12 = NULL, r22m = NULL, q = NULL, c1 = NULL, c2 = NULL, c1t = NULL, omega = NULL, dlim = NULL, powerlim = NULL, Jlim = NULL, mlim = NULL, rounded = TRUE )
power.2m( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, p = NULL, icc = NULL, r12 = NULL, r22m = NULL, q = NULL, c1 = NULL, c2 = NULL, c1t = NULL, omega = NULL, dlim = NULL, powerlim = NULL, Jlim = NULL, mlim = NULL, rounded = TRUE )
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 objects from function |
constraint |
Specify the constrained values of |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Logical; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
d |
Effect size. |
power |
Statistical power. |
m |
Total budget. |
n |
The level-1 sample size per level-2 unit. |
J |
The number of sites. |
p |
The proportion of level-1 units to be assigned to treatment. |
icc |
The unconditional intraclass correlation coefficient (ICC) in population or in each treatment condition. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22m |
The proportion of variance of site-specific treatment effect explained by covariates. |
q |
The number of covariates at level 2. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
omega |
The standardized variance of site-specific treatment effect. |
dlim |
The range for solving the root of effect size ( |
powerlim |
The range for solving the root of power ( |
Jlim |
The range for searching the root of level-2 sample size ( |
mlim |
The range for searching the root of budget ( |
rounded |
Logical; round the values of |
Required budget (and/or required level-2 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., & Kelcey, B. (in press). Optimal sample allocation in multisite randomized trials. The Journal of Experimental Education. <https://doi.org/10.1080/00220973.2020.1830361>
# Unconstrained optimal design #--------- myod1 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005)) myod1$out # n = 19.8, p = 0.37 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 2019, J = 20.9 # mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.2m(d = 0.2, power = 0.8, q = 1, icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, n = 20, p = 0.37) # Required budget and sample size with constrained p mym.2 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 2373, J = 19.8 # Required budget and sample size with constrained p and n mym.3 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, n = 5)) mym.3$out # m = 2502, J = 66.7 # Power calculation mypower <- power.2m(expr = myod1, q = 1, d = 0.2, m = 2019) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.2m(expr = myod1, q = 1, d = 0.2, m = 2019, constraint = list(p = 0.5)) mypower.1$out # power = 0.72 # MDES calculation mymdes <- power.2m(expr = myod1, q = 1, power = 0.80, m = 2019) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myJ <- power.2m(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myJ$out # J = 6.3 # myL$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myJ <- power.2m(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, n = 20, p = 0.37) # Power calculation mypower1 <- power.2m(cost.model = FALSE, expr = myod1, J = 6.3, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.2m(cost.model = FALSE, expr = myod1, J = 6.3, power = 0.8, q = 1) mymdes1$out # d = 0.20
# Unconstrained optimal design #--------- myod1 <- od.2m(icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, varlim = c(0, 0.005)) myod1$out # n = 19.8, p = 0.37 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 2019, J = 20.9 # mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.2m(d = 0.2, power = 0.8, q = 1, icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, n = 20, p = 0.37) # Required budget and sample size with constrained p mym.2 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 2373, J = 19.8 # Required budget and sample size with constrained p and n mym.3 <- power.2m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, n = 5)) mym.3$out # m = 2502, J = 66.7 # Power calculation mypower <- power.2m(expr = myod1, q = 1, d = 0.2, m = 2019) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.2m(expr = myod1, q = 1, d = 0.2, m = 2019, constraint = list(p = 0.5)) mypower.1$out # power = 0.72 # MDES calculation mymdes <- power.2m(expr = myod1, q = 1, power = 0.80, m = 2019) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myJ <- power.2m(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myJ$out # J = 6.3 # myL$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myJ <- power.2m(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc = 0.2, omega = 0.02, r12 = 0.5, r22m = 0.5, c1 = 1, c2 = 10, c1t = 10, n = 20, p = 0.37) # Power calculation mypower1 <- power.2m(cost.model = FALSE, expr = myod1, J = 6.3, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.2m(cost.model = FALSE, expr = myod1, J = 6.3, power = 0.8, q = 1) mymdes1$out # d = 0.20
This function can calculate required budget for desired power and power under a fixed budget for multisite-randomized trials (MRTs) with individual mediators probing mediation effects. It also can perform conventional power analyses (e.g., required sample size and power calculation).
power.2m.111( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, a = NULL, b = NULL, power = NULL, m = NULL, test = NULL, n = NULL, p = NULL, c1 = NULL, c1t = NULL, c2 = NULL, r12 = 0, r22m = 0, r12m = 0, icc.m = NULL, omega = NULL, icc = NULL, J = NULL, q = 0, q.a = 0, q.b = 0, max.iter = 300, powerlim = NULL, Jlim = NULL, mlim = NULL, rounded = TRUE )
power.2m.111( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, a = NULL, b = NULL, power = NULL, m = NULL, test = NULL, n = NULL, p = NULL, c1 = NULL, c1t = NULL, c2 = NULL, r12 = 0, r22m = 0, r12m = 0, icc.m = NULL, omega = NULL, icc = NULL, J = NULL, q = 0, q.a = 0, q.b = 0, max.iter = 300, powerlim = NULL, Jlim = NULL, mlim = NULL, rounded = TRUE )
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; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
a |
The treatment effect on the mediator. |
b |
The within treatment correlation between the outcome and the mediator. |
power |
Statistical power. |
m |
Total budget. |
test |
The type of test will be used to detect mediation effects. Default is the joint significance test (i.e., test = "joint"). Another choice is the Sobel test by specifying the argument as test = "sobel". |
n |
The level-1 sample size per level-2 unit. |
p |
The proportion of level-1 units to be assigned to treatment. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2 |
The cost of sampling one level-2 unit. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22m |
The proportion of variance of site-specific treatment effect explained by covariates. |
r12m |
The proportion of within treatment mediator variance at the level one explained by covariates. |
icc.m |
The intraclass correlation coefficient for the mediator. |
omega |
The standardized variance of site-specific treatment effect. |
icc |
The unconditional intraclass correlation coefficient (ICC) in population or in each treatment condition. |
J |
The number of sites. |
q |
The number of covariates at level 2. |
q.a |
The number of covariates at the individual level of the mediator model (except the treatment indicator). |
q.b |
The number of covariates in the outcome model (except the treatment indicator and the mediator). |
max.iter |
Maximal number of function evaluations when used as the stopping criterion. Default is 200. |
powerlim |
The range for solving the root of power ( |
Jlim |
The range for searching the root of level-2 sample size ( |
mlim |
the range for searching the root of budget ( |
rounded |
Logical; round the values of |
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.
This function can calculate required budget for desired power, power or minimum detectable effect size (MDES) under fixed budget for three-level cluster randomized trials (CRTs). It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).
power.3( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, K = NULL, p = NULL, icc2 = NULL, icc3 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, q = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, dlim = NULL, powerlim = NULL, Klim = NULL, mlim = NULL, rounded = TRUE )
power.3( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, K = NULL, p = NULL, icc2 = NULL, icc3 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, q = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, dlim = NULL, powerlim = NULL, Klim = NULL, mlim = NULL, rounded = TRUE )
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 objects from function |
constraint |
Specify the constrained values of |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Logical; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
d |
Effect size. |
power |
Statistical power. |
m |
Total budget. |
n |
The level-1 sample size per level-2 unit. |
J |
The level-2 sample size per level-3 unit. |
K |
The total level-3 sample size. |
p |
The proportion of level-3 clusters/units assigned to treatment. |
icc2 |
The unconditional intraclass correlation coefficient (ICC) at level 2. |
icc3 |
The unconditional intraclass correlation coefficient (ICC) at level 3. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
r32 |
The proportion of level-3 variance explained by covariates. |
q |
The number of covariates at level 3. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c3 |
The cost of sampling one level-3 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
c3t |
The cost of sampling one level-3 unit in treatment condition. |
dlim |
The range for solving the root of effect size ( |
powerlim |
The range for solving the root of power ( |
Klim |
The range for searching the root of level-3 sample size ( |
mlim |
The range for searching the root of budget ( |
rounded |
Logical; round the values of |
Required budget (and/or required level-3 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., & Kelcey, B. (2020). Optimal sample allocation under unequal costs in cluster-randomized trials. Journal of Educational and Behavioral Statistics, 45(4): 446–474. <https://doi.org/10.3102/1076998620912418>
# Unconstrained optimal design myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250) myod1$out # output # n = 7.9, J = 3.2, p = 0.28 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.3(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 16032, K = 97.3 #mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.3(d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, n = 8, J = 3, p = 0.28) # Required budget and sample size with constrained p mym.2 <- power.3(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 19239, K = 78.8 # Required budget and sample size with constrained p and J mym.3 <- power.3(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, J = 20)) mym.3$out # m = 39774, K = 46.9 # Power calculation mypower <- power.3(expr = myod1, q = 1, d = 0.2, m = 16032) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.3(expr = myod1, q = 1, d = 0.2, m = 16032, constraint = list(p = 0.5)) mypower.1$out # power = 0.72 # MDES calculation mymdes <- power.3(expr = myod1, q = 1, power = 0.80, m = 16032) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myK <- power.3(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myK$out # K = 97.3 #myK$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myK <- power.3(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, n = 8, J = 3, p = 0.28) # Power calculation mypower1 <- power.3(cost.model = FALSE, expr = myod1, K = 97, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.3(cost.model = FALSE, expr = myod1, K = 97, power = 0.8, q = 1) mymdes1$out # d = 0.20
# Unconstrained optimal design myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250) myod1$out # output # n = 7.9, J = 3.2, p = 0.28 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.3(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 16032, K = 97.3 #mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.3(d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, n = 8, J = 3, p = 0.28) # Required budget and sample size with constrained p mym.2 <- power.3(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 19239, K = 78.8 # Required budget and sample size with constrained p and J mym.3 <- power.3(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, J = 20)) mym.3$out # m = 39774, K = 46.9 # Power calculation mypower <- power.3(expr = myod1, q = 1, d = 0.2, m = 16032) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.3(expr = myod1, q = 1, d = 0.2, m = 16032, constraint = list(p = 0.5)) mypower.1$out # power = 0.72 # MDES calculation mymdes <- power.3(expr = myod1, q = 1, power = 0.80, m = 16032) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myK <- power.3(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myK$out # K = 97.3 #myK$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myK <- power.3(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, n = 8, J = 3, p = 0.28) # Power calculation mypower1 <- power.3(cost.model = FALSE, expr = myod1, K = 97, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.3(cost.model = FALSE, expr = myod1, K = 97, power = 0.8, q = 1) mymdes1$out # d = 0.20
This function can calculate required budget for desired power, power or minimum detectable effect size (MDES) under fixed budget for three-level multisite randomized trials (MRTs). It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).
power.3m( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, K = NULL, p = NULL, icc2 = NULL, icc3 = NULL, r12 = NULL, r22 = NULL, r32m = NULL, q = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c1t = NULL, c2t = NULL, omega = NULL, dlim = NULL, powerlim = NULL, Klim = NULL, mlim = NULL, rounded = TRUE )
power.3m( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, K = NULL, p = NULL, icc2 = NULL, icc3 = NULL, r12 = NULL, r22 = NULL, r32m = NULL, q = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c1t = NULL, c2t = NULL, omega = NULL, dlim = NULL, powerlim = NULL, Klim = NULL, mlim = NULL, rounded = TRUE )
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 objects from function |
constraint |
Specify the constrained values of |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Logical; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
d |
Effect size. |
power |
Statistical power. |
m |
Total budget. |
n |
The level-1 sample size per level-2 unit. |
J |
The level-2 sample size per level-3 unit. |
K |
The level-3 sample size per level-4 unit. |
p |
The proportion of level-2 units to be assigned to treatment. |
icc2 |
The unconditional intraclass correlation coefficient (ICC) at level 2. |
icc3 |
The unconditional intraclass correlation coefficient (ICC) at level 3. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
r32m |
The proportion of variance of site-specific treatment effect explained by covariates. |
q |
The number of covariates at level 3. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c3 |
The cost of sampling one level-3 unit. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
omega |
The standardized variance of site-specific treatment effect. |
dlim |
The range for solving the root of effect size ( |
powerlim |
The range for solving the root of power ( |
Klim |
The range for searching the root of level-3 sample size ( |
mlim |
The range for searching the root of budget ( |
rounded |
Logical; round the values of |
Required budget (and/or required level-3 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., & Kelcey, B. (in press). Optimal sampling ratios in three-level multisite experiments. Journal of Research on Educational Effectiveness.
# Unconstrained optimal design #--------- myod1 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005)) myod1$out # n = 13.1, J = 15.3, p = 0.23 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.3m(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 15491, K = 13.6 # mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.3m(d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, n = 13, J = 15, p = 0.23) # Required budget and sample size with constrained p mym.2 <- power.3m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 21072, K = 10.9 # Required budget and sample size with constrained p and n mym.3 <- power.3m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, n = 20)) mym.3$out # m = 21252, K = 10.4 # Power calculation mypower <- power.3m(expr = myod1, q = 1, d = 0.2, m = 15491) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.3m(expr = myod1, q = 1, d = 0.2, m = 15491, constraint = list(p = 0.5)) mypower.1$out # power = 0.62 # MDES calculation mymdes <- power.3m(expr = myod1, q = 1, power = 0.80, m = 15491) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myK <- power.3m(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myK$out # K = 13.6 # myK$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myK <- power.3m(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, n = 13, J = 15, p = 0.23) # Power calculation mypower1 <- power.3m(cost.model = FALSE, expr = myod1, K = 13.6, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.3m(cost.model = FALSE, expr = myod1, K = 13.6, power = 0.8, q = 1) mymdes1$out # d = 0.20
# Unconstrained optimal design #--------- myod1 <- od.3m(icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, varlim = c(0, 0.005)) myod1$out # n = 13.1, J = 15.3, p = 0.23 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.3m(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 15491, K = 13.6 # mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.3m(d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, n = 13, J = 15, p = 0.23) # Required budget and sample size with constrained p mym.2 <- power.3m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 21072, K = 10.9 # Required budget and sample size with constrained p and n mym.3 <- power.3m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, n = 20)) mym.3$out # m = 21252, K = 10.4 # Power calculation mypower <- power.3m(expr = myod1, q = 1, d = 0.2, m = 15491) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.3m(expr = myod1, q = 1, d = 0.2, m = 15491, constraint = list(p = 0.5)) mypower.1$out # power = 0.62 # MDES calculation mymdes <- power.3m(expr = myod1, q = 1, power = 0.80, m = 15491) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myK <- power.3m(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myK$out # K = 13.6 # myK$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myK <- power.3m(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, omega = 0.02, r12 = 0.5, r22 = 0.5, r32m = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 200, c3 = 200, n = 13, J = 15, p = 0.23) # Power calculation mypower1 <- power.3m(cost.model = FALSE, expr = myod1, K = 13.6, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.3m(cost.model = FALSE, expr = myod1, K = 13.6, power = 0.8, q = 1) mymdes1$out # d = 0.20
This function can calculate required budget for desired power, power or minimum detectable effect size (MDES) under fixed budget for four-level cluster randomized trials (CRTs). It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).
power.4( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, K = NULL, L = NULL, p = NULL, icc2 = NULL, icc3 = NULL, icc4 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, r42 = NULL, q = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c4 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, c4t = NULL, dlim = NULL, powerlim = NULL, Llim = NULL, mlim = NULL, rounded = TRUE )
power.4( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, K = NULL, L = NULL, p = NULL, icc2 = NULL, icc3 = NULL, icc4 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, r42 = NULL, q = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c4 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, c4t = NULL, dlim = NULL, powerlim = NULL, Llim = NULL, mlim = NULL, rounded = TRUE )
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 objects from function |
constraint |
Specify the constrained values of |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Logical; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
d |
Effect size. |
power |
Statistical power. |
m |
Total budget. |
n |
The level-1 sample size per level-2 unit. |
J |
The level-2 sample size per level-3 unit. |
K |
The level-3 sample size per level-4 unit. |
L |
The total level-4 sample size. |
p |
The proportion of level-4 clusters/units to be assigned to treatment. |
icc2 |
The unconditional intraclass correlation coefficient (ICC) at level 2. |
icc3 |
The unconditional intraclass correlation coefficient (ICC) at level 3. |
icc4 |
The unconditional intraclass correlation coefficient (ICC) at level 4. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
r32 |
The proportion of level-3 variance explained by covariates. |
r42 |
The proportion of level-4 variance explained by covariates. |
q |
The number of covariates at level 4. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c3 |
The cost of sampling one level-3 unit in control condition. |
c4 |
The cost of sampling one level-4 unit in control condition. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
c3t |
The cost of sampling one level-3 unit in treatment condition. |
c4t |
The cost of sampling one level-4 unit in treatment condition. |
dlim |
The range for solving the root of effect size ( |
powerlim |
The range for solving the root of power ( |
Llim |
The range for solving the root of level-4 sample size ( |
mlim |
The range for searching the root of budget ( |
rounded |
Logical; round the values of |
Required budget (and/or required level-4 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.
# Unconstrained optimal design myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500) myod1$out # output # n = 7.1, J = 3.2, K = 4.2, p = 0.23 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.4(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 71161, L = 57.1 #mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.4(d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, n = 7, J = 3, K = 4, p = 0.23) # Required budget and sample size with constrained p (p = 0.5) mym.2 <- power.4(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 93508, L = 41.1 # Required budget and sample size with constrained p and K mym.3 <- power.4(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, K = 20)) mym.3$out # m = 157365, L = 25.7 # Power calculation mypower <- power.4(expr = myod1, q = 1, d = 0.2, m = 71161) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.4(expr = myod1, q = 1, d = 0.2, m = 71161, constraint = list(p = 0.5)) mypower.1$out # power = 0.68 # MDES calculation mymdes <- power.4(expr = myod1, q = 1, power = 0.80, m = 71161) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myL <- power.4(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myL$out # L = 57.1 #myL$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myL <- power.4(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, n = 7, J = 3, K = 4, p = 0.23) # Power calculation mypower1 <- power.4(cost.model = FALSE, expr = myod1, L = 57, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.4(cost.model = FALSE, expr = myod1, L = 57, power = 0.8, q = 1) mymdes1$out # d = 0.20
# Unconstrained optimal design myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500) myod1$out # output # n = 7.1, J = 3.2, K = 4.2, p = 0.23 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.4(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 71161, L = 57.1 #mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.4(d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, n = 7, J = 3, K = 4, p = 0.23) # Required budget and sample size with constrained p (p = 0.5) mym.2 <- power.4(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 93508, L = 41.1 # Required budget and sample size with constrained p and K mym.3 <- power.4(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, K = 20)) mym.3$out # m = 157365, L = 25.7 # Power calculation mypower <- power.4(expr = myod1, q = 1, d = 0.2, m = 71161) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.4(expr = myod1, q = 1, d = 0.2, m = 71161, constraint = list(p = 0.5)) mypower.1$out # power = 0.68 # MDES calculation mymdes <- power.4(expr = myod1, q = 1, power = 0.80, m = 71161) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myL <- power.4(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myL$out # L = 57.1 #myL$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myL <- power.4(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, n = 7, J = 3, K = 4, p = 0.23) # Power calculation mypower1 <- power.4(cost.model = FALSE, expr = myod1, L = 57, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.4(cost.model = FALSE, expr = myod1, L = 57, power = 0.8, q = 1) mymdes1$out # d = 0.20
This function can calculate required budget for desired power, power or minimum detectable effect size (MDES) under fixed budget for four-level multisite randomized trials (MRTs). It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).
power.4m( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, K = NULL, L = NULL, p = NULL, icc2 = NULL, icc3 = NULL, icc4 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, r42m = NULL, q = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c4 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, omega = NULL, dlim = NULL, powerlim = NULL, Llim = NULL, mlim = NULL, rounded = TRUE )
power.4m( cost.model = TRUE, expr = NULL, constraint = NULL, sig.level = 0.05, two.tailed = TRUE, d = NULL, power = NULL, m = NULL, n = NULL, J = NULL, K = NULL, L = NULL, p = NULL, icc2 = NULL, icc3 = NULL, icc4 = NULL, r12 = NULL, r22 = NULL, r32 = NULL, r42m = NULL, q = NULL, c1 = NULL, c2 = NULL, c3 = NULL, c4 = NULL, c1t = NULL, c2t = NULL, c3t = NULL, omega = NULL, dlim = NULL, powerlim = NULL, Llim = NULL, mlim = NULL, rounded = TRUE )
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 objects from function |
constraint |
The constrained values of |
sig.level |
Significance level or type I error rate, default value is 0.05. |
two.tailed |
Logical; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE. |
d |
Effect size. |
power |
Statistical power. |
m |
Total budget. |
n |
The level-1 sample size per level-2 unit. |
J |
The level-2 sample size per level-3 unit. |
K |
The level-3 sample size per level-4 unit. |
L |
The total level-4 sample size. |
p |
The proportion of level-3 units to be assigned to treatment. |
icc2 |
The unconditional intraclass correlation coefficient (ICC) at level 2. |
icc3 |
The unconditional intraclass correlation coefficient (ICC) at level 3. |
icc4 |
The unconditional intraclass correlation coefficient (ICC) at level 4. |
r12 |
The proportion of level-1 variance explained by covariates. |
r22 |
The proportion of level-2 variance explained by covariates. |
r32 |
The proportion of level-3 variance explained by covariates. |
r42m |
The proportion of variance of site-specific treatment effect explained by covariates. |
q |
The number of covariates at level 4. |
c1 |
The cost of sampling one level-1 unit in control condition. |
c2 |
The cost of sampling one level-2 unit in control condition. |
c3 |
The cost of sampling one level-3 unit in control condition. |
c4 |
The cost of sampling one level-4 unit. |
c1t |
The cost of sampling one level-1 unit in treatment condition. |
c2t |
The cost of sampling one level-2 unit in treatment condition. |
c3t |
The cost of sampling one level-3 unit in treatment condition. |
omega |
The standardized variance of site-specific treatment effect. |
dlim |
The range for solving the root of effect size ( |
powerlim |
The range for solving the root of power ( |
Llim |
The range for solving the root of level-4 sample size ( |
mlim |
The range for searching the root of budget ( |
rounded |
Logical; round the values of |
Required budget (and/or required level-4 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.
# Unconstrained optimal design #--------- myod1 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005)) myod1$out # n = 8.3, J = 3.2, K = 4.9, p = 0.36 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.4m(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 30201, L = 20.6 # mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.4m(d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, n = 8, J = 3, K = 5, p = 0.36) # Required budget and sample size with constrained p mym.2 <- power.4m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 33183, L = 19.3 # Required budget and sample size with constrained p and n mym.3 <- power.4m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, n = 20)) mym.3$out # m = 34262, L = 18.0 # Power calculation mypower <- power.4m(expr = myod1, q = 1, d = 0.2, m = 30201) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.4m(expr = myod1, q = 1, d = 0.2, m = 30201, constraint = list(p = 0.5)) mypower.1$out # power = 0.76 # MDES calculation mymdes <- power.4m(expr = myod1, q = 1, power = 0.80, m = 30201) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myL <- power.4m(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myL$out # L = 20.6 # myL$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myL <- power.4m(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, n = 8, J = 3, K = 5, p = 0.36) # Power calculation mypower1 <- power.4m(cost.model = FALSE, expr = myod1, L = 20.6, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.4m(cost.model = FALSE, expr = myod1, L = 20.6, power = 0.8, q = 1) mymdes1$out # d = 0.20
# Unconstrained optimal design #--------- myod1 <- od.4m(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, varlim = c(0, 0.005)) myod1$out # n = 8.3, J = 3.2, K = 4.9, p = 0.36 # ------- Power analyses by default considering costs and budget ------- # Required budget and sample size mym.1 <- power.4m(expr = myod1, d = 0.2, q = 1, power = 0.8) mym.1$out # m = 30201, L = 20.6 # mym.1$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function mym.1 <- power.4m(d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, n = 8, J = 3, K = 5, p = 0.36) # Required budget and sample size with constrained p mym.2 <- power.4m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5)) mym.2$out # m = 33183, L = 19.3 # Required budget and sample size with constrained p and n mym.3 <- power.4m(expr = myod1, d = 0.2, q = 1, power = 0.8, constraint = list(p = 0.5, n = 20)) mym.3$out # m = 34262, L = 18.0 # Power calculation mypower <- power.4m(expr = myod1, q = 1, d = 0.2, m = 30201) mypower$out # power = 0.80 # Power calculation under constrained p (p = 0.5) mypower.1 <- power.4m(expr = myod1, q = 1, d = 0.2, m = 30201, constraint = list(p = 0.5)) mypower.1$out # power = 0.76 # MDES calculation mymdes <- power.4m(expr = myod1, q = 1, power = 0.80, m = 30201) mymdes$out # d = 0.20 # ------- Conventional power analyses with cost.model = FALSE------- # Required sample size myL <- power.4m(cost.model = FALSE, expr = myod1, d = 0.2, q = 1, power = 0.8) myL$out # L = 20.6 # myL$par # parameters and their values used for the function # Or, equivalently, specify every argument in the function myL <- power.4m(cost.model = FALSE, d = 0.2, power = 0.8, q = 1, icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, omega = 0.02, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42m = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, c4 = 500, n = 8, J = 3, K = 5, p = 0.36) # Power calculation mypower1 <- power.4m(cost.model = FALSE, expr = myod1, L = 20.6, d = 0.2, q = 1) mypower1$out # power = 0.80 # MDES calculation mymdes1 <- power.4m(cost.model = FALSE, expr = myod1, L = 20.6, power = 0.8, q = 1) mymdes1$out # d = 0.20
Calculate the relative efficiency (RE) between two designs, it returns
same results as those from function rpe
.
re(od, subod, rounded = TRUE, verbose = TRUE)
re(od, subod, rounded = TRUE, verbose = TRUE)
od |
Returned object of first design (e.g., unconstrained optimal design)
from function |
subod |
Returned object of second design (e.g., constrained optimal design)
from function |
rounded |
Logical; round the values of |
verbose |
Logical; print the value of relative efficiency if TRUE, otherwise not; default is TRUE. |
Relative efficiency value.
(1) Shen, Z., & Kelcey, B. (2020). Optimal sample allocation under unequal costs in cluster-randomized trials. Journal of Educational and Behavioral Statistics, 45(4): 446–474. <https://doi.org/10.3102/1076998620912418> (2) Shen, Z., & Kelcey, B. (in press). Optimal sample allocation in multisite randomized trials. The Journal of Experimental Education. <https://doi.org/10.1080/00220973.2020.1830361> (3) Shen, Z., & Kelcey, B. (in press). Optimal sampling ratios in three-level multisite experiments. Journal of Research on Educational Effectiveness.
# Unconstrained optimal design of 2-level CRT #---------- myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, varlim = c(0.01, 0.02)) # Constrained optimal design with n = 20 myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, n = 20, varlim = c(0.005, 0.025)) # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.88 # Constrained optimal design with p = 0.5 myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, p = 0.5, varlim = c(0.005, 0.025)) # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.90 # Unconstrained optimal design of 3-level CRT #---------- myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025)) # Constrained optimal design with J = 20 myod2 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, J = 20, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0, 0.025)) # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.53 # Unconstrained optimal design of 4-level CRT #--------- myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) # Constrained optimal design with p = 0.5 myod2 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, p = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.78
# Unconstrained optimal design of 2-level CRT #---------- myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, varlim = c(0.01, 0.02)) # Constrained optimal design with n = 20 myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, n = 20, varlim = c(0.005, 0.025)) # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.88 # Constrained optimal design with p = 0.5 myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, p = 0.5, varlim = c(0.005, 0.025)) # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.90 # Unconstrained optimal design of 3-level CRT #---------- myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025)) # Constrained optimal design with J = 20 myod2 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, J = 20, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0, 0.025)) # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.53 # Unconstrained optimal design of 4-level CRT #--------- myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) # Constrained optimal design with p = 0.5 myod2 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, p = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) # Relative efficiency (RE) myre <- re(od = myod1, subod= myod2) myre$re # RE = 0.78
Calculate the relative precision and efficiency (RPE) between two designs,
it returns same results as those from function re
.
rpe(od, subod, rounded = TRUE, verbose = TRUE)
rpe(od, subod, rounded = TRUE, verbose = TRUE)
od |
Returned object of first design (e.g., unconstrained optimal design)
from function |
subod |
Returned object of second design (e.g., constrained optimal design)
from function |
rounded |
Logical; round the values of |
verbose |
Logical; print the value of relative precision and efficiency if TRUE, otherwise not; default is TRUE. |
Relative precision and efficiency value.
(1) Shen, Z., & Kelcey, B. (2020). Optimal sample allocation under unequal costs in cluster-randomized trials. Journal of Educational and Behavioral Statistics, 45(4): 446–474. <https://doi.org/10.3102/1076998620912418> (2) Shen, Z., & Kelcey, B. (in press). Optimal sample allocation in multisite randomized trials. The Journal of Experimental Education. <https://doi.org/10.1080/00220973.2020.1830361> (3) Shen, Z., & Kelcey, B. (in press). Optimal sampling ratios in three-level multisite experiments. Journal of Research on Educational Effectiveness.
# Unconstrained optimal design of 2-level CRT #---------- myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, varlim = c(0.01, 0.02)) # Constrained optimal design with n = 20 myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, n = 20, varlim = c(0.005, 0.025)) # Relative precision and efficiency (RPE) myrpe <- rpe(od = myod1, subod= myod2) myrpe$rpe # RPE = 0.88 # Constrained optimal design with p = 0.5 myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, p = 0.5, varlim = c(0.005, 0.025)) # Relative precision and efficiency (RPE) myrpe <- rpe(od = myod1, subod= myod2) myrpe$rpe # RPE = 0.90 # Unconstrained optimal design of 3-level CRT #---------- myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025)) # Constrained optimal design with J = 20 myod2 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, J = 20, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0, 0.025)) # Relative precision and efficiency (RPE) myrpe <- rpe(od = myod1, subod= myod2) myrpe$rpe # RPE = 0.53 # Unconstrained optimal design of 4-level CRT #--------- myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) # Constrained optimal design with p = 0.5 myod2 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, p = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) # Relative precision and efficiency (RPE) myrpe <- rpe(od = myod1, subod= myod2) myrpe$rpe # RPE = 0.78
# Unconstrained optimal design of 2-level CRT #---------- myod1 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, varlim = c(0.01, 0.02)) # Constrained optimal design with n = 20 myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, n = 20, varlim = c(0.005, 0.025)) # Relative precision and efficiency (RPE) myrpe <- rpe(od = myod1, subod= myod2) myrpe$rpe # RPE = 0.88 # Constrained optimal design with p = 0.5 myod2 <- od.2(icc = 0.2, r12 = 0.5, r22 = 0.5, c1 = 1, c2 = 5, c1t = 1, c2t = 50, p = 0.5, varlim = c(0.005, 0.025)) # Relative precision and efficiency (RPE) myrpe <- rpe(od = myod1, subod= myod2) myrpe$rpe # RPE = 0.90 # Unconstrained optimal design of 3-level CRT #---------- myod1 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0.005, 0.025)) # Constrained optimal design with J = 20 myod2 <- od.3(icc2 = 0.2, icc3 = 0.1, r12 = 0.5, r22 = 0.5, r32 = 0.5, J = 20, c1 = 1, c2 = 5, c3 = 25, c1t = 1, c2t = 50, c3t = 250, varlim = c(0, 0.025)) # Relative precision and efficiency (RPE) myrpe <- rpe(od = myod1, subod= myod2) myrpe$rpe # RPE = 0.53 # Unconstrained optimal design of 4-level CRT #--------- myod1 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) # Constrained optimal design with p = 0.5 myod2 <- od.4(icc2 = 0.2, icc3 = 0.1, icc4 = 0.05, r12 = 0.5, p = 0.5, r22 = 0.5, r32 = 0.5, r42 = 0.5, c1 = 1, c2 = 5, c3 = 25, c4 = 125, c1t = 1, c2t = 50, c3t = 250, c4t = 2500, varlim = c(0, 0.01)) # Relative precision and efficiency (RPE) myrpe <- rpe(od = myod1, subod= myod2) myrpe$rpe # RPE = 0.78