Chapter 1 Preface

This is a working document describing how I usually analyse and present randomized controlled trials (RCTs), both in Stata and R. It is mainly a repository for code I use and need to refer to instead of searching through old code, but it could be useful for other as well.

I am quite new to R, and have embraced the tidyverse style of coding. The graphics are a mostly created using ggplot2, but lately I have also started using the ggformula package. The “book” is written in RMarkdown with bookdown.

1.1 Structure of the book

The structure of the book is not very sophisticated. First there is an introduction where I introduce the concept of an RCT, and then I simualte a trial to be used in the continuation of the book. Chapter 3 and 4 are description on how to analyse continuous and dichotomous endpoints, both for single and repeated follow-up observations. The plan is to include also a chapter on time to event endpoints and sample size calculations.

1.2 Acknowledgements