Data Setup

The analyses conducted in this supplement will require loading the following packages:

## Load required packages
suppressPackageStartupMessages(library(lmtest))
suppressPackageStartupMessages(library(tidyr))
suppressPackageStartupMessages(library(sandwich))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(ggstance))
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(jtools))

Next, by setting the filePath variable to match the location of the supplied Pragmatic Trial Data.csv, we can open the dataset. By printing the first few rows, we can start getting ourselves familiar with the data.

## Load the dataset
simulated.data <- read.csv(paste0(filePath, "data/Pragmatic Trial Data.csv"))
head(simulated.data)
##   Z id t0         B          L1 L2 L2lag   cavgL1 A Alag1 Y
## 1 1  1  0 0.2780523  2.64317182  1     0 2.643172 1     1 0
## 2 1  1  1 0.2780523  6.14841344  1     1 4.395793 1     1 0
## 3 1  1  2 0.2780523  1.56694834  1     1 3.452845 1     1 0
## 4 1  1  3 0.2780523 -0.03690539  1     1 2.580407 1     1 0
## 5 1  1  4 0.2780523  0.32103495  1     1 2.128533 1     1 0
## 6 1  1  5 0.2780523 -2.22462997  0     1 1.403006 1     1 0

We see that this dataset consists of 11 variables, including:

  • Z the arm the patient was randomized to
  • id the patient id that groups observations from the same individual together
  • t0 the time point of the observation
  • B the measured baseline covariate
  • L1 and L2 the time-varying covariates, with L2lag and cavgL1 derived from these columns
  • A whether the patient received the treatment for the time interval prior to this observation
  • Y whether the individual experienced the outcome of interest