Tanner, KT, Sharples, LD, Daniel, RM and Keogh, RH. 2021. KamTan/MediationSimulation. [Online]. GitHub. Available from: https://github.com/KamTan/MediationSimulation
Tanner, KT, Sharples, LD, Daniel, RM and Keogh, RH. KamTan/MediationSimulation [Internet]. GitHub; 2021. Available from: https://github.com/KamTan/MediationSimulation
Tanner, KT, Sharples, LD, Daniel, RM and Keogh, RH (2021). KamTan/MediationSimulation. [Data Collection]. GitHub. https://github.com/KamTan/MediationSimulation
Alternative Title
Mediation Simulation
Description
Sample R code for generating simulated data for a mediation analysis with a time-updated mediator and survival outcome. Code to accompany chapter 8 of the thesis by Kamaryn Tanner: "Dynamic Prediction, Mediation and Communication for Survival Outcomes, with Applications to Cystic Fibrosis". This code was written in R v4.0.2 running on a Windows 10 PC. The code is organised in three files: In medsimMain.R, we load the necessary libraries and source files and then simulate truth data. Data is generated for four cases: exposure A set to 1 and mediators set to levels they would have been at with an exposure of 1 (A1M1); exposure A set to 0 and mediators set to levels they would have been at with an exposure of 0 (A0M0); exposure A set to 1 but mediators set to levels they would have been at with an exposure of 0 (A1M0); exposure A set to 0 but mediators set to levels they would have been at with an exposure of 1 (A0M1). From this data, we calculate the total effect "truth" as A1M1 / A0M0, the direct effect truth as A1M0/A0M0 and the indirect effect truth as A1M1/A1M0. The next step is to calculate the simulated data for analysis by the selected mediation methods. Note that data is written out as one data frame. The mediation code will need to split it up into smaller simulated data files. Scenario1.R contains all of the parameters for controlling the simulation. By creating different versions of Scenario1.R, you can investigate different simulation scenarios without changing any code. medsimSupportFxns.R contains all of the helper functions called in medsimMain.R
Keywords
Data capture method | Experiment: Laboratory |
---|---|
Date (Date published in a 3rd party system) | 26 July 2021 |
Language(s) of written materials | English |
Data Creators | Tanner, KT, Sharples, LD, Daniel, RM and Keogh, RH |
---|---|
LSHTM Faculty/Department | Faculty of Epidemiology and Population Health > Dept of Medical Statistics |
Participating Institutions | London School of Hygiene & Tropical Medicine, London, United Kingdom |
Funders |
|
---|
Date Deposited | 12 Jul 2022 15:29 |
---|---|
Last Modified | 13 Jul 2022 14:07 |
Publisher | GitHub |