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
21 papers in training set
Top 0.1%
12.0%
2
European Psychiatry
10 papers in training set
Top 0.1%
7.0%
3
Translational Psychiatry
219 papers in training set
Top 0.8%
7.0%
4
Schizophrenia Bulletin
29 papers in training set
Top 0.2%
6.6%
5
Acta Psychiatrica Scandinavica
10 papers in training set
Top 0.1%
6.2%
6
Molecular Psychiatry
242 papers in training set
Top 0.6%
4.7%
7
JAMA Psychiatry
13 papers in training set
Top 0.1%
4.5%
8
PLOS Medicine
98 papers in training set
Top 0.8%
4.2%
50% of probability mass above
9
npj Digital Medicine
97 papers in training set
Top 1%
4.2%
10
Biological Psychiatry
119 papers in training set
Top 0.9%
3.9%
11
Neuropsychopharmacology
134 papers in training set
Top 1.0%
3.5%
12
Psychological Medicine
74 papers in training set
Top 0.6%
3.5%
13
Nature Medicine
117 papers in training set
Top 1%
2.8%
14
JAMA Network Open
127 papers in training set
Top 2%
2.0%
15
BMC Medicine
163 papers in training set
Top 3%
2.0%
16
BMJ Mental Health
15 papers in training set
Top 0.1%
1.8%
17
PLOS ONE
4510 papers in training set
Top 55%
1.7%
18
American Journal of Psychiatry
20 papers in training set
Top 0.2%
1.7%
19
Psychiatry Research
35 papers in training set
Top 1.0%
1.7%
20
Nature Communications
4913 papers in training set
Top 53%
1.7%
21
Epidemiology and Psychiatric Sciences
10 papers in training set
Top 0.2%
1.2%
22
Biological Psychiatry: Cognitive Neuroscience and Neuroimaging
62 papers in training set
Top 1%
0.9%
23
BJPsych Open
25 papers in training set
Top 0.6%
0.9%
24
Acta Neuropsychiatrica
12 papers in training set
Top 0.8%
0.9%
25
Journal of Neurology, Neurosurgery & Psychiatry
29 papers in training set
Top 1%
0.9%
26
Biological Psychiatry Global Open Science
54 papers in training set
Top 1%
0.8%
27
Nature Neuroscience
216 papers in training set
Top 6%
0.7%
28
Journal of Affective Disorders
81 papers in training set
Top 2%
0.7%
29
Schizophrenia
19 papers in training set
Top 0.4%
0.7%
30
Frontiers in Psychiatry
83 papers in training set
Top 3%
0.7%