A Structural FHMM for Interpretable Disease Trajectories in T2DM
Authors: Alessandro Mari, Ekaterina Krymova, Guillaume Obozinski, Maria Luisa Marques de Sa Faquetti, Adrian Martinez de la Torre, Andrea Burden
Organizations: Swiss Data Science Center (SDSC), Ecole Polytechnique F´ed´erale de Lausanne (EPFL), Switzerland · Swiss Data Science Center (SDSC), ETH Zürich, Switzerland · Pharmacoepidemiology Group, Institute of Pharmaceutical Sciences, Zurich, Switzerland
In this work, we propose a structural variant of the Factorial Hidden Markov Model (FHMM) for the analysis of disease trajectories in patients with Type 2 diabetes mellitus (T2DM). The model represents a patient's latent health state as a combination of multiple independent, simultaneously evolving components, associated with comorbidities and lab results. This structured latent representation facilitates the identification of clinically meaningful patient states and clustering of common disease trajectories. We evaluate the proposed approach using The IQVIA Medical Research Data incorporating data from THIN, a Cegedim database of anonymized electronic health records (EHR), identifying patients with a first-ever prescription for a non-insulin antidiabetic drug (NIAD) between January 2006 and December 2019. The model identifies multiple clinically coherent latent components corresponding to known patterns of diabetes-related complications and reveals heterogeneous progression pathways, including distinct microvascular-dominant and multi-organ trajectories associated with elevated comorbidity burden and mortality. These results demonstrate that the proposed framework captures meaningful longitudinal structure in EHR data and provides interpretable insights into the evolution of T2DM and its comorbidities.
Figures & tables
Figure 1: Graphical representation of the preprocessing steps.
• Glycated hemoglobin (Hb A1c) in % • Low-density Lipoprotein (LDL) cholesterol in mmol/L • High-density Lipoprotein (HDL) cholesterol in mmol/L • Triglycerides (TG) in mmol/L • Blood pressure (Systolic/Diastolic) in mmHg • Body Mass Index (BMI) in kg/m 2 • Glomerular filtration rate (GFR) in mL/min/1.73m 2
Table 1: List of variables that are included in the model.
Figure 2: Directed graphical model of a FHMM with M=3 hidden chains. Arrows represent causal relationships and gray nodes are observed variables. White nodes are not observed. The variables Xt are the drugs taken at time t that influence the patient health state Ht=def(Ht(1),…,Ht(M)) . The results of the lab tests YtLAB and the set of comorbidities YtCOM are direct consequences of the health state Ht at time t .
Figure 3: Possible transitions between states of a hidden chain with 5 states and jumps of size d=1 .
Figure 4: Filtering of patients based on missing laboratory data during the four years preceding NIAD initiation. A total of 100325 patients were excluded. Abbreviations are defined in Table 1 .
Sex
Men
Women
Age group
<65
65+
<65
65+
Number of patients
27191
21989
20792
18229
Average age at NIAD (y) ± SD
54.0 ± 8.0
73.7 ± 6.3
52.5 ± 9.3
74.9 ± 6.7
Median follow-up duration in years post-NIAD [IQR]
4.5 [5.0]
4.0 [4.5]
4.0 [5.0]
4.0 [4.5]
Average BMI at NIAD (kg/m 2 ) ± SD
32.9 ± 6.3
30.1 ± 5.1
35.4 ± 7.9
31.0 ± 6.4
Average HbA1c at NIAD (%) ± SD
7.4 ± 1.7
7.1 ± 1.4
7.2 ± 1.6
7.0 ± 1.3
Table 2: Patient characteristics at the index date (NIAD initiation) for the cohort after preprocessing. Comorbidities are reported as percentages of the cohort population. Laboratory measurements are summarized as mean values, with the proportion of missing observations reported in parentheses. Abbreviations are defined in Table 1 . SD denotes standard deviation and IQR denotes interquartile range.
Men <65
Women <65
Men 65+
Women 65+
Model
BIC
AIC
BIC
AIC
BIC
AIC
BIC
AIC
HMM(27)8
329077
314469
236219
221959
234704
220497
212736
198738
FHMM(3,3)1
310663
307445
225526
222385
229629
226500
203633
200550
FHMM(4,4)2
292039
286438
216236
210769
221682
216235
195206
189839
FHMM(4,6)2
293949
285052
211923
203239
220663
212010
195312
186787
FHMM(6,4)2
264231
256136
190847
182946
201848
193976
181320
173563
Table 3: Comparison between models with various number of chains. Metrics are evaluated on the validation set and drugs are not used as input.
Figure 5: Top: Emission parameters η modeling the risk of developing a comorbidity for a given state. Larger values indicate a higher probability of having the comorbidity. The values are reported on a logarithmic scale. Bottom: Mean value of lab tests with respect to the intercept (i.e., state 0). Red (resp. blue) indicates an increase (resp. decrease) in E[Yt∣Ht] relative to the intercept. The model includes 8 chains with 4 states per chain and is fitted on on Women <65 .
Figure 6: Estimated contribution of drug prescriptions to initial latent state allocation ( Winit ), based on a model with 8 chains and 4 states per chain fitted to the Women <65 subgroup. Higher values indicate a greater probability of starting in a more severe latent state. These estimates capture baseline correlations, not causal effects, since they describe state assignment rather than counterfactual deviation.
Cluster
0
1
2
3
4
5
6
7
8
9
10
11
12
# of patients
3373
1468
1549
792
2774
1491
1101
1431
1006
1421
594
1143
1362
Avg. age at NIAD (y) ± SD
47.01 ± 10.68
47.1 ± 10.3
54.01 ± 7.19
57.49 ± 6.09
54.27 ± 7.5
54.53 ± 8.24
54.61 ± 7.71
55.52 ± 7.38
56.12 ± 7.1
53.19 ± 7.93
57.12 ± 6.27
48.75 ± 9.98
55.23 ± 7.86
Avg. follow-up post-NIAD (y) ± SD
3.73 ± 2.68
4.52 ± 2.98
5.88 ± 3.15
4.87 ± 2.99
4.63 ± 3.13
5.23 ± 3.28
5.23 ± 3.19
6.21 ± 3.27
5.37 ± 3.24
5.81 ± 3.25
6.79 ± 3.23
5.08 ± 3.0
6.52 ± 3.35
Avg. BMI at NIAD (kg/m 2 ) ± SD
33.15 ± 7.55
37.25 ± 7.79
34.07 ± 6.16
35.74 ± 7.81
34.54 ± 6.94
34.31 ± 6.73
35.04 ± 6.93
40.96 ± 9.87
36.64 ± 7.38
38.35 ± 7.72
31.23 ± 6.45
32.96 ± 6.62
38.04 ± 8.34
Avg. HbA1c at NIAD (%) ± SD
6.83 ± 1.56
7.26 ± 1.66
7.48 ± 1.61
7.24 ± 1.47
6.89 ± 1.37
7.15 ± 1.49
7.25 ± 1.48
7.51 ± 1.61
7.35 ± 1.5
7.05 ± 1.46
7.16 ± 1.59
7.94 ± 1.83
6.92 ± 1.37
% Ever smoked
23.04
79.56
20.46
78.41
20.01
29.51
43.23
56.81
55.07
59.25
30.13
24.41
50.07
Table 4: Patient characteristics in each cluster for the Women <65 cohort with average values and standard deviation where applicable. Comorbidities are presented as absolute counts at NIAD initiation, along with the number of new comorbidities developed post-NIAD. Proportions, expressed as percentages of the cohort population, are reported in parentheses.
Figure 7: Average cluster-specific probabilities and lab values for Women <65 . Values have been centered by subtracting the average at the time of NIAD initiation to improve readability. Red bars indicate increases, and blue bars indicate decreases relative to the average patient at NIAD. Comorbidity risks are shown as changes in probability (left axis), and lab values as percentage changes relative to the reference value (right axis). Annotated numbers indicate absolute changes in the original units (see Table 1 ). Error bars represent the standard error of the mean.
Figure 8: Distribution of the clusters over time.
Figure 9: Cumulative Incidence Function (CIF) for the time to first cluster transition in Women <65 , stratified by initial cluster assignment at 6 months post-NIAD. The estimates account for censoring due to loss to follow-up and study termination, computed using the Aalen nonparametric estimator [ 25 ] .
Figure 10: Transition graph. Red arrows (resp. blue) means an increase (resp. decrease) of the comorbidity risk ( Women <65 ). Arrow thickness is proportional to the number of observed transitions. Transitions with less than 1% probability are not shown.
Appendix figures & tables21 assets
Supplementary material from the paper’s appendix.
Appendix
Lab Value
Low
High
Comment
Glomerular filtration rate
0
150
-
Hb A1C
0
16
-
High Density Lipoprotein
0
5
-
Low Density Lipoprotein
0
10
-
Triglycerides
0
15
-
BMI
0
80
-
Appendix
Table 5: Predefined thresholds used to remove outliers. Values are removed if they are not included in the lower and upper limits.
Men <65
Men 65+
Women <65
Women 65+
Train
Val
Test
Train
Val
Test
Train
Val
Test
Train
Val
Test
COPD
7.7
7.6
8.0
16.4
16.1
17.0
7.8
7.9
7.9
13.3
12.8
15.6
Diabetic retinopathy
32.8
33.4
32.9
34.8
36.3
36.4
30.4
31.5
31.1
34.6
33.8
35.7
Hypertension
59.5
59.7
61.3
71.2
71.0
71.9
56.9
57.0
57.1
78.6
79.9
79.2
Myocardial infarction
8.8
9.2
9.0
16.6
17.1
18.5
3.0
2.8
2.8
7.9
6.8
7.3
Peripheral vascular disease
4.2
3.8
4.5
11.0
11.1
10.5
1.7
1.8
1.6
5.5
6.2
5.7
Appendix
Table 6: Number of patient diagnosed with the comorbidity for each data split. Numbers are given in percentage.
Metric
BIC
AIC
Category
Model
Drugs
No Drugs
Drugs
No Drugs
Men <65
FHMM(3,3)1
315914
310663
308086
307445
FHMM(4,4)2
308458
292039
294662
286438
FHMM(6,4)2
291660
264231
271273
256136
FHMM(8,4)2
280861
273337
253882
262748
FHMM(10,2)1
286149
276474
270171
270739
Appendix
Table 7: Comparison between models with drugs ( Xt ) and without drugs. Metrics are evaluated on the validation set.
Figure 11: Top: Average effect of drugs on the transition matrix, estimated as 1/K∑i=1K(Wr,idrug−Wl,idrug) . Red (resp. blue) means an increase of the probability to transition to a higher (resp. lower) state value. Bottom: Emission parameters η modeling the risk of developing a comorbidity for a given state. Larger values indicate a higher probability of having the comorbidity. The model includes 8 chains with 4 states per chain and is fitted on Men <65 .
Figure 12: Cluster selection using Davies-Bouldin index and the prediction strength. The optimal number of cluster is indicated by the black dashed line. This is fitted on the population of Women <65 .
Figure 13: Evolution of patient clusters 0 (healthy), 2 (pathway to multimorbidity), 3 (pulmonary-metabolic), 4 (isolated hypertension), 6 (hepatic), 8 (advanced nephropathy), 9 (obese hypertension), 10 (bone-vascular), 11 (isolated DR), and 12 (cardio-pulmonary multimorbidity) over time ( Women <65 ), conditional on the initial cluster assignment (6 months post-NIAD). The number of patients in each cluster is indicated alongside the corresponding bars. For clarity, flows representing less than 1% of the initial cluster size, as well as transitions to no available follow-up data, are not displayed. Clusters 1, 5, and 7 are excluded due to the low number of transitions observed from these clusters.
Cluster
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# of patients
6504
1788
1698
1166
3911
1522
360
1212
957
1534
1010
1511
1070
703
685
Avg. age at NIAD (y) ± SD
50.88 ± 8.68
53.66 ± 8.11
55.28 ± 6.95
57.41 ± 6.39
53.89 ± 7.32
56.18 ± 6.73
58.28 ± 5.63
53.21 ± 7.78
57.69 ± 5.92
57.42 ± 6.14
55.41 ± 7.21
51.53 ± 8.35
56.68 ± 6.42
55.89 ± 7.02
54.0 ± 7.97
Avg. follow-up post-NIAD (y) ± SD
4.28 ± 3.1
6.85 ± 3.25
5.78 ± 2.86
5.38 ± 3.11
4.72 ± 3.22
6.52 ± 3.27
4.49 ± 2.89
5.97 ± 3.06
5.46 ± 3.59
5.58 ± 3.57
3.63 ± 2.85
5.29 ± 2.75
6.25 ± 2.88
5.05 ± 3.08
6.29 ± 2.64
Avg. BMI at NIAD (kg/m 2 ) ± SD
30.85 ± 5.52
34.96 ± 6.67
31.58 ± 4.79
34.31 ± 6.68
32.47 ± 5.32
30.86 ± 4.48
32.25 ± 6.67
43.79 ± 5.7
32.82 ± 4.93
33.54 ± 4.23
33.08 ± 6.39
30.38 ± 4.95
36.46 ± 6.85
32.01 ± 6.18
34.96 ± 6.77
Avg. HbA1c at NIAD (%) ± SD
7.45 ± 1.73
7.39 ± 1.61
7.47 ± 1.59
7.31 ± 1.64
7.23 ± 1.56
7.19 ± 1.6
7.31 ± 1.61
7.44 ± 1.63
7.36 ± 1.7
7.2 ± 1.45
7.4 ± 1.71
7.69 ± 1.7
7.48 ± 1.59
7.47 ± 1.63
7.59 ± 1.65
% Ever smoked
43.48
53.75
32.63
62.86
39.43
34.82
71.67
39.69
53.81
44.72
55.15
39.38
44.11
70.13
53.87
Appendix
Table 8: Patient characteristics in each cluster for the Men <65 cohort with average values and standard deviation where applicable. Comorbidities are presented as absolute counts at NIAD initiation, along with the number of new comorbidities developed post-NIAD. Proportions, expressed as percentages of the cohort population, are reported in parentheses.
Figure 14: Average cluster-specific probabilities and lab values for Men <65 . Values have been centered by subtracting the average at the time of NIAD initiation to improve readability. Red bars indicate increases, and blue bars indicate decreases relative to the average patient at NIAD. Comorbidity risks are shown as changes in probability (left axis), and lab values as percentage changes relative to the reference value (right axis). Annotated numbers indicate absolute changes in the original units (see Table 1 ). Error bars represent the standard error of the mean.
Figure 15: Evolution of patient clusters over time ( Men <65 ), conditional on the initial cluster assignment (6 months post-NIAD). The number of patients in each cluster is indicated alongside the corresponding bars. For clarity, only the most frequent transitions are shown (see Figure 16 for more details). Cluster 6 is excluded due to the low number of transitions observed from this cluster.
Figure 16: Cumulative Incidence Function (CIF) for the time to first cluster transition in Men <65 , stratified by initial cluster assignment at 6 months post-NIAD. The estimates account for censoring due to loss to follow-up and study termination, computed using the Aalen nonparametric estimator [ 25 ] .
Figure 17: Transition graph. Red arrows (resp. blue) means an increase (resp. decrease) of the comorbidity risk ( Men <65 ). Arrow thickness is proportional to the number of observed transitions. Transitions with less than 1% probability are not shown.
Cluster
0
1
2
3
4
5
6
7
8
9
10
11
12
# of patients
2732
1515
1813
838
1974
1430
1125
1214
1954
3028
769
762
1319
Avg. age at NIAD (y) ± SD
72.61 ± 6.01
72.22 ± 5.62
73.01 ± 5.74
75.48 ± 6.69
74.38 ± 6.09
74.57 ± 6.37
75.52 ± 6.54
73.3 ± 6.12
74.73 ± 6.57
72.0 ± 5.39
75.14 ± 6.76
73.46 ± 6.24
74.14 ± 6.3
Avg. follow-up post-NIAD (y) ± SD
4.4 ± 3.1
5.31 ± 2.86
5.08 ± 2.85
4.45 ± 2.8
4.9 ± 2.9
5.15 ± 3.28
4.37 ± 2.85
5.79 ± 3.08
4.04 ± 2.78
4.46 ± 3.1
4.89 ± 2.81
5.35 ± 2.73
4.96 ± 2.97
Avg. BMI at NIAD (kg/m 2 ) ± SD
28.68 ± 4.35
30.01 ± 4.87
29.41 ± 3.84
29.9 ± 5.1
30.54 ± 5.51
29.78 ± 3.97
30.13 ± 5.43
34.35 ± 6.26
29.0 ± 3.88
29.71 ± 4.17
32.81 ± 5.74
33.89 ± 6.31
28.94 ± 5.19
Avg. HbA1c at NIAD (%) ± SD
6.96 ± 1.33
7.33 ± 1.41
7.16 ± 1.36
7.09 ± 1.39
6.94 ± 1.33
6.95 ± 1.24
7.12 ± 1.36
6.87 ± 1.3
7.11 ± 1.37
6.92 ± 1.28
7.01 ± 1.36
7.21 ± 1.38
7.1 ± 1.36
% Ever smoked
29.61
31.22
26.86
27.92
45.54
27.48
56.44
27.68
41.91
27.87
34.72
29.27
48.6
Appendix
Table 9: Patient characteristics in each cluster for the Men 65+ cohort with average values and standard deviation where applicable. Comorbidities are presented as absolute counts at NIAD initiation, along with the number of new comorbidities developed post-NIAD. Proportions, expressed as percentages of the cohort population, are reported in parentheses.
Figure 18: Average cluster-specific probabilities and lab values for Men 65+ . Values have been centered by subtracting the average at the time of NIAD initiation to improve readability. Red bars indicate increases, and blue bars indicate decreases relative to the average patient at NIAD. Comorbidity risks are shown as changes in probability (left axis), and lab values as percentage changes relative to the reference value (right axis). Annotated numbers indicate absolute changes in the original units (see Table 1 ). Error bars represent the standard error of the mean.
Figure 19: Evolution of patient clusters over time ( Men 65+ ), conditional on the initial cluster assignment (6 months post-NIAD). The number of patients in each cluster is indicated alongside the corresponding bars. For clarity, only the most frequent transitions are shown (see Figure 20 for more details). Clusters 2,3,6,8,10,11 are excluded due to the low number of transitions observed from these clusters.
Figure 20: Cumulative Incidence Function (CIF) for the time to first cluster transition in Men 65+ , stratified by initial cluster assignment at 6 months post-NIAD. The estimates account for censoring due to loss to follow-up and study termination, computed using the Aalen nonparametric estimator [ 25 ] .
Figure 21: Transition graph. Red arrows (resp. blue) means an increase (resp. decrease) of the comorbidity risk ( Men 65+ ). Arrow thickness is proportional to the number of observed transitions. Transitions with less than 1% probability are not shown.
Cluster
0
1
2
3
4
5
6
7
8
9
10
11
12
# of patients
2604
857
1629
742
1626
1276
787
1258
681
3702
716
644
452
Avg. age at NIAD (y) ± SD
72.7 ± 5.8
72.98 ± 5.79
74.91 ± 6.32
74.08 ± 6.18
76.72 ± 6.69
79.47 ± 7.44
76.98 ± 7.06
73.32 ± 5.86
78.33 ± 7.13
73.24 ± 5.72
73.69 ± 6.0
77.85 ± 7.15
74.04 ± 6.35
Avg. follow-up post-NIAD (y) ± SD
4.7 ± 3.12
5.11 ± 2.68
5.07 ± 2.71
4.35 ± 2.77
5.52 ± 3.12
3.5 ± 2.66
3.79 ± 2.64
6.0 ± 3.23
4.04 ± 2.31
4.82 ± 3.24
5.7 ± 2.68
4.24 ± 2.78
4.91 ± 2.73
Avg. BMI at NIAD (kg/m 2 ) ± SD
30.24 ± 6.15
29.99 ± 5.92
29.84 ± 4.83
32.63 ± 6.74
28.96 ± 5.31
27.99 ± 4.72
29.53 ± 6.46
36.76 ± 7.37
30.7 ± 6.34
30.74 ± 4.8
36.67 ± 7.09
34.36 ± 7.83
31.65 ± 6.33
Avg. HbA1c at NIAD (%) ± SD
6.96 ± 1.27
7.24 ± 1.32
7.09 ± 1.29
7.08 ± 1.39
6.83 ± 1.3
7.08 ± 1.35
7.15 ± 1.42
6.98 ± 1.26
7.37 ± 1.49
6.9 ± 1.25
7.05 ± 1.18
7.09 ± 1.41
7.32 ± 1.37
% Ever smoked
30.72
32.79
24.86
64.56
18.02
31.03
43.96
24.24
37.0
21.47
25.56
33.7
23.67
Appendix
Table 10: Patient characteristics in each cluster for the Women 65+ cohort with average values and standard deviation where applicable. Comorbidities are presented as absolute counts at NIAD initiation, along with the number of new comorbidities developed post-NIAD. Proportions, expressed as percentages of the cohort population, are reported in parentheses.
Figure 22: Average cluster-specific probabilities and lab values for Women 65+ . Values have been centered by subtracting the average at the time of NIAD initiation to improve readability. Red bars indicate increases, and blue bars indicate decreases relative to the average patient at NIAD. Comorbidity risks are shown as changes in probability (left axis), and lab values as percentage changes relative to the reference value (right axis). Annotated numbers indicate absolute changes in the original units (see Table 1 ). Error bars represent the standard error of the mean.
Figure 23: Evolution of patient clusters over time ( Women 65+ ), conditional on the initial cluster assignment (6 months post-NIAD). The number of patients in each cluster is indicated alongside the corresponding bars. For clarity, only the most frequent transitions are shown (see Figure 24 for more details). Clusters 1,8 are excluded due to the low number of transitions observed from these clusters.
Figure 24: Cumulative Incidence Function (CIF) for the time to first cluster transition in Women 65+ , stratified by initial cluster assignment at 6 months post-NIAD. The estimates account for censoring due to loss to follow-up and study termination, computed using the Aalen nonparametric estimator [ 25 ] .
Figure 25: Transition graph. Red arrows (resp. blue) means an increase (resp. decrease) of the comorbidity risk ( Women 65+ ). Arrow thickness is proportional to the number of observed transitions. Transitions with less than 1% probability are not shown.
Longitudinal electronic health record modeling learns from patient histories over time to forecast outcomes, characterize disease trajectories, and guide care.
University of Massachusetts Amherst, United States · MedStar Health Center for Diagnostic Systems Safety, United States · National Center for Human Factors in Healthcare, MedStar Health Research Institute, United States +2