Learn R Programming

anomo (version 1.0.0)

power.eq.2group: Statistical Power Analysis for Equivalence Tests of Two-Group Means

Description

Statistical power analysis for equivalence test of two-group means.

Usage

power.eq.2group(
  cost.model = FALSE,
  expr = NULL,
  constraint = NULL,
  d = NULL,
  eq.dis = NULL,
  m = NULL,
  c1 = NULL,
  c1t = NULL,
  n = NULL,
  p = NULL,
  q = 1,
  sig.level = 0.05,
  r12 = NULL,
  power = NULL,
  powerlim = NULL,
  nlim = NULL,
  mlim = NULL,
  eq.dislim = NULL,
  verbose = TRUE
)

Value

Required budget (and/or required sample size), statistical power, or minimum detectable eq.dis depending on the specification of parameters. The function also returns the function name, design type, and parameters used in the calculation.

Arguments

cost.model

Logical; power analyses accommodating costs and budget (e.g., required budget for desired power, power, minimum detectable eq.dis under a fixed budget) if TRUE. Otherwise, conventional power analysis is performed (e.g., required sample size, power, or minimum detectable eq.dis calculation); default value is FALSE, and it will be changed to TRUE if expr is not NULL.

expr

Returned object from function od.eq.2group; default value is NULL; if expr is specified, parameter values of r12, c1, c1t, and p used or solved in function od.eq.2group will be passed to the current function; only the value of p that specified or solved in function od.eq.2group can be overwritten if constraint is specified.

constraint

Specify the constrained value of p in list format to overwrite that from expr; default value is NULL.

d

The estimated difference in two-group means.

eq.dis

A positive number to specify the distance from equivalence bounds to d. The equivalence bounds are c(-abs(d)-eq.dis, abs(d)+eq.dis).

m

Total budget.

c1

The cost of sampling one unit in the control condition.

c1t

The cost of sampling one unit in the treated condition.

n

The total sample size across groups.

p

The proportion of individuals in the intervention group or group 1.

q

The number of predictors in the combined linear regression model. Default is 1.

sig.level

The significance level. Default is .05.

r12

The proportion of variance explained by covariates if any.

power

Statistical power.

powerlim

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

nlim

The range for searching the root of sample size (n) numerically, default value is c(4, 10e10).

mlim

The range for searching the root of budget (m) numerically, default value is the costs sampling nlim units across treatment conditions or c(4 * ncost, 10e10 * ncost) with ncost = ((1 - p) * c1 + p * c1t).

eq.dislim

The range for solving the root of equivalence difference with the effect size (d) numerically, default value is c(0, 10).

verbose

Logical; print the process if TRUE, otherwise not; default value is TRUE.

Examples

Run this code
   library(anomo)
# 1. Conventional Power Analyses from Difference Perspectives
# Calculate the required sample size to achieve certain level of power
mysample <- power.eq.2group(d = .1, eq.dis = 0.1,  p =.5,
                            r12 = .5, q = 1, power = .8)
mysample$out

# Calculate power provided by a sample size allocation
mypower <- power.eq.2group(d = 1, eq.dis = .1, n = 1238, p =.5,
                           r12 = .5, q = 1)
mypower$out

# Calculate the minimum detectable distance a given sample size allocation
# can achieve
myeq.dis <- power.eq.2group(d = .1, n = 1238, p =.5,
                           r12 = .5, q = 1, power = .8)
myeq.dis$out

# 2. Power Analyses Using Optimal Sample Allocation
myod <- od.eq.2group(r12 = 0.5, c1 = 1, c1t = 10)
budget <- power.eq.2group(expr = myod, d = .1, eq.dis = 0.1,
                          q = 1, power = .8)
budget.balanced <- power.eq.2group(expr = myod, d = .1, eq.dis = 0.1,
                                   q = 1, power = .8,
                                   constraint = list(p = .50))
(budget.balanced$out$m-budget$out$m)/budget$out$m *100
# 27% more budget required from the balanced design with p = 0.50.

Run the code above in your browser using DataLab