Published June 30, 2025 | Version v1
Software Open

Accompanying code for "Revealing state changes in momentary affect during treatment for depression using hidden Markov modeling"

  • 1. ROR icon University Medical Center Groningen

Description

During psychological treatment, depressed individuals tend to show changes in affect and symptoms in varied, non-linear patterns that are not yet well understood. 
This study aimed to investigate how affect changes as depression improves, by examining the presence and dynamics of underlying mood states in intensive ecological momentary assessments (M=502 observations per person) of 29 depressed individuals receiving psychotherapy. 
A Bayesian multilevel Hidden Markov Modeling approach was used to identify the optimal number of states and investigate whether probabilities of switching between these states changed over the course of treatment. Visualization was used to reveal temporal patterns in state switches and inter-individual heterogeneity.
A three-state solution best fit the data: a high depressed mood state in which negative affect was elevated and positive affect was lower; an inverse, low depressed mood state; and an intermediate state in which arousal levels were relatively low (including more tiredness, less stress and irritation). 
These states aligned well with validated weekly symptom scores. 
Typically, individuals remained in the same mood state from one moment to the next, switching to other states on 24\% of occasions. 
Initially, switches from high to low depressed mood mainly occurred via the medium depressed mood state.
As treatment progressed, participants (treatment responders especially) became more likely to remain in or switch to the low depressed mood state and became less likely to spend time in or switch to the high and medium depressed mood states. 
The pattern of switches and time spent in these states varied highly between individuals.

This repository contains the accompanying code for the manuscript: "Revealing state changes in momentary affect during treatment for depression using hidden Markov modeling". It comprehends R code to: (0) pre-process the data (e.g., sanity check on careless responding), (1) run the multilevel hidden Markov model on the affect factors and (2) post-process the obtained results in (1). Please note that the empirical data used in (0) and (1) is not available as part of this repository.

 

Files

mHMM_depression.zip

Files (41.1 kB)

Name Size Download all
md5:d235229d35b0e16025dd7956341a3b6b
41.1 kB Preview Download

Additional details

Software

Programming language
R