This GitHub repository contains all the Rcode and necessary files (R functions and data) for running all the examples presented in the tutorial entitled Modeling recurrent events: a tutorial based on relapse and remitting episodes while using medication for opioid use disorder (OUD).
The repository includes:
-
DATA: Two .csv files with the simulated dataset mimicking data from the CTN-0051 clinical trial comparing extended-release naltrexone (XR-NTX) and buprenorphine-naloxone (BUP-NX) for treating OUD: i. "survival_models_format.csv" : dataset in the long format for implenting the Extended Cox, Parametric Survival, and longitudinal data regression models. ii. "msm_format.csv": dataset in the required format for fitting the multistate model.
-
R scripts R scripts necessary for the implementation of the models presented in the tutorial: i. Recurrent events Tutorial_Functions.r ii. Recurrent events Tutorial_Functions_Mstate iii. parfm_sourcepack: folder with modified functions necessary for fiting the survival models with frailty.
-
R Markdown An anootated R Markdown (.Rmd) file with step-by-step code and explanation of outputs.
-
Tutorial Content The .pdf file with the complete report produced by the .Rmd file, presenting a polished summary of the methods, results, and plots for easy reading and sharing.
The tutorial illustrates four general modeling frameworks for analyzing recurrent events:
- Extended Cox models (e.g., Anderson-Gill, PWP, frailty models)
- Parametric survival models
- Multistate models
- Longitudinal models for binary outcomes
Each framework is demonstrated through three applied use case scenarios derived from the CTN-0051 clinical trial comparing extended-release naltrexone (XR-NTX) and buprenorphine-naloxone (BUP-NX) for treating opioid use disorder (OUD):
- Estimating adjusted treatment effects
- Making individual-level outcome predictions
- Modeling recurrent transitions between remission and relapse states