od.2.221m: Optimal sample allocation calculation for two-level CRTs...

View source: R/od.2.221m.R

od.2.221mR Documentation

Optimal sample allocation calculation for two-level CRTs probing moderation effects with cluster-level moderators

Description

The optimal design of two-level cluster randomized trials (CRTs) probing moderation effects with cluster-level moderators is to to identify the optimal sample allocation that requires the minimum budget to achieve a 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.

Usage

od.2.221m(
  d = NULL,
  gamma = NULL,
  n = NULL,
  Q = NULL,
  p = NULL,
  icc = NULL,
  c1 = NULL,
  c1t = NULL,
  c2 = NULL,
  c2t = NULL,
  r12 = NULL,
  r22 = NULL,
  r12m = NULL,
  r22m = NULL,
  m = NULL,
  q.main = 0,
  q.mod = 0,
  tol = 1e-11,
  power.mod = 0.8,
  power.main = 0.8,
  d.p = c(0.5, 0.9),
  d.n = c(2, 1000),
  sig.level = 0.05,
  two.tailed = TRUE,
  Jlim = NULL,
  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
)

Arguments

d

The standardized main or average treatment effect.

gamma

The standardized moderated treatment effect (i.e., regression coefficient of the interaction term of moderator and treatment).

n

The level-1 sample size per level-2 unit.

Q

The proportion of binary moderator that coded as 1.

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.

r12

The proportion of level-1 variance explained by covariates.

r22

The proportion of level-2 variance explained by covariates.

r12m

The proportion of outcome variance at the individual level explained by covariates in the model with the moderator.

r22m

The proportion of outcome variance at the cluster level explained by covariates in the model with the moderator.

m

Total budget.

q.main

The number of covariates in the outcome model testing main effects

q.mod

The number of cluster-level covariates in the model (except the treatment indicator, moderator, and the interaction term).

tol

convergence tolerance.

power.mod

Statistical power specified for moderation. The default value is .80.

power.main

Statistical power specified for the total/main effect. The default value is .80.

d.p

The initial sampling domains for p. Default is c(0.5, 0.9).

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.mod, q.main)+7, 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.

Value

Unconstrained or constrained optimal sample allocation (n and p). The function also returns function name, design type, and parameters used in the calculation.


odr documentation built on June 8, 2025, 10:50 a.m.