SkillAgentSearch skills...

TimescaleSuicidalThinking

Code repository for the paper "Locating the Timescale of Suicidal Thinking" Coppersmith, Ryan et al.

Install / Use

/learn @ryanoisin/TimescaleSuicidalThinking
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

  • /Data contains 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.

  • /figures contains the figures created by the below scripts.

  • /files contains model fit objects generated by fitting ctsem models. Not shared publicly at this time

  • /analysis_ct contains scripts relating to running CT-VAR models in ctsem, and CT-MSM models in msm; analysing and visualizing the results. Caution: running ctsem models using MCMC estimation can be time-intensive

  • /analysis_ct contains 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.R contains auxiliary functions for plotting, computing descriptives and processing the data

  • analysis_descriptives.R a 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.R script 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.R creates the processed data files using in the continuous-time model analysis, stored in /Data

  • analysis_msm.R code to run and visualize the results of the markov-switching models

analysis_ct

  • model_fitting_ctsem.R fits the CT-VAR(1) model to the full cleaned dataset with ctsem, saves results as .RDS file in /files/
  • analysis_ctsem.R code to load the fitted ctsem model objects, check convergence, extract fixed effect estimates, and visualize results (Figure 4)
  • analysis_msm.R code to fit the CT-Markov-Switching-Model (CT-MSM) to the full cleaned dataset using msm, 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.R fits the CT-VAR(1) model to the "EMA" data subset, saves in /files
  • model_fitting_short.R fits the CT-VAR(1) model to the "short" data subset, saves in /files
  • analysis_fitted_models.R code to load the fitted ctsem model objects, check convergence, extract fixed effect estimates. Creates Figure 6 panels (a) and (b).
  • plotting_ctsem.R code 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.R code to fit the CT-Markov-Switching-Model (CT-MSM) to the ESMand short datasets using msm, 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.txt contains the machine specifications and package versions used when estimating the CT-VAR(1) models through ctsem. Because this analysis takes a considerable amount of time to run, the analysis was performed on a different machine than the remaining analyses.
  • sessionInfo.txt contains the machine specifications and package versions used for the rest of the analyses
View on GitHub
GitHub Stars5
CategoryDevelopment
Updated5mo ago
Forks0

Languages

R

Security Score

67/100

Audited on Nov 6, 2025

No findings