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

View source: R/power.1.111m.R

power.1.111mR Documentation

Budget and/or sample size, power, MDES calculation for single-level randomized controlled trials (RCTs) investigating moderation effects (1-1-1m)

Description

This function can calculate required budget for desired power, the minimum detectable effect size, and statistical power under a fixed budget in randomized controlled trials (RCTs) probing moderation effects. It also can perform conventional power analyses (e.g., required sample size calculation, minimum detectable effect size calculation, and power calculation).

Usage

power.1.111m(
  cost.model = TRUE,
  expr = NULL,
  constraint = NULL,
  sig.level = 0.05,
  two.tailed = TRUE,
  gamma = NULL,
  binary = TRUE,
  power = NULL,
  m = NULL,
  n = NULL,
  p = NULL,
  Q = 0.5,
  c1 = NULL,
  c1t = NULL,
  r.yx = 0,
  r.mx = 0,
  r.ym = 0,
  q.mod = 1,
  gammalim = c(0.005, 5),
  powerlim = c(1e-04, 0.9999),
  nlim = c(20, 1e+07),
  mlim = NULL
)

Arguments

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 od.1.111m; default value is NULL; if expr is specified, parameter values of a, b, c, ct, and p used or solved in function od.1.111m will be passed to the current function; only the values of p that specified or solved in function od.1.111m can be overwritten if constraint is specified.

constraint

If specified, the constrained value of p in a list format (e.g., constraint = list(p = 0.5)) will overwrite that from expr; default value is NULL.

sig.level

Significance level, default value is .05.

two.tailed

Logical; two-tailed tests if TRUE, otherwise one-tailed tests; default value is TRUE.

gamma

Moderated treatment effect.

binary

Logical. The moderator is binary if TRUE and continuous if FALSE. Default is TRUE.

power

Statistical power.

m

Total budget.

n

Total number of individuals.

p

The proportion of individuals assigned to the experimental group.

Q

The proportion of individuals in one group the binary moderator. Default value is 0.5, which requires the minimum number of individuals to achieve a targeted power. Change it as necessary.

c1

The cost of sampling one unit in control condition.

c1t

The cost of sampling one unit in treatment condition.

r.yx

Within-treatment correlation between the outcome (y) and the covariate (x) for continuous moderators. Within-treatment within-moderator correlation between the outcome (y) and the covariate (x) for binary moderators.

r.mx

Within-treatment correlation between the moderator (m) and the covariate (x), if specified, for continuous moderators.

r.ym

Within-treatment correlation between the outcome (y) and the moderator (m), if specified, for continuous moderators.

q.mod

The number of covariates in the moderation model (besides the treatment, moderator, and their interaction term). The default value is 1.

gammalim

The range for identifying the root of moderation effect size (gamma) numerically, default value is c(0.005, 5).

powerlim

The range for identifying the root of power (power) numerically, default value is c(0.0001, 0.9999).

nlim

The range for identifying the root of sample size (n) numerically. Default is c(20, 1e7).

mlim

The range for identifying the root of budget (m) numerically, default value is the costs sampling nlim units.

Value

Required budget (m) or required sample size (n), statistical power(power), minimum detectable moderation effect size (gamma), depending on the specification of parameters. The function also returns the function name, design type, and parameters used in the calculation.

Examples

# Optimal design and power analyses accommodating costs and budget
myod <- od.1.111m(d =.1, gamma = .2, r12 = .50,
                 c1 = 10, c1t = 100)
myod
N <- power.1.111m(expr = myod, power = .8)
N$out

# Conventional power analyses
# Required sample size for a binary moderator
N <- power.1.111m(cost.model = FALSE, gamma = .2, power = .8, p =.5)
N

# Required sample size for a continuous moderator
N <- power.1.111m(cost.model = FALSE,
                  gamma = .2, power = .8, p =.5, binary = FALSE)
N


odr documentation built on Nov. 5, 2025, 5:12 p.m.