A super fun project where I took the old longitudinal Framingham data, and turned it into data capable of being modeled in a multi-state manner, with 4 states: wellness (no disease) (State 1), hypertension (State 2), cardiovascular disease (State 3) and death (State 4). The model takes censoring into account, and is able to produce both transition probabilities and intensities, and hazard ratios for a hypothetical patient.
Dr. Rinku Sutradhar, Senior Scientist and Biostatistician at the University of Toronto, presented this webinar on the basics of multistate modeling on the Population Data BC YouTube channel in June of 2020. I studied this webinar carefully, and listened to it several times to understand some of the theory behind these models and how they are calculated.
I also read this entire paper and created some test models as I prepared to create the Framingham model I had in mind:
Jackson CH (2011). “Multi-State Models for Panel Data: The msm Package for R.” Journal of Statistical Software, 38(8), 1–29. doi:10.18637/jss.v038.i08.
Taken from the Jackson (2011) reference, a first multistate model using the supplied 'cav' data set from Sharples, et al. (2003). The data is from a progression of coronary allograft vasculopathy (CAV), a post-transplant deterioration of arterial walls. The dataset has 2,816 state observations, defined as:
State 1: No CAV
State 2: Mild / moderate CAV
State 3: Severe CAV
State 4: Death
Click on the thumbnail to be taken to the Jupyter Notebook.
Also taken from the Jackson (2011) reference, a second test model, using a hidden Markov model to model bronchiolitis obliterans syndrome (BOS) - a chronic deterioration in lung function - using the 'fev' data, a dataset of repeated measures of forced expiratory volume in 1 second, in recipients of lung transplants.
In medicine, hidden Markov models can represent chronic staged diseases which can only be diagnosed by an error-prone marker.
We will model bronchiolitis obliterans syndrome (BOS) using the HMM because onset values fluctuate, and entry into states can be sudden. The HMM will have THREE states:
State 1: No BOS
State 2: BOS
State 3: Death
Click on the thumbnail to be taken to the Jupyter Notebook.
After recording covariates including ages at each transition, and recording all the patients who reached the end of the 8,766 day study without dying as reaching 'censorship' (State 99), the final DataFrame had 10,132 entries:
There were 2,917 people who experienced State 1 (No disease)
2,476 people who experienced State 2 (Hypertension), and 1,298 of those never experienced State 1 (they began in State 2)
844 people survived State 3 (Cardiovascular disease)
1,388 people died (transitioned to State 4)
2,507 people reached the end of their participation in an unknown state without dying, and were considered censored (State 99).
Click on the thumbnail to be taken to the Jupyter Notebook.
Mean time in the Well state: 1/0.048348 = 20.7 years
Mean time in the Hypertensive state: 1/0.021638 = 46.2 years
Mean time in the CVD state: 1/0.150787 = 6.6 years
From the Well state, the likelihood of transition to Hypertensive is: 0.026774 (2.7%)
From the Well state, the likelihood of transition to CVD is: 0.009887 (1%)
From the Well state, the likelihood of transition to Death is 0.011687 (1.2%)
From the Hypertensive state, the likelihood of transition to CVD is: 0.011434 (1.1%)
From the Hypertensive state, the likelihood of transition to Death is: 0.010204 (1%)
From the CVD state, the likelihood of transition to Death is: 0.150787 (15%)
Age
1 year increase in age is associated with a 5% increased risk of CVD onset (Well -> CVD)
1 year increase in age is associated with a 8% increased risk of Death (on average) (Well -> Death)
1 year increase in age is associated with a 3.2% increased risk of CVD onset, if Hypertensive (HTN -> CVD)
1 year increase in age is associated with a 4.4% increased risk of Death, if Hypertensive (HTN -> Death)
1 year increase in age is associated with a 5.8% increased risk of Death, if CVD (CVD -> Death)
Biological Sex
Being Female increases the risk of Hypertension onset (Well -> HTN) by 39% on average.
Being Female decreases the risk of CVD onset (Well -> CVD) by 51% on average.
Being Female decreases the risk of Death (Well -> Death) by 19% on average.
Being Female decreases the risk of CVD, given HTN (HTN -> CVD) by 45% on average.
Being Female decreases the risk of Death, given HTN (HTN -> Death) by 33% on average.
Diabetes
An initial diagnosis of Diabetes increases the risk of CVD onset (Well -> CVD) by an avg. of 170%
An initial diagnosis of Diabetes increases the risk of CVD onset, if Hypertensive (HTN -> CVD) by an avg. of 187%
An initial diagnosis of Diabetes increases the risk of Death for those who already have HTN by 103%.
An initial diagnosis of Diabetes increases the risk of Death for those who already have CVD by 57%.
Smoking
Being a smoker is associated with a 27% lower risk of becoming Hypertensive if Well (these are younger people).
Being a smoker is associated with a 26% increased risk of CVD, if Well.
Being a smoker is associated with a 39% increased risk of Dying, if Well.
Being a smoker is associated with a 29% increased risk of CVD, if Hypertensive.
Being a smoker is associated with a 25% increased risk of Death, if CVD.
One of the amazing things about a multi-state model is that we can feed a given set of covariate values into the model and determine transition probabilities for a patient with those characteristics. We can then compare that patient to the average patient, or to a patient with different characteristics (fewer risk factors, for example), to quantify the amount of risk of disease that may be reduced with a given treatment or change in lifestyle.
Below, I compared an average patient's transition likelihoods to that of a hypothetical patient who was 40 years old, with Diabetes and a current smoker. The average age of a patient in the at risk group was 50 years.
Comparing a 40 year-old smoker with Diabetes to the average patient
Average patient's likelihood of transition from Well -> HTN 0.026774 (2.7%), for this patient it is 9.7%, 7% higher than average.
Average patient's likelihood of transition from Well -> CVD 0.009887 (1%), for this patient it is 5.3%, 4.3% higher than average.
Average patient's likelihood of transition from HTN -> CVD 0.011434 (1.1%), for this patient it is 5.9%, 4.8% higher than average.
Average patient's likelihood of transition from CVD -> Death 0.150787 (15%), for this patient it is 6.6%, 8.4% lower than average.
Average patient's mean time in Well state 20.7 yrs, this patient 13.4 yrs, 7.3 fewer years than average.
Average patient's mean time in Hypertensive state 46.2 yrs, this patient 12.3 yrs, 33.9 fewer years than average.
Average patient's mean time in CVD state 6.6 yrs, this patient 15.2 yrs, 8.6 more years than average.
It is likely that increases in the likelihood of disease are due to the patient's risk factors, but increases in the # of years until death are due to the patient's relatively younger age.