Back

Predicting Intentional Self-Harm Following Psychiatric Discharge in Catalonia, Spain: Machine Learning Models from Linked Registry Data

Alayo, I.; Pujol, O.; Amigo, F.; Ballester, L.; Cirici Amell, R.; Contaldo, S. F.; Ferrer, M.; Guinart, D.; Latorre, L.; Leis, A.; Lopez Fernandez, M.; Mayer, M. A.; Pastor, M.; Pena-Salazar, C.; Portillo-Van Diest, A.; Ramirez-Anguita, J. M.; Sanz, F.; Alonso, J.; Kessler, R. C.; Mehlum, L.; Palao, D.; Perez Sola, V.; Vilagut, G.; Mortier, P.

2025-09-28 psychiatry and clinical psychology
10.1101/2025.09.26.25336360 medRxiv
Show abstract

IntroductionPatients recently discharged from psychiatric hospitalization are at increased risk of intentional self-harm, including suicide. Using linked population-based registry data from Catalonia, Spain, we developed machine learning-based prediction models for post-discharge intentional self-harm across different follow-up horizons, sex, and age groups, and evaluated their generalizability and robustness with multiple validation strategies. MethodsRetrospective cohort study including 41,827 individuals accounting for 71,865 psychiatric hospitalizations with discharge at age [≥]10 years, between January 1, 2015, and December 31, 2018, in Catalonia, Spain, with follow-up until December 31, 2019. Primary outcome was intentional self-harm (fatal or non-fatal) within 7, 30, 90, 180, and 365 days post-discharge. Models incorporated 247 predictors from electronic health records, including sociodemographic characteristics, mental and physical disorder categories, categories of dispensed psychotropic medication, and history of self-harm and psychiatric hospitalization. Model performance was evaluated using the area under the receiver operating characteristic curve (AUCROC) and the area under the precision-recall curve (AUCPR). Predictor importance was assessed using Shapley Additive Explanations (SHAP). ResultsWithin 365 days, 4,901 hospitalizations (6.8%) were followed by intentional self-harm. The 365-day model trained on the full cohort achieved a AUCROC of 0.819, in the test sample with adjusted AUCPR indicating a median 5.4-fold improvement over baseline prevalence. This model generalized well across event horizons and sex-age strata, outperforming subgroup-specific models when data sparsity limited performance. Separate models trained by event horizons, and stratified by sex, and sex-age groups achieved a median AUCROC of 0.775 (IQR 0.764-0.808), with adjusted AUCPR indicating a median 5.4-fold improvement over baseline prevalence (IQR 4.5-6.2). Key predictors included the recency of the last registered diagnosis of depressive episodes, recurrent depression, adjustment disorders, and schizophrenia, as well as recent SSRI dispensation and the number of childhood-onset disorder and musculoskeletal disease diagnoses in the previous five years. Predictor importance varied considerably across sex-age strata, with smaller differences across horizons. Subject-level and temporal split validation strategies reduced performance (AUCROC 0.711-0.746), though estimates remained clinically informative (2.8-3.1-fold improvement over baseline prevalence). ConclusionsMachine learning models using routinely collected health records predicted intentional self-harm after psychiatric hospitalization with good discrimination and clinically meaningful precision-recall performance. A single 365-day model generalized well across horizons and demographic groups, suggesting that one broadly trained model may provide a pragmatic and scalable approach for clinical implementation.

Matching journals

The top 8 journals account for 50% of the predicted probability mass.

1
The British Journal of Psychiatry
23 papers in training set
Top 0.1%
9.4%
2
Journal of Affective Disorders
92 papers in training set
Top 0.4%
7.0%
3
Translational Psychiatry
260 papers in training set
Top 0.9%
6.5%
4
Psychological Medicine
88 papers in training set
Top 0.3%
6.5%
5
European Psychiatry
11 papers in training set
Top 0.1%
6.0%
6
Molecular Psychiatry
282 papers in training set
Top 1%
5.3%
7
Biological Psychiatry
137 papers in training set
Top 0.6%
5.3%
8
BMJ Mental Health
15 papers in training set
Top 0.1%
5.0%
50% of probability mass above
9
Acta Psychiatrica Scandinavica
10 papers in training set
Top 0.1%
5.0%
10
PLOS Medicine
110 papers in training set
Top 0.5%
4.7%
11
Psychiatry Research
41 papers in training set
Top 0.3%
4.7%
12
npj Digital Medicine
118 papers in training set
Top 2%
3.1%
13
JAMA Psychiatry
15 papers in training set
Top 0.1%
2.5%
14
Epidemiology and Psychiatric Sciences
11 papers in training set
Top 0.1%
2.0%
15
PLOS ONE
5266 papers in training set
Top 50%
1.7%
16
Biological Psychiatry: Cognitive Neuroscience and Neuroimaging
71 papers in training set
Top 0.9%
1.7%
17
BMC Psychiatry
25 papers in training set
Top 0.5%
1.4%
18
Communications Medicine
113 papers in training set
Top 3%
1.4%
19
Nature Medicine
125 papers in training set
Top 2%
1.4%
20
Acta Neuropsychiatrica
14 papers in training set
Top 0.3%
1.3%
21
Computational Psychiatry
12 papers in training set
Top 0.1%
1.0%
22
American Journal of Psychiatry
24 papers in training set
Top 0.5%
1.0%
23
Neuropsychopharmacology
153 papers in training set
Top 2%
1.0%
24
JAMA Network Open
130 papers in training set
Top 4%
0.8%
25
Psychiatry and Clinical Neurosciences
11 papers in training set
Top 0.3%
0.8%
26
Journal of Neurology, Neurosurgery & Psychiatry
30 papers in training set
Top 0.8%
0.8%
27
Schizophrenia
21 papers in training set
Top 0.4%
0.8%
28
Schizophrenia Bulletin
32 papers in training set
Top 0.4%
0.8%
29
Journal of Psychiatric Research
32 papers in training set
Top 1.0%
0.8%
30
BJPsych Open
29 papers in training set
Top 0.9%
0.6%