KamTan/MediationSimulation

Tanner, KTORCID logo, Sharples, LDORCID logo, Daniel, RM and Keogh, RHORCID logo (2021). KamTan/MediationSimulation. [Dataset]. GitHub. https://github.com/KamTan/MediationSimulation
Copy

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

Mediation, Survival analysis, Longitudinal data, Simulation study

No files available. Please consult associated links.


Atom BibTeX OpenURL ContextObject in Span Multiline CSV OpenURL ContextObject Dublin Core (with Type as Type) MPEG-21 DIDL Data Cite XML EndNote HTML Citation JSON METS MODS RDF+N3 RDF+N-Triples RDF+XML Reference Manager Refer Simple Metadata ASCII Citation EP3 XML
Export

Downloads