APPLIED POWER ANALYSIS

These R tutorials show how our design parameters and effect size benchmarks can be used in power analyses.

 

The scenarios below replicate application examples from our published work using the R package PowerUpR (Bulus et al., 2021).

Note

Many additional worked examples, including other complex designs such as multisite randomized trials, can be found in our publications, their online supplemental materials, and our previous open-source tutorials:

Designing robust intervention studies on students’ socio-emotional learning

Planning complex CRTs and MSRTs with PowerUpR

Power Analysis for Educational IRTs and CRTs

Prerequisites

R Setup and Plot Style

# Load packages for power analysis, data handling, tables, and plots
library(PowerUpR)
library(tidyverse)
# Reuse one restrained plotting theme across all three tutorials
theme_set(
  theme_minimal(base_size = 13) +
    theme(
      panel.grid.major = element_line(color = "#e9ecef", linewidth = 0.35),
      panel.grid.minor = element_blank(),
      plot.title = element_blank(),
      plot.subtitle = element_blank(),
      axis.title = element_text(face = "bold"),
      legend.position = "bottom",
      legend.title = element_blank()
    )
)

# Create a highlighting palette
highlight <- function(labels, highlight_labels, highlight_color, base_color) {
  values <- setNames(rep(base_color, length(labels)), labels)
  if (!is.null(highlight_labels)) {
    values[highlight_labels] <- highlight_color
  }
  values
}

Assumptions

The code below uses the same basic assumptions across scenarios unless the original example specifies otherwise: target statistical power of 80%, α-level of 5% with two-tailed tests, and balanced allocation (p = 0.50).

# Store assumptions that are shared across application scenarios
defaults <- list(
  power = 0.80,
  alpha = 0.05,
  two.tailed = TRUE,
  p = 0.50
)

Helpers

# PowerUpR inspects match.call(); do.call() keeps calls reliable inside purrr
call_powerupr <- function(fun, args) {
  capture.output(result <- do.call(fun, args))
  result
}

# Extract one named numeric result from a PowerUpR output object
pull_powerupr <- function(result, field) {
  value <- result[[field]]
  if (is.null(value)) {
    stop(sprintf("PowerUpR result has no '%s' field.", field), call. = FALSE)
  }
  as.numeric(value[[1]])
}

# Render compact HTML tables with a common class
format_table <- function(data, caption = NULL, digits = 2) {
  knitr::kable(
    data,
    digits = digits,
    caption = caption,
    format = "html",
    table.attr = "class='tutorial-table'"
  )
}

# Format power values as percentages in plots
power_label <- scales::percent_format(accuracy = 1)

Tutorial 1: Learning App Lab Pilot (IRT)

How many students do we need?  

DesignIndividually randomized trial
Planning targetSample size (MRSS)
OutcomeGrade 7 mathematics
Selected covariatesPretests

Scenario excerpt from Stallasch et al. (2024):

A research team has programmed an app. It functions as a multidisciplinary digital learning environment which can be used throughout lower secondary school in Germany.

(…) the researchers aim to test the general efficacy of the underlying didactic approach. They plan a small-scale pilot IRT involving exclusively mathematical topics from grade 7. A standardized treatment effect of d = 0.15 is considered meaningful, representing around one half of the expected annual growth in mathematics for grades 6-7 in the German student population (Brunner, Stallasch et al., 2023, Table 1). The team’s objective, therefore, is to sample enough seventh graders to detect MDES = 0.15 at α = 0.05 (two-tailed) with 1 − β = 0.80, where PT = 0.50. The minimum required sample size (MRSS) to achieve this in an unconditional IRT design is N = 1397 students.

Striving for parsimony and being aware of the potential virtue of covariate adjustment, the researchers plan to statistically control for IP. Before power analysis, they consult our flow chart (Fig. 5): since the IRT addresses the total population in lower secondary school and a specific grade and domain analyzed in our study, the team is guided to Table E2 (panel a) that lists the suitable empirically estimated single-level design parameters.

Inserting R2T|IP = 0.53, the researchers find that the MRSS more than halves to N = 654 when adjusting for IP. They then think about optimizing the design by additionally including either a reading CP or SC, where R2T|IP+CP = 0.56 and R2T|IP+SC = 0.55. The MRSS further reduces to N = 630 when combining IP with SC and to N = 622 when combining IP with CP.

They decide to administer both a mathematics and reading test. The team wants to account for uncertainty in R2T|IP+CP. To this end, they determine the 95% CI by means of SE(R2T|IP+CP) = 0.01: the lower bound is calculated as 0.56 − 1.96 × 0.01 = 0.54 and the upper bound as 0.56 + 1.96 × 0.01 = 0.57, which leads to an MRSS range of 649 ≥ N ≥ 596. Consequently, when opting for a conservative approach and sampling N = 649 students, it is fairly certain that the IRT will be sensitive to uncover a (truly existing) treatment effect of d = 0.15 with IP and CP as covariates.

Note. MDES = minimum detectable effect size; R2T = total explained variance (single-level); IP = domain-identical pretest; CP = cross-domain pretest; SC = sociodemographics.

Researchers plan a small pilot study to test whether a new learning app improves students’ grade 7 mathematics achievement. In a lab-like setting, students are individually assigned to the app or a control group; the power analysis asks how many students are needed to detect an effect of d = 0.15 with 80% power. Mathematics and reading pretests are considered as covariates to reduce the required sample size.

Step 1: Selecting Appropriate Design Parameters

The selection path through the flowchart points to the grade- and domain-specific single-level design parameters listed in Table E2, from which R2 values for grade 7 mathematics are used.

# Create one design-parameter table for all Tutorial 1 calculations
s1_dp <- tibble::tribble(
  ~s1_analysis_category, ~s1_covariate_set,                                                            ~s1_g1, ~s1_r2, ~s1_se_r2,
  "Main",                "No covariates",                                                              0,      0.0000, NA_real_,
  "Main",                "Domain-identical pretest",                                                   1,      0.5327, NA_real_,
  "Main",                "Domain-identical pretest + cross-domain pretest",                            2,      0.5554, 0.0098,
  "Main",                "Domain-identical pretest + sociodemographics",                               5,      0.5499, 0.0099,
  "Sensitivity",         paste0("Domain-identical pretest + cross-domain pretest", ": Lower 95% CI"),  2,      0.5362, 0.0098,
  "Sensitivity",         paste0("Domain-identical pretest + cross-domain pretest", ": Upper 95% CI"),  2,      0.5746, 0.0098
)
# Display the selected parameters for the main analysis and sensitivity analysis
s1_dp %>%
  transmute(
    `Analysis category` = s1_analysis_category,
    `Covariate set` = s1_covariate_set,
    `Number of covariates` = s1_g1,
    `R²` = s1_r2,
    `SE(R²)` = s1_se_r2
  ) %>%
  format_table(caption = "Single-level design parameters selected from Table E2 (panel a)", digits = 4)
Single-level design parameters selected from Table E2 (panel a)
Analysis category Covariate set Number of covariates R² SE(R²)
Main No covariates 0 0.0000 NA
Main Domain-identical pretest 1 0.5327 NA
Main Domain-identical pretest + cross-domain pretest 2 0.5554 0.0098
Main Domain-identical pretest + sociodemographics 5 0.5499 0.0099
Sensitivity Domain-identical pretest + cross-domain pretest: Lower 95% CI 2 0.5362 0.0098
Sensitivity Domain-identical pretest + cross-domain pretest: Upper 95% CI 2 0.5746 0.0098

Step 2: Calculating the MRSS

We calculate the required number of students for each covariate set using the selected point estimates.

# Reuse the same MRSS calculation for the main and sensitivity analyses
s1_calculate_mrss <- function(s1_input) {
  s1_input %>%
    mutate(
      s1_required_students = pmap_dbl(
        list(s1_g1, s1_r2),
        function(g1, r2) {
          result <- call_powerupr(
            mrss.ira,
            list(
              es = 0.15,
              power = defaults$power,
              alpha = defaults$alpha,
              two.tailed = defaults$two.tailed,
              p = defaults$p,
              g1 = g1,
              r21 = r2
            )
          )
          pull_powerupr(result, "n")
        }
      )
    )
}

# Calculate the MRSS for the main covariate sets
s1_main_results <- s1_dp %>%
  filter(s1_analysis_category == "Main") %>%
  s1_calculate_mrss()
# Present the MRSS results in a compact table
s1_main_results %>%
  transmute(
    `Covariate set` = s1_covariate_set,
    `R²` = s1_r2,
    `Required students` = s1_required_students
  ) %>%
  format_table(caption = "Minimum required sample size by covariate set", digits = 4)
Minimum required sample size by covariate set
Covariate set R² Required students
No covariates 0.0000 1397
Domain-identical pretest 0.5327 654
Domain-identical pretest + cross-domain pretest 0.5554 622
Domain-identical pretest + sociodemographics 0.5499 630

Step 3: Sensitivity Analysis

We vary the R2 value for the domain-identical pretest and cross-domain pretest across its 95% confidence interval.

# Calculate the MRSS at each confidence limit
s1_sensitivity_results <- s1_dp %>%
  filter(s1_analysis_category == "Sensitivity") %>%
  s1_calculate_mrss()
# Present the sensitivity results in a compact table
s1_sensitivity_results %>%
  transmute(
    `Covariate set` = s1_covariate_set,
    `R²` = s1_r2,
    `Required students` = s1_required_students
  ) %>%
  format_table(caption = "Minimum required sample size under uncertainty", digits = 4)
Minimum required sample size under uncertainty
Covariate set R² Required students
Domain-identical pretest + cross-domain pretest: Lower 95% CI 0.5362 649
Domain-identical pretest + cross-domain pretest: Upper 95% CI 0.5746 596

Step 4: Visualizing the Results

# Plot the main MRSS results as vertical bars
s1_main_results %>%
  mutate(s1_covariate_set = factor(s1_covariate_set, levels = s1_covariate_set)) %>%
  ggplot(aes(x = s1_covariate_set, y = s1_required_students, fill = s1_covariate_set)) +
  geom_col(aes(color = s1_covariate_set), width = 0.75, show.legend = FALSE) +
  geom_text(aes(label = s1_required_students), vjust = -0.35, size = 3.6, show.legend = FALSE) +
  scale_color_manual(values = highlight(s1_main_results$s1_covariate_set, "Domain-identical pretest + cross-domain pretest", "#027381", "#bc8f8f")) +
  scale_fill_manual(values = highlight(s1_main_results$s1_covariate_set, "Domain-identical pretest + cross-domain pretest", "#96d2d3", "#f4ecec")) +
  scale_x_discrete(labels = function(x) stringr::str_wrap(x, width = 19)) +
  expand_limits(y = max(s1_main_results$s1_required_students) * 1.12) +
  labs(x = NULL, y = "Required students") +
  theme(panel.grid.major.x = element_blank())
# Compare the confidence limits with the main point estimate
s1_sensitivity_results %>%
  mutate(s1_covariate_set = factor(s1_covariate_set, levels = paste0("Domain-identical pretest + cross-domain pretest", c(": Lower 95% CI", ": Upper 95% CI")), labels = c("Lower 95% CI", "Upper 95% CI"))) %>%
  ggplot(aes(x = s1_covariate_set, y = s1_required_students)) +
  geom_col(width = 0.72, fill = "#f4ecec", color = "#bc8f8f") +
  geom_hline(
    yintercept = s1_main_results %>%
      filter(s1_covariate_set == "Domain-identical pretest + cross-domain pretest") %>%
      pull(s1_required_students),
    linetype = "dashed",
    color = "#027381"
  ) +
  geom_text(aes(label = s1_required_students), vjust = -0.35, size = 3.6, show.legend = FALSE) +
  scale_x_discrete(labels = function(x) stringr::str_wrap(x, width = 23)) +
  expand_limits(y = max(s1_sensitivity_results$s1_required_students) * 1.08) +
  labs(x = NULL, y = "Required students")
Minimum required sample size by covariate set

Minimum required sample size by covariate set

Minimum required sample size under uncertainty

Minimum required sample size under uncertainty

Tutorial 2: Learning App Field Trial (3L-CRT)

How much power can we achieve?  

DesignCluster-randomized trial
Planning targetPower (1−β)
Sample Budget400 schools
Selected covariatesFluid intelligence

Scenario excerpt from Stallasch et al. (2024):

A research team has programmed an app. It functions as a multidisciplinary digital learning environment which can be used throughout lower secondary school in Germany.

(…) the researchers aim to scrutinize the effectiveness of the full app in students’ usual school routine. They plan a large-scale 3L-CRT involving the complete spectrum of domains for grades 5–10. d = 0.11 is considered reasonable, approximating half of the average academic year-to-year growth observed across lower secondary school in Germany (Brunner, Stallasch, et al., 2023, Table 1). Due to logistical reasons, the total sample is restricted to a maximum of K = 400 schools, with nL2 = 20 and JL3 = 3. The team’s primary concern, thus, is to achieve sufficient power (i.e., 1 − β ≥ 0.80) to detect MDES = 0.11 at α = 0.05 (two-tailed), where PL3 = 0.50.

Since the 3L-CRT addresses the total population in lower secondary school but neither a specific grade nor domain, our flow chart (Fig. 5) directs them to Table F2 (panel c) that lists the suitable meta-analytically integrated three-level design parameters. Entering pooled ρ values at L2/L3 of 0.05/0.35 into power analysis, the researchers learn that an unconditional 3L-CRT clearly undercuts the desired power rate (1 − β = 0.43).

They wonder which covariates to use: given the limited testing time, assessing multiple IPs is not a viable option. Instead, controlling for either Gf or SC seems most feasible, with pooled R2 values at L1/L2/L3 of 0.07/0.16/0.86 for Gf and 0.04/0.12/0.77 for SC. Controlling for both Gf (1 − β = 0.98) and SC (1 − β = 0.92) leads to adequate power.

However, when incorporating total design parameter heterogeneities (i.e., sampling error plus true variation) and adopting a (very) conservative approach by using the upper bounds of 95% PIs of ρL2 = 0.07 and ρL3 = 0.50 and the lower bounds of the 95% PIs of R2L1|Gf = 0.00, R2L2|Gf = 0.00, R2L3|Gf = 0.76, R2L1|SC = 0.00, R2L2|SC = 0.00, and R2L3|SC = 0.56, only Gf (1 − β = 0.81) likely guarantees enough power, as opposed to SC (1 − β = 0.59). The team decides to collect students’ Gf scores.

Finally, the researchers wish to evaluate the long-term effects of the app. Thus, a possible follow-up 3L-CRT of the same sample should still demonstrate adequate power. The suitable design parameters are pooled ρL2 = 0.04, pooled ρL3 = 0.38, and predicted values of R2L1|Gf-2 = 0.01, R2L2|Gf-2 = 0.22, R2L3|Gf-2 = 0.81, as well as R2L1|Gf-4 = 0.01, R2L2|Gf-4 = 0.12, R2L3|Gf-4 = 0.79. Assuming no attrition over time, the team calculates 1 − β = 0.95/0.94 for a 2-/4-year-lagged Gf. Consequently, even when reevaluating the app’s impact 4 years later, the 3L-CRT with Gf as a covariate will likely be adequately powered.

Note. MDES = minimum detectable effect size; ρ = intraclass correlation (ICC); R2 = explained variance; IPs = domain-identical pretests; Gf = fluid intelligence; SC = sociodemographics; PI = meta-analytic prediction interval. L1, L2, and L3 denote the student, classroom, and school levels, respectively.

In a large-scale field experiment, researchers want to test a multidisciplinary learning app across subjects and grades 5–10 in German lower secondary schools. In this school-randomized study, they can recruit at most 400 schools, with three classrooms of 20 students each. The power analysis asks whether this fixed sample can detect an effect of d = 0.11 with at least 80% power, including when fluid intelligence is used as a covariate and outcomes are measured years later.

Step 1: Selecting Appropriate Design Parameters

The selection path through the flowchart points to the three-level meta-analytic design parameters listed in Table F2, from which pooled or predicted ρ and R2 values are used, along with their prediction intervals.

# Create one design-parameter table for all Tutorial 2 calculations
s2_dp <- tibble::tribble(
  ~s2_analysis_category, ~s2_covariate_set,                ~s2_g3, ~s2_rho2, ~s2_rho3, ~s2_r21, ~s2_r22, ~s2_r23,
  "Main",                "No covariates",                  0,      0.0481,   0.3507,   0.0000,  0.0000,  0.0000,
  "Main",                "Fluid intelligence",             1,      0.0481,   0.3507,   0.0748,  0.1637,  0.8575,
  "Main",                "Sociodemographics",              4,      0.0481,   0.3507,   0.0409,  0.1233,  0.7651,
  "Follow-up",           "Fluid intelligence, 2-year lag", 1,      0.0362,   0.3774,   0.0138,  0.2246,  0.8083,
  "Follow-up",           "Fluid intelligence, 4-year lag", 1,      0.0362,   0.3774,   0.0144,  0.1169,  0.7914,
  "Sensitivity",         "Fluid intelligence",             1,      0.0659,   0.4994,   0.0000,  0.0000,  0.7594,
  "Sensitivity",         "Sociodemographics",              4,      0.0659,   0.4994,   0.0000,  0.0000,  0.5588
)
# Display all parameter rows used in the Tutorial 2 calculations
s2_dp %>%
  transmute(
    `Analysis category` = s2_analysis_category,
    `Covariate set` = s2_covariate_set,
    `Number of covariates at L3` = s2_g3,
    `ρ at L2` = s2_rho2,
    `ρ at L3` = s2_rho3,
    `R² at L1` = s2_r21,
    `R² at L2` = s2_r22,
    `R² at L3` = s2_r23
  ) %>%
  format_table(caption = "Three-level design parameters selected from Table F2 (panel c)", digits = 4)
Three-level design parameters selected from Table F2 (panel c)
Analysis category Covariate set Number of covariates at L3 ρ at L2 ρ at L3 R² at L1 R² at L2 R² at L3
Main No covariates 0 0.0481 0.3507 0.0000 0.0000 0.0000
Main Fluid intelligence 1 0.0481 0.3507 0.0748 0.1637 0.8575
Main Sociodemographics 4 0.0481 0.3507 0.0409 0.1233 0.7651
Follow-up Fluid intelligence, 2-year lag 1 0.0362 0.3774 0.0138 0.2246 0.8083
Follow-up Fluid intelligence, 4-year lag 1 0.0362 0.3774 0.0144 0.1169 0.7914
Sensitivity Fluid intelligence 1 0.0659 0.4994 0.0000 0.0000 0.7594
Sensitivity Sociodemographics 4 0.0659 0.4994 0.0000 0.0000 0.5588

Step 2: Calculating the Power

We calculate power for the initial trial and the two follow-up assessments using their respective parameter sets.

# Reuse the same power calculation for all analysis categories
s2_calculate_power <- function(s2_input) {
  s2_input %>%
    mutate(
      s2_power = pmap_dbl(
        list(s2_g3, s2_rho2, s2_rho3, s2_r21, s2_r22, s2_r23),
        function(g3, rho2, rho3, r21, r22, r23) {
          result <- call_powerupr(
            power.cra3,
            list(
              es = 0.11,
              alpha = defaults$alpha,
              two.tailed = defaults$two.tailed,
              p = defaults$p,
              n = 20,
              J = 3,
              K = 400,
              g3 = g3,
              rho2 = rho2,
              rho3 = rho3,
              r21 = r21,
              r22 = r22,
              r23 = r23
            )
          )
          pull_powerupr(result, "power")
        }
      )
    )
}

# Compute power for the initial trial and its follow-ups
s2_main_results <- s2_dp %>%
  filter(s2_analysis_category == "Main") %>%
  s2_calculate_power()
s2_follow_up_results <- s2_dp %>%
  filter(s2_analysis_category == "Follow-up") %>%
  s2_calculate_power()
# Present the main and follow-up power values in a compact table
bind_rows(s2_main_results, s2_follow_up_results) %>%
  transmute(
    `Analysis category` = s2_analysis_category,
    `Covariate set` = s2_covariate_set,
    `ρ at L2` = s2_rho2,
    `ρ at L3` = s2_rho3,
    `R² at L1` = s2_r21,
    `R² at L2` = s2_r22,
    `R² at L3` = s2_r23,
    `Power` = s2_power
  ) %>%
  format_table(caption = "Power for the initial and follow-up trial", digits = 4)
Power for the initial and follow-up trial
Analysis category Covariate set ρ at L2 ρ at L3 R² at L1 R² at L2 R² at L3 Power
Main No covariates 0.0481 0.3507 0.0000 0.0000 0.0000 0.4317
Main Fluid intelligence 0.0481 0.3507 0.0748 0.1637 0.8575 0.9826
Main Sociodemographics 0.0481 0.3507 0.0409 0.1233 0.7651 0.9207
Follow-up Fluid intelligence, 2-year lag 0.0362 0.3774 0.0138 0.2246 0.8083 0.9526
Follow-up Fluid intelligence, 4-year lag 0.0362 0.3774 0.0144 0.1169 0.7914 0.9367

Step 3: Sensitivity Analysis

We check the covariate choice using conservative prediction-interval bounds for the ρ and R2 values.

# Compute power under conservative prediction-interval bounds
s2_sensitivity_results <- s2_dp %>%
  filter(s2_analysis_category == "Sensitivity") %>%
  s2_calculate_power()
# Present the sensitivity results in a compact table
s2_sensitivity_results %>%
  transmute(
    `Covariate set` = s2_covariate_set,
    `ρ at L2` = s2_rho2,
    `ρ at L3` = s2_rho3,
    `R² at L1` = s2_r21,
    `R² at L2` = s2_r22,
    `R² at L3` = s2_r23,
    `Power` = s2_power
  ) %>%
  format_table(caption = "Power under conservative prediction-interval assumptions", digits = 4)
Power under conservative prediction-interval assumptions
Covariate set ρ at L2 ρ at L3 R² at L1 R² at L2 R² at L3 Power
Fluid intelligence 0.0659 0.4994 0 0 0.7594 0.8104
Sociodemographics 0.0659 0.4994 0 0 0.5588 0.5936

Step 4: Visualizing the Results

# Compare power estimates
bind_rows(s2_main_results, s2_follow_up_results, s2_sensitivity_results) %>%
  mutate(
    s2_analysis_category = factor(s2_analysis_category, levels = c("Main", "Follow-up", "Sensitivity")),
    s2_covariate_set = factor(s2_covariate_set, levels = rev(unique(s2_covariate_set)))
  ) %>%
  ggplot(aes(y = s2_covariate_set, color = s2_analysis_category)) +
  geom_vline(xintercept = defaults$power, linetype = "dashed", color = "#212529") +
  geom_segment(aes(x = 0, xend = s2_power, yend = s2_covariate_set), linewidth = 0.8) +
  geom_point(aes(x = s2_power), size = 3) +
  geom_text(aes(x = s2_power, label = power_label(s2_power), hjust = if_else(s2_power > 0.90, 1, 0)), nudge_y = 0.22, show.legend = FALSE, size = 3.4) +
  facet_grid(s2_analysis_category ~ ., scales = "free_y", space = "free_y") +
  scale_x_continuous(labels = power_label, limits = c(0, 1), breaks = seq(0, 1, 0.2)) +
  scale_color_manual(values = c(
    "Main" = "#027381",
    "Follow-up" = "#212529",
    "Sensitivity" = "#bc8f8f"
  )) +
  labs(x = "Power", y = NULL) +
  theme(panel.grid.major.y = element_blank(), legend.position = "none")
Power for the initial trial, follow-ups, and conservative assumptions

Power for the initial trial, follow-ups, and conservative assumptions

Tutorial 3: History Intervention in Comprehensive Schools (3L-CRT)

What is the attainable MDES?  

DesignCluster-randomized trial
Planning targetEffect size (MDES)
Sample budget40 schools
Selected covariatesPretests + sociodemographics

Adapted scenario excerpt from Stallasch et al. (2021):

Suppose that research Team 2 plans a three-level CRT to study the impact of an intervention that is intended to affect students’ history achievement in comprehensive schools (grades 5–12). Due to budgetary constraints (see Spybrook, Shi, et al., 2016), a fixed maximum number of K = 40 schools (with J = 2 classrooms, and n = 20 students each) are at the researchers’ disposal. Given these limits, the primary concern of Team 2 is to ensure that the attainable MDES lies within the range of typical intervention effects on student achievement (i.e., 0.20 ≤ d ≤ 0.30; Hill et al., 2008).

Team 2 consults Figure 4 to find the suitable table of design parameters. Since the intervention is targeted at a single, specific school type within the non-academic track, Team 2 uses the design parameters that are adjusted for mean-level differences between school types. Moreover, since design parameters for history are not available, Team 2 consults Table B4 outlining the normative distributions across the various achievement domains to determine small (i.e., 25th percentile), medium (i.e., 50th percentile), and large values (i.e., 75th percentile) of the design parameters.

Entering the respective values for the intraclass correlations (25th percentile: ρL2 = 0.04, ρL3 = 0.08; 50th percentile: ρL2 = 0.06, ρL3 = 0.10; 75th percentile: ρL2 = 0.09, ρL3 = 0.12; see Table B4), Team 2 learns that the attainable MDES is 0.32/0.35/0.39 for small/medium/large values of ρL2 and ρL3.

Including both pretests and sociodemographics as covariates (25th percentile: R2L1 = 0.17, R2L2 = 0.70, R2L3 = 0.84; 50th percentile: R2L1 = 0.22, R2L2 = 0.77, R2L3 = 0.90; 75th percentile: R2L1 = 0.31, R2L2 = 0.86, R2L3 = 0.97; see Table B4) and using the 75th percentiles of the values for ρL2 and ρL3 (as more conservative upper bounds), the respective values for the MDES reduce to 0.20/0.18/0.14 for small/medium/large values of R2 at the various levels.

Consequently, Team 2 can be quite confident that their CRT design offers sufficient sensitivity to detect a true intervention effect within the desired range when including both pretests and sociodemographics.

Note. MDES = minimum detectable effect size; ρ = intraclass correlation (ICC); R2 = explained variance. L1, L2, and L3 denote the student, classroom, and school levels, respectively.

A research team plans an intervention study to improve history achievement in German comprehensive schools spanning grades 5–12. With a fixed budget of 40 schools, two classrooms per school, and 20 students per classroom, the power analysis asks what minimum effect this school-randomized study can detect. The team assesses whether adding pretests and sociodemographic covariates brings that effect into the expected range of d = 0.20–0.30.

Step 1: Selecting Appropriate Design Parameters

The selection path through the flowchart points to the normative distributions for the three-level design parameters listed in Table B4. We use the 25th percentile, 50th percentile, and 75th percentile values of ρ and R2.

# Create one design-parameter table for all Tutorial 3 calculations
s3_dp <- tibble::tribble(
  ~s3_analysis_category, ~s3_percentile, ~s3_rho2, ~s3_rho3, ~s3_r21, ~s3_r22, ~s3_r23,
  "Main",                "50th",         0.0580,   0.0957,   0.2210,  0.7705,  0.9030,
  "Sensitivity",         "25th",         0.0438,   0.0758,   0.1694,  0.6988,  0.8510,
  "Sensitivity",         "75th",         0.0900,   0.1182,   0.3064,  0.8576,  0.9654
)
# Display the selected normative distribution values
s3_dp %>%
  transmute(
    `Analysis category` = s3_analysis_category,
    `Percentile` = s3_percentile,
    `ρ at L2` = s3_rho2,
    `ρ at L3` = s3_rho3,
    `R² at L1` = s3_r21,
    `R² at L2` = s3_r22,
    `R² at L3` = s3_r23
  ) %>%
  format_table(caption = "Selected 25th, 50th, and 75th percentile design parameters from Table B4", digits = 4)
Selected 25th, 50th, and 75th percentile design parameters from Table B4
Analysis category Percentile ρ at L2 ρ at L3 R² at L1 R² at L2 R² at L3
Main 50th 0.0580 0.0957 0.2210 0.7705 0.9030
Sensitivity 25th 0.0438 0.0758 0.1694 0.6988 0.8510
Sensitivity 75th 0.0900 0.1182 0.3064 0.8576 0.9654

Step 2: Calculating the MDES

For the main MDES analysis, we use the 50th percentiles of the ρ and R2 values.

# Reuse the same MDES calculation for the main and sensitivity analyses
s3_calculate_mdes <- function(s3_input) {
  s3_input %>%
    mutate(
      s3_mdes = pmap_dbl(
        list(s3_g3, s3_rho2, s3_rho3, s3_r21, s3_r22, s3_r23),
        function(g3, rho2, rho3, r21, r22, r23) {
          result <- call_powerupr(
            mdes.cra3,
            list(
              power = defaults$power,
              alpha = defaults$alpha,
              two.tailed = defaults$two.tailed,
              p = defaults$p,
              n = 20,
              J = 2,
              K = 40,
              g3 = g3,
              rho2 = rho2,
              rho3 = rho3,
              r21 = r21,
              r22 = r22,
              r23 = r23
            )
          )
          pull_powerupr(result, "mdes")
        }
      )
    )
}

# Select 50th percentile parameters for the main analysis
s3_main_dp <- s3_dp %>%
  filter(s3_analysis_category == "Main")

# Compute the MDES with 50th percentile ICCs and R-squared values
s3_main_input <- bind_rows(
  s3_main_dp %>%
    mutate(
      s3_covariate_set = "No covariates",
      s3_g3 = 0,
      s3_icc_percentile = s3_percentile,
      s3_r2_percentile = "—",
      across(c(s3_r21, s3_r22, s3_r23), ~0)
    ),
  s3_main_dp %>%
    mutate(
      s3_covariate_set = "Pretests + sociodemographics",
      s3_g3 = 5,
      s3_icc_percentile = s3_percentile,
      s3_r2_percentile = s3_percentile
    )
)
s3_main_results <- s3_calculate_mdes(s3_main_input)
# Present the main MDES results
s3_main_results %>%
  transmute(
    `Covariate set` = s3_covariate_set,
    `ρ percentile` = s3_icc_percentile,
    `R² percentile` = s3_r2_percentile,
    `ρ at L2` = s3_rho2,
    `ρ at L3` = s3_rho3,
    `R² at L1` = s3_r21,
    `R² at L2` = s3_r22,
    `R² at L3` = s3_r23,
    `MDES` = s3_mdes
  ) %>%
  format_table(caption = "MDES under the 50th percentile assumptions", digits = 4)
MDES under the 50th percentile assumptions
Covariate set ρ percentile R² percentile ρ at L2 ρ at L3 R² at L1 R² at L2 R² at L3 MDES
No covariates 50th — 0.058 0.0957 0.000 0.0000 0.000 0.3473
Pretests + sociodemographics 50th 50th 0.058 0.0957 0.221 0.7705 0.903 0.1644

Step 3: Sensitivity Analysis

For the unadjusted design, we calculate the 25th percentile and 75th percentile ρ cases in addition to the 50th percentile main result. For the covariate-adjusted design, we calculate the 25th percentile, 50th percentile, and 75th percentile R2 cases while fixing both ρ values at their conservative 75th percentiles.

# Select 25th percentile and 75th percentile ICC values for the unadjusted sensitivity analysis
s3_unadjusted_sensitivity_dp <- s3_dp %>%
  filter(s3_analysis_category == "Sensitivity")

# Select the conservative ICCs for the covariate-adjusted sensitivity analysis
s3_conservative_iccs <- s3_dp %>%
  filter(s3_percentile == "75th")

# Vary ICCs without covariates and R-squared values with ICCs fixed at the 75th percentile
s3_sensitivity_input <- bind_rows(
  s3_unadjusted_sensitivity_dp %>%
    mutate(
      s3_covariate_set = "No covariates",
      s3_g3 = 0,
      s3_icc_percentile = s3_percentile,
      s3_r2_percentile = "—",
      across(c(s3_r21, s3_r22, s3_r23), ~0)
    ),
  s3_dp %>%
    arrange(match(s3_percentile, c("25th", "50th", "75th"))) %>%
    mutate(
      s3_analysis_category = "Sensitivity",
      s3_covariate_set = "Pretests + sociodemographics",
      s3_g3 = 5,
      s3_icc_percentile = "75th",
      s3_r2_percentile = s3_percentile,
      s3_rho2 = s3_conservative_iccs$s3_rho2,
      s3_rho3 = s3_conservative_iccs$s3_rho3
    )
)
s3_sensitivity_results <- s3_calculate_mdes(s3_sensitivity_input)
# Present the percentile-based sensitivity results
s3_sensitivity_results %>%
  transmute(
    `Covariate set` = s3_covariate_set,
    `ρ percentile` = s3_icc_percentile,
    `R² percentile` = s3_r2_percentile,
    `ρ at L2` = s3_rho2,
    `ρ at L3` = s3_rho3,
    `R² at L1` = s3_r21,
    `R² at L2` = s3_r22,
    `R² at L3` = s3_r23,
    `MDES` = s3_mdes
  ) %>%
  format_table(caption = "MDES under sensitivity assumptions", digits = 4)
MDES under sensitivity assumptions
Covariate set ρ percentile R² percentile ρ at L2 ρ at L3 R² at L1 R² at L2 R² at L3 MDES
No covariates 25th — 0.0438 0.0758 0.0000 0.0000 0.0000 0.3146
No covariates 75th — 0.0900 0.1182 0.0000 0.0000 0.0000 0.3890
Pretests + sociodemographics 75th 25th 0.0900 0.1182 0.1694 0.6988 0.8510 0.1992
Pretests + sociodemographics 75th 50th 0.0900 0.1182 0.2210 0.7705 0.9030 0.1761
Pretests + sociodemographics 75th 75th 0.0900 0.1182 0.3064 0.8576 0.9654 0.1421

Step 4: Visualizing the Results

On the x-axis, percentiles refer to ρ values for the unadjusted design and to R2 values for the covariate-adjusted design. In the adjusted design, the 75th-percentile ρ values are used throughout.

# Combine the unadjusted 50th percentile main result with the sensitivity results
s3_mdes_plot_data <- bind_rows(
  s3_main_results %>% filter(s3_covariate_set == "No covariates"),
  s3_sensitivity_results
) %>%
  mutate(
    s3_percentile = factor(s3_percentile, levels = c("25th", "50th", "75th"), labels = c("25th percentile", "50th percentile", "75th percentile")),
    s3_x_base = as.numeric(s3_percentile),
    s3_x_offset = if_else(s3_covariate_set == "No covariates", -0.12, 0.12),
    s3_x = s3_x_base + s3_x_offset
  )

# Plot the MDES values as lollipop plots
s3_mdes_plot_data %>%
  ggplot(aes(color = s3_covariate_set)) +
  annotate("rect", xmin = -Inf, xmax = Inf, ymin = 0.20, ymax = 0.30, alpha = 0.28, fill = "#96d2d3") +
  geom_segment(aes(x = s3_x, xend = s3_x, y = 0, yend = s3_mdes), linewidth = 0.8) +
  geom_point(aes(x = s3_x, y = s3_mdes), size = 3.2) +
  scale_x_continuous(
    breaks = seq_along(levels(s3_mdes_plot_data$s3_percentile)),
    labels = levels(s3_mdes_plot_data$s3_percentile)
  ) +
  scale_color_manual(values = c(
    "No covariates" = "#bc8f8f",
    "Pretests + sociodemographics" = "#027381"
  )) +
  labs(x = NULL, y = "MDES")
MDES by ρ and R² percentiles (ρ fixed at the 75th percentile for covariate-adjusted designs) in relation to the defined target effect range of d = 0.20–0.30

MDES by ρ and R² percentiles (ρ fixed at the 75th percentile for covariate-adjusted designs) in relation to the defined target effect range of d = 0.20–0.30

References

Bulus, M., Dong, N., Kelcey, B., & Spybrook, J. (2021). PowerUpR: Power analysis tools for multilevel randomized experiments. R package version 1.1.0. https://CRAN.R-project.org/package=PowerUpR
Stallasch, S. E., Lüdtke, O., Artelt, C., & Brunner, M. (2021). Multilevel design parameters to plan cluster-randomized intervention studies on student achievement in elementary and secondary school. Journal of Research on Educational Effectiveness, 14(1), 172–206. https://doi.org/10.1080/19345747.2020.1823539
Stallasch, S. E., Lüdtke, O., Artelt, C., Hedges, L. V., & Brunner, M. (2024). Single- and multilevel perspectives on covariate selection in randomized intervention studies on student achievement. Educational Psychology Review, 36(4), 112. https://doi.org/10.1007/s10648-024-09898-7