This topic walks through the second mini-project — predicting adverse outcomes for patients in the ICU — including the cost model that turns a model’s ROC curve into a concrete threshold-selection question.
The data set is from the ICU (intensive care unit) of a Boston hospital. The general situation in an ICU: if you are in an ICU you are not doing well — you have a high probability of mortality.
There are technically different kinds of ICUs:
So it kind of depends; in general, for these kinds of datasets, depending on the population, around 50% of patients have an adverse outcome.
In this project, “adverse outcome” is defined as mortality. You could also look at transfers to palliative care — palliative care meaning care that’s not meant to prolong life so much as make the person comfortable, which happens when the expectation is the patient will pass away soon. Either of these flags is a useful proxy for “this person is getting worse.”
If you can predict which patients are going to deteriorate, you can intervene. The idea is: if you know ahead of time that a patient is about to deteriorate, maybe you can do something about it, so maybe they will not deteriorate after all. (Or if they do deteriorate, you reach them faster.)
A system like this was actually implemented in many hospitals — one in Ontario, several in the UK. On the pager, the staff would get a page if the system flagged the patient as likely to deteriorate or be transferred to palliative care.
Unfortunately, the system had a lot of false positives, and the doctors and nurses who got those pages learned to ignore them. That was one of the motivations for designing this project: how do we figure out how to use this kind of system in a way that actually improves outcomes?
The data is multiple text files. The mini-project gives you code that:
Once you’ve run all that code, you have a single data frame on which you do logistic regression to predict mortality.
You use a specified set of predictor variables (mean heart rate, mean urine output, mean temperature, age, etc.). The model is:
\[P(\text{mortality} = 1) = \sigma(\text{linear combination of predictors}).\]
You fit on training data and evaluate on a validation set.
You are asked to plot an ROC curve, which shows the trade-off between the false positive rate and the true positive rate.
You read the graph to answer questions about the model.
This is where it gets interesting. We are saying: how useful is this model in actual hospital practice?
The model:
So far this is plausible.
We need a formula for the probability of failing to come up with the right intervention as a function of the time \(t\) spent reviewing. We make one up:
\[p(\text{fail} \mid t) = \exp\!\left(-\frac{t^2}{100}\right).\]
If \(t\) is large, \(-t^2/100\) is very negative, so \(\exp(\cdot)\) is basically 0 — failure rate is essentially zero. If \(t\) is tiny, the exponent is close to zero, so the probability of failure is close to 1. This formula is not based on anything other than “this gives a really nice graph at the end.” We are not claiming the world really works like this.
fail_prob <- function(t) exp(-t^2 / 100)
ts <- seq(0, 15, by = 0.1)
plot(ts, fail_prob(ts), type = "l",
xlab = "time spent on chart (minutes)",
ylab = "P(miss the right intervention)",
main = "Made-up time vs failure-probability model")
Without the alert system, the doctor spends about \(60/25 = 2.4\) minutes per chart on average.
With the alert system: you only spend time on the charts that are flagged as likely to deteriorate. The patients who are not flagged: you spend less time on them (you don’t need to look at their chart at all in the strict version; in a more realistic version you spend less time on patients with low predicted risk but not zero).
We sweep possible thresholds: “the doctor only pays attention to charts above a given probability of adverse outcome.”
For every threshold, you can compute the average number of patients expected to die. With this formula, it turns out there is a very clear optimum point where it actually makes sense to spend more time on patients above a certain threshold.
Your task in part 5B of the mini-project is to make the graph: threshold on the x-axis, average number of people expected to die on the y-axis. The graph has a clear minimum which you find and report.
The mini-project is the basis for ~70% of the test. Specifically:
glm(... ~ ..., family = binomial) formula and interpret coefficients. (Like the sample test on Titanic.)Here is a plot of FPR vs TPR with several points labelled with their threshold. Come up with a reasonable criterion for selecting a threshold and apply it.
There is not one right answer. Reasonable arguments to make:
The marker is looking for “pick something in the middle of the curve, justify it” — a system is not useful if TPR = 0 or FPR = 1, so the answer is some explicit criterion in between.
For part 6 you are asked to identify the assumptions of the cost model and say why they might not be correct. You will not be marked harshly — say something. Identify the assumptions, say “this might be true, but here is a situation where it might not hold.” Something like that.
For example, the made-up formula \(\exp(-t^2/100)\) has no biological basis. Different doctors have different baseline skill, so a single function for “the doctor” is too simple. The independence assumption between patients is also probably violated (if you screw up the first chart you have less time for the rest, but you might also be tired and worse at the next ones).
Be reasonable; this part is about thinking critically, not about producing a defensive thesis.