Solution (source code)

= Solution

Use individual <stratified randomization> within each prison, with concealed centrally generated <permuted-block randomization> and varying block sizes. Prison can affect both baseline risk and intervention delivery, so balancing assignments within prison protects against imbalance in that important <covariate>. Varying block sizes and <allocation concealment> prevent staff from predicting the next allocation and selecting participants accordingly. Prespecify how incomplete final blocks are treated. To enforce the overall 4000:4000 allocation exactly, coordinate the stratum totals centrally, allocating odd final places through a concealed random rule; exact half allocation within every prison is impossible if some prison totals are odd.

\b[Individual randomization stratified by prison is preferable to randomizing only twenty whole prisons for this design.] A <cluster-randomized trial> would have few independent units and could lose substantial precision through <intraclass correlation>. Sharing or selling the intervention can cause <treatment contamination>, so record it and retain an <intention-to-treat analysis>; substantial spillover might justify a separately powered cluster design rather than being ignored.