Evaluation of Randomized Controlled Trials With R
| A Tutorial for Mental Health Researchers


Mathias Harrer, Pim Cuijpers, Lea K.J. Schuurmans, Tim Kaiser, Claudia Buntrock, Annemieke van Straten, David Ebert


This tutorial aims to serve as an accessible introduction to the evaluation of randomized controlled trials (RCTs) in mental health research. Based on example data of a real-world clinical trial, we will cover essential steps of RCT analyses and demonstrate their implementation using the statistical programming language R.

In the following pages, we give a hands-on introduction to the analysis of RCT data using R. A conceptual understanding of essential statistical methods is provided, and we then showcase how these methods can be applied in real-world examples.

An overview of the covered topics is presented on the following page. We show how to conduct a descriptive analysis of RCT data, how to deal with study dropout and other types of missing data, and how to assess if a treatment had an effect on continuous or binary endpoints in our study. We also discuss multiplicity issues in clinical trials, how to incorporate longitudinal data and provide tips on the reporting of RCT results.

The image to the right shows a stained-glass window at the Gonville and Caius College, Cambridge. It commemorates Ronald A. Fisher, whose works Statistical Methods for Research Workers (1925) and The Design of Experiments (1935) laid the groundwork for much of modern statistics. Fisher’s works had a monumental impact because they provided researchers with the statistical tools needed to draw inferences from their experiments. Many methods introduced by Fisher, such as analysis of variance, remain relevant in the analysis of RCTs to this day.

The window displays a 7-by-7 Latin square, an experimental design that Fisher used to test the yield of fertilizers while working at the Rothamsted Experimental Station (Lehmann 2011). While undoubtedly one of the most important statisticians of all time, Fisher was also a staunch supporter of eugenics, which is why the window was removed in 2020 (Busby 2020).

The tutorial is written specifically for mental health researchers. We assume some familiarity with common research questions in this field; as well as a basic knowledge of fundamental statistical concepts (i.e., means, standard deviations, correlation, \(P\) values). Mathematical notations will be used at times throughout the tutorial, but rest assured that we will take the time to explain the meaning of each symbol, and focus mainly on the key message conveyed by each formula. Mathematical notations often allow us to precisely describe the concepts we are talking about, and having seen those for- mulas also makes it easier to understand more advanced texts you may want to read further down the line.

Some knowledge of R will certainly be helpful to complete the tutorial but is not required. In the first section, we describe how to install R, as well as a computer program that makes working with R much more convenient. In the first part, we provide a gentle introduction to R itself and cover operations needed throughout the rest of the tutorial.


Mathias Harrer , Technical University of Munich

Pim Cuijpers , Vrije Universiteit Amsterdam

Lea K.J. Schuurmans , Technical University of Munich

Tim Kaiser , Free University of Berlin

Claudia Buntrock , Otto-von-Guericke University Magdeburg

Annemieke van Straten , Vrije Universiteit Amsterdam

David Daniel Ebert , Technical University of Munich

shared first authors.

Citing the Tutorial

This tutorial has been published as part of a primer article in Trials:

Harrer, M., Cuijpers, P., Schuurmans, L.K.J., Kaiser, T., Buntrock, C., van Straten, A. & Ebert, D. Evaluation of randomized controlled trials: a primer and tutorial for mental health researchers. Trials 24, 562 (2023). doi: 10.1186/s13063-023-07596-3.