Preface

R packages

In this practical, a number of R packages are used. If any of them are not installed you may be able to follow the practical but will not be able to run all of the code. The packages used (with versions that were used to generate the solutions) are:

  • R version 3.6.0 (2019-04-26)
  • mice (version: 3.4.0)
  • nlme (version: 3.1.139)
  • JointAI (version: 0.5.1)
  • splines (version: 3.6.0)
  • ggplot2 (version: 3.1.1)

Help files

You can find help files for any function by adding a ? before the name of the function.

Alternatively, you can look up the help pages online at https://www.rdocumentation.org/ or find the whole manual for a package at https://cran.r-project.org/web/packages/available_packages_by_name.html

Dataset

In this practical we will work with data from a trial on primary biliary cirrhosis (PBC) of the liver.

To get the pbclong data, load the file pbclong.RData. You can download it here. To load this dataset, you can use the command file.choose() which opens the explorer and allows you to navigate to the location of the downloaded file on your computer. If you know the path to the file, you can also use load("<path>/<pbclong.RData").

The variables contained in the dataset pbclong are:

id patient identifier
day continuously measured day of follow-up time (the time variable)
sex patients’ sex (f: female, m: male)
trt treatment group (0: D-penicillmain, 1: placebo)
age patients’ age at intake
ascites presence of ascites at baseline (0:no, 1:yes)
hepato presence of hepatomegaly or enlarged liver
bili serum bilirubin level at baseline
copper urine copper (ug/day)
albumin serum albumin level at follow-up (time-varying)

The variables have the following distributions and proportions of missing values: