This repository provides R code for sample size calculations and simulations for hierarchical 2 × 2 factorial designs with treatment effect heterogeneity across clusters. Sample size is expressed as the number of clusters.
The code accompanies the paper “Addressing Cluster-Level Treatment Effect Heterogeneity in Sample Size Determination for Hierarchical 2 × 2 Factorial Designs” by Jiaqi Tong, Fan Li, and Guangyu Tong, published in Biometrical Journal (2026).
| File | Description |
|---|---|
SSCode.R |
Sample size functions and supporting calculations. nc() uses a series expansion approximation, and nc_na() uses a simple approximation. |
SimulationCode.R |
Simulation code for the random slope model. |
Tong J, Li F, Tong G. Addressing Cluster-Level Treatment Effect Heterogeneity in Sample Size Determination for Hierarchical 2 × 2 Factorial Designs. Biometrical Journal. 2026;68(3):e70146. doi:10.1002/bimj.70146.