TimescaleSuicidalThinking
Code repository for the paper "Locating the Timescale of Suicidal Thinking" Coppersmith, Ryan et al.
Install / Use
/learn @ryanoisin/TimescaleSuicidalThinkingREADME
README
This is the reproducibility archive for the paper "Mapping the Timescale of Suicidal Thinking" (preprint: https://psyarxiv.com/eus2q/). It allows one to reproduce all analyses and results in the paper.
Folders
-
/Datacontains the raw EMA data and all processed data files created by data processing files. Note that the raw and processed data is not contained in the publicly shared repository at this moment in time. -
/figurescontains the figures created by the below scripts. -
/filescontains model fit objects generated by fittingctsemmodels. Not shared publicly at this time -
/analysis_ctcontains scripts relating to running CT-VAR models inctsem, and CT-MSM models inmsm; analysing and visualizing the results. Caution: running ctsem models using MCMC estimation can be time-intensive -
/analysis_ctcontains scripts relating to fitting CT models on the "short" and "long/EMA" datasets in analysing and visualizing the results. Caution: running ctsem models using MCMC estimation can be time-intensive
Scripts
-
aux_Functions.Rcontains auxiliary functions for plotting, computing descriptives and processing the data -
analysis_descriptives.Ra script to compute the analyses presented as "descriptive statistics" in the manuscript, including: numbers of observations, within-person mean and variability, number of high risk responses. Does not include any analyses related to the modal response. Creates Figure 2. -
analysis_variability.Rscript which computes the modal response, and the "p_mode", the number of observations which are equal to the modal response. Also contains code for all the analyses described under the section "Variability as a function of the time-interval", including code to reproduce Figure 3. -
data_processing.Rcreates the processed data files using in the continuous-time model analysis, stored in/Data -
analysis_msm.Rcode to run and visualize the results of the markov-switching models
analysis_ct
model_fitting_ctsem.Rfits the CT-VAR(1) model to the full cleaned dataset withctsem, saves results as.RDSfile in/files/analysis_ctsem.Rcode to load the fitted ctsem model objects, check convergence, extract fixed effect estimates, and visualize results (Figure 4)analysis_msm.Rcode to fit the CT-Markov-Switching-Model (CT-MSM) to the full cleaned dataset usingmsm, extract parameter estimates and visualize results (Figure 5)
analysis_ct_subset
In this folder we repeat the analyses found in the analysis_ct folder for two different subsets of the data. The short dataset consists of observations taken at short time-intervals,and the EMA dataset consists of observations taken with a longer time-interval more typical of EMA designs. For details see paper.
model_fitting_ema.Rfits the CT-VAR(1) model to the "EMA" data subset, saves in/filesmodel_fitting_short.Rfits the CT-VAR(1) model to the "short" data subset, saves in/filesanalysis_fitted_models.Rcode to load the fittedctsemmodel objects, check convergence, extract fixed effect estimates. Creates Figure 6 panels (a) and (b).plotting_ctsem.Rcode to make additional visualizations of estimated model parameters, including lagged effect plots and impulse response functions (IRFs) for both data subsets. Caution: can be time-intensive to run this code. Creates Figure 6 panels (b) through (e)analysis_msm_subset.Rcode to fit the CT-Markov-Switching-Model (CT-MSM) to theESMandshortdatasets usingmsm, extract parameter estimates and visualize results (Figure 7).
files
In addition to storing model fit objects, this folder contains two files for the purposes of reproducibility
sessionInfo_ctsem.txtcontains the machine specifications and package versions used when estimating the CT-VAR(1) models throughctsem. Because this analysis takes a considerable amount of time to run, the analysis was performed on a different machine than the remaining analyses.sessionInfo.txtcontains the machine specifications and package versions used for the rest of the analyses
