Learn R Programming

DMAR (version 1.0.0)

ss_power_mixed_effects: Sample Size or Power for a Treatment Effect in a Two-Level Mixed-Effects Model

Description

Determine the necessary number of level-2 units per arm to achieve a desired level of statistical power for a treatment-versus-control comparison in a two-level mixed-effects model with a random intercept (e.g., individuals nested within clusters in a cluster-randomized trial, or repeated measurements nested within subjects in a person-randomized longitudinal study). Alternatively, given a number of level-2 units per arm, return the realized statistical power.

Usage

ss_power_mixed_effects(
  d,
  n,
  rho,
  J = NULL,
  desired_power = 0.85,
  alpha_level = 0.05,
  directional = FALSE
)

Value

A data.frame with rows for necessary_J_per_arm (or specified_J_per_arm),

total_N, noncentrality, and actual_power. The result carries the dmar_ss_power class, so tidy and

glance summarize it in broom convention (the reported size is the number of clusters per arm).

Arguments

d

Standardized treatment effect, defined as the population mean difference divided by the population standard deviation of the level-1 outcome

n

Number of level-1 units per level-2 unit (e.g., individuals per cluster, or measurements per subject); assumed equal across level-2 units

rho

Intra-class correlation (the proportion of total outcome variance attributable to differences between level-2 units); must be in [0, 1)

J

Number of level-2 units per arm (i.e., J treatment clusters and J control clusters); if specified, returns the realized power

desired_power

Desired statistical power (default 0.85)

alpha_level

Type I error rate (default 0.05)

directional

Logical: TRUE for a one-sided test (in the same sign as d), FALSE (default) for a two-sided test

Author

Ken Kelley [email protected]

Details

This function computes power for the fixed treatment effect at the higher level of a two-level mixed-effects model with random intercept, $$y_{ij} = \beta_0 + \beta_1 T_j + u_j + \epsilon_{ij},$$ where \(u_j \sim N(0, \sigma_u^2)\) is the level-2 random intercept and \(\epsilon_{ij} \sim N(0, \sigma_e^2)\) is the level-1 residual. The treatment indicator \(T_j\) varies between level-2 units (i.e., entire clusters or entire subjects are assigned to treatment or control). The intra-class correlation is \(\rho = \sigma_u^2 / (\sigma_u^2 + \sigma_e^2)\) and the total outcome variance is \(\sigma_y^2 = \sigma_u^2 + \sigma_e^2\).

The standard error of the estimated treatment effect is \(SE(\hat\beta_1) = \sigma_y \sqrt{2 (1 + (n - 1)\rho) / (J n)}\), giving a noncentrality parameter of $$\lambda = d \sqrt{J n / (2 (1 + (n - 1)\rho))}$$ under a two-sample t-test with \(2J - 2\) degrees of freedom.

The factor \(1 + (n - 1)\rho\) is the design effect: as the within-cluster correlation grows, the effective information per level-2 unit shrinks, so more level-2 units are needed for a given level of power.

References

Maxwell, S. E., Delaney, H. D., & Kelley, K. (2027). Designing experiments and analyzing data: A model comparison perspective (4th ed.). Routledge.

Raudenbush, S. W. (1997). Statistical analysis and optimal design for cluster randomized trials. Psychological Methods, 2, 173--185. tools:::Rd_expr_doi("10.1037/1082-989X.2.2.173")

See Also

ss_power_split_plot_anova, ss_power_smd, ss_power_pcm

design_consequences for what a chosen design delivers: power, the Type S (sign) and Type M (exaggeration) errors of the significance filter, and the expected confidence interval width.

Other sample size for power: power_fisher_exact(), ss_aipe_mixed_effects(), ss_power_R2(), ss_power_R2_sensitivity(), ss_power_c(), ss_power_c_ancova(), ss_power_composite_ancova(), ss_power_composite_ancova_2group(), ss_power_composite_anova(), ss_power_composite_factorial_ancova(), ss_power_composite_factorial_ancova_het(), ss_power_composite_factorial_anova(), ss_power_composite_sem(), ss_power_contrast(), ss_power_equivalence_c(), ss_power_factorial_ancova(), ss_power_factorial_anova(), ss_power_indirect_effect(), ss_power_one_way_anova(), ss_power_pcm(), ss_power_r(), ss_power_rc(), ss_power_reg_coef(), ss_power_reg_coef_sensitivity(), ss_power_rm_anova(), ss_power_sc(), ss_power_sem(), ss_power_smd(), ss_power_split_plot_anova()

Other mixed models: R2_mixed_effects(), R2_mixed_effects_decomposition(), icc_lmer(), manova_split_plot(), mixed_anova(), ss_aipe_mixed_effects(), ss_aipe_mixed_effects_sensitivity(), ss_power_split_plot_anova()

Examples

Run this code
# 30 individuals per cluster, ICC = 0.05, standardized effect d = 0.30, power = .80
ss_power_mixed_effects(d = 0.30, n = 30, rho = 0.05, desired_power = 0.80)

# Same effect but with much higher ICC (e.g., schools or therapists)
ss_power_mixed_effects(d = 0.30, n = 30, rho = 0.20, desired_power = 0.80)

# Realized power with 25 level-2 units per arm
ss_power_mixed_effects(d = 0.30, n = 30, rho = 0.05, J = 25)

# directional test
ss_power_mixed_effects(d = 0.30, n = 30, rho = 0.05, desired_power = 0.80,
                         directional = TRUE)

Run the code above in your browser using DataLab