Chapter 14. Survival Analysis
This chapter introduces “survival analysis”, which is a set of statistical methods used to answer questions about the time until an event. In the context of medicine it is literally about survival, but it can be applied to the time until any kind of event, or instead of time it can be about space or other dimensions.
Survival analysis is challenging because the data we have are often incomplete. But as we’ll see, Bayesian methods are particularly good at working with incomplete data.
As examples, we’ll consider two applications that are a little less serious than life and death: the time until light bulbs fail and the time until dogs in a shelter are adopted. To describe these “survival times”, we’ll use the Weibull distribution.
The Weibull Distribution
The Weibull distribution is often used in survival analysis because it is a good model for the distribution of lifetimes for manufactured products, at least over some parts of the range.
SciPy provides several versions of the Weibull distribution; the one
we’ll use is called weibull_min
. To make the interface
consistent with our notation, I’ll wrap it in a function
that takes as parameters , which mostly affects the
location or “central tendency” of the distribution, and
, which affects the shape.
from
scipy.stats
import
weibull_min
def
weibull_dist
(
lam
,
k
):
return
weibull_min
(
k
,
scale
=
lam
)
As an example, here’s a Weibull distribution with parameters and k = 0.8:
lam
=
3
k
=
0.8
Get Think Bayes, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.