power.2m.111m: Budget and/or sample size, power, MDES calculation for...

View source: R/power.2m.111m.R

power.2m.111mR Documentation

Budget and/or sample size, power, MDES calculation for two-level MRTs detecting moderation effects with moderators at level 1

Description

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) detecting moderation effects with moderators at level 1. It also can perform conventional power analyses (e.g., required sample size, power, and MDES calculation).

Usage

power.2m.111m(
  cost.model = TRUE,
  expr = NULL,
  constraint = NULL,
  sig.level = 0.05,
  two.tailed = TRUE,
  omega = NULL,
  gamma = NULL,
  power = NULL,
  m = NULL,
  n = NULL,
  J = NULL,
  p = NULL,
  icc = NULL,
  r12 = NULL,
  q = 1,
  c1 = NULL,
  c2 = NULL,
  c1t = NULL,
  gammalim = c(0, 5),
  powerlim = c(1e-10, 1 - 1e-10),
  Jlim = c(6, 1e+10),
  mlim = NULL,
  rounded = TRUE,
  binary = TRUE,
  Q = 0.5,
  random.slope = TRUE
)

Arguments

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 od.2m; default is NULL; if expr is specified, parameter values of icc, r12, r22m, c1, c2, c1t, p, and n used or solved in function od.2m will be passed to current function; only the values of p and n that specified or solved in function od.2m can be overwritten if constraint is specified.

constraint

Specify the constrained values of p and/or n in list format to overwrite those from expr; default value is NULL.

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.

omega

The treatment-by-site variance of the outcome.

gamma

The standardized moderated treatment effect.

power

Statistical power.

m

Total budget, default is the total costs of sampling 60 sites.

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.

q

The number of additional covariates at level 1 beyond the treatment indicator, covariate, and the interaction between the moderator and the treatment. Default is 1.

c1

The cost of sampling one level-1 unit in control condition.

c2

The cost of sampling one level-2 unit (site).

c1t

The cost of sampling one level-1 unit in treatment condition.

gammalim

The range for searching the root of standardized moderation effect (gamma). Default is c(0, 5).

powerlim

The range for solving the root of power (power) numerically, default value is c(1e-10, 1 - 1e-10).

Jlim

The range for solving the root of level-2 sample size (J) numerically, default value is c(6, 1e+10).

mlim

The range for searching the root of budget (m) numerically, default is the costs sampling Jlim level-2 units or c(4 * Jcost, 1e+10 * Jcost) with Jcost = (1 - p) * c1 * n + p * c1t * n + c2.

rounded

Logical; round the values of p, n/J/K that are from functions od.4 to two decimal places and integer, respectively if TRUE, otherwise no rounding; default value is TRUE.

binary

Logical; binary moderator if TURE and continuous moderator if FALSE. Default is TRUE.

Q

The proportion of units in one group for the binary moderator. Default is 0.5.

random.slope

Logical, the model is a random slope one if TURE. Default is TRUE.

Value

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.

Examples

myod <- od.2m.111m(icc = .2, r12 = .5, r22m = .5,
                   c1 = 10, c1t = 100, c2 = 50, omega = .01, gamma = 0.1)
mypowwer <- power.2m.111m(expr = myod, gamma = .1, power = .8)

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