Survival Models
Time-to-event models, unified by one idea — censoring as a probability mass over the region an event time is known to lie in. The arc starts with Weibull proportional hazards (parametric, right-censored, fit by MLE and Metropolis), extends it two ways, and generalises the censoring. The frailty model adds a per-subject random multiplier on the hazard — the hierarchical/random-effects extension, literally the survival likelihood × the hierarchical-Poisson sampler. The Cox-via-Poisson bridge fits the semiparametric Cox model as an ordinary Poisson GLM on expanded person-time (the piecewise-exponential = Poisson identity), making the recurring “survival is a count model” theme explicit. And interval-censored survival completes the censoring tour — one likelihood S(l) − S(u) that covers right, left, interval, and exact observations at once. Each is built from scratch and cross-checked across PyMC and R.
What time-to-event data is, and why censoring is unavoidable. The outcome here is how long something takes — until a patient relapses, a shock absorber fails, a tumour appears. What makes that its own subject, rather than ordinary regression on a number, is that you cannot wait forever. Studies end, patients move away, vehicles are taken off the road; and when follow-up stops, some subjects simply have not had the event yet. Their observation is censored: what you know is that the event time is greater than the number you wrote down, not what it is.
Both obvious responses are wrong, and wrong in opposite directions. Discard the censored subjects and you have thrown away precisely the ones who lasted longest — in the leukaemia trial below, the 12 of 21 treated patients still in remission when the study ended are the evidence that the drug worked, so deleting them would delete the finding. Treat still in remission at 60 weeks as though it meant relapsed at 60 weeks and you have invented events that never happened, biasing the other way. Neither is a small approximation: in the reliability example 61% of the sample is censored, and in the mouse study every single observation is.
The way out is to be honest about what each subject actually tells you. One who relapsed in week 8 contributes the probability of an event at week 8. One still event-free at week 60 contributes the probability of surviving past 60 — a whole tail of the distribution rather than a point. Both are perfectly good factors in a likelihood; they are simply different shapes. That single idea — a censored observation contributes the probability mass over the region its event time is known to lie in — is what the whole section rests on, and the interval-censored page at the end shows one formula covering every variety of it at once.
The hazard, which is what every result here is measured in. The natural way to describe a lifetime is the chance of surviving past each moment — the survival function S(t), which starts at 1 and falls. But survival models are built on its derivative in disguise, the hazard: the rate at which the event strikes at time t, among those who have made it that far. That last clause is the whole point. The number of relapses in week 30 depends on how many patients are still in remission at week 30, which is a shrinking and continually changing pool; dividing by it strips that out and leaves a quantity that means the same thing at every time. So a hazard of 0.05 per week says that of the patients still event-free, about 5% relapse in the coming week — whether there are 40 of them left or 4. Hazard and survival carry the same information: accumulate the hazard over time and exponentiate the negative, and you get S(t) back.
Hazard ratios, and the assumption behind them. Every headline number in this section is a hazard ratio — the factor by which a covariate multiplies that rate. A treatment with a hazard ratio of 0.18 leaves patients relapsing at roughly a fifth the rate of controls at any given moment. What makes a single such number meaningful is the proportional-hazards assumption, which names two of the pages below: the covariate multiplies the hazard by the same factor at all times, so the two groups’ hazard curves are vertical shifts of one another on a log scale and never cross. It is a real assumption and it can fail — a surgery that kills some patients immediately but protects the survivors has a hazard ratio above 1 early and below 1 later, and no single number describes it. Where it holds, one coefficient summarises a whole curve; that economy is why the assumption is made so often, and why it is worth remembering that it was made.
Parametric, semiparametric, nonparametric. The three pages that fit covariates differ chiefly in how much they are willing to assume about the baseline hazard — the shape of risk over time before any covariate acts. The Weibull model is parametric: the baseline is a specific curve governed by one shape parameter, which buys precision and extrapolation beyond the observed range at the cost of being wrong if the curve is wrong. The Cox model is semiparametric: the covariate effects are a parametric multiplier, but the baseline is left entirely unrestricted, so nothing at all is assumed about how risk evolves. And the Kaplan–Meier curve is nonparametric — no model, just the observed survival fraction stepping down at each event and pausing at each censored observation, which is why it appears on nearly every figure here as the thing a fitted model has to reproduce.
The two pictures the whole section runs on
The top panel is censoring, which is what makes time-to-event its own subject. Four subjects, four different things known about them — and in every case the model is handed the region the event time lies in rather than a number. Only the first contributes a density; the other three contribute probability mass over a stretch of the axis, which is why a survival likelihood mixes densities and tail probabilities in one product. The last row is the general case, and the interval-censored page shows the single formula S(l) − S(u) collapsing to all four.
The bottom two panels are the same fit twice — a Weibull fitted here, by right-censored maximum likelihood, to the 21 treated patients of the leukaemia trial below (9 relapses, 12 still in remission). On the left it is a hazard: the rate of relapse among those still in remission, rising slowly because the fitted shape is k = 1.35. On the right the same numbers are a survival curve, and the two are related by accumulating the hazard and exponentiating the negative — one object, two views. The staircase behind it is the Kaplan–Meier estimate, which assumes nothing: it drops at each relapse by the fraction of the remaining pool it represents, and merely steps over each censored patient (the ticks), removing them from the pool without recording an event. Its values here — 0.857, 0.807, 0.753, 0.690, 0.627, 0.538, 0.448 — are the textbook figures for this dataset.
Look at where the two part company after week 23 and you have the parametric–nonparametric trade-off in one image. Kaplan–Meier flattens at 0.448 and stays there, because after the last observed relapse it has nothing to go on and will not guess. The Weibull keeps descending, reaching 0.35 by week 35, because its shape parameter commits it to a view about what happens next. That extrapolation is exactly what the reliability example below needs — a warranty figure is a statement about distances no vehicle in the sample reached — and exactly what you are trusting when you use it.
Bayesian Weibull Proportional-Hazards Model
Parametric survival regression — Weibull proportional hazards with right-censoring —
fit from scratch by both MLE and Bayesian RW-Metropolis. The new ingredient over every earlier
example is censoring: an event contributes the hazard × survival
h(t)S(t), a censored subject only the survival S(t), switched
by a single indicator. The hazard ratio is eβ and the Weibull shape
k sets whether risk rises, falls, or is constant (k=1, exponential). A nice
structural link: the Weibull log-likelihood is a Poisson
kernel in disguise (the piecewise-exponential trick). Three worked examples surface different
facets of the same model: Leuk (BUGS; 6-MP vs placebo) — a treatment effect,
the drug lowering relapse hazard ~5–6×; Mice (BUGS; 4 groups) — a multi-level
factor with a strong wear-out shape (k ≈ 3.2); and a reliability study
(Meeker & Escobar shock absorbers, 61% censored) — engineering life metrics
(characteristic life, B₁₀, MTTF) read straight off the posterior. Each is cross-checked against
PyMC (censored likelihood via pm.Potential) and R (survreg Weibull +
semiparametric coxph).
Bayesian Hierarchical Survival — Frailty Models
The hierarchical extension of the Weibull survival model: each subject carries a
frailty — an unobserved random multiplier on the hazard, the survival
analogue of a random intercept. The implementation is deliberately modular — literally the
survival likelihood × the
hierarchical-Poisson random-intercept sampler — since
the per-patient frailty update is identical in form to the Poisson random intercept, only the
likelihood term differs. The frailty absorbs unmeasured heterogeneity and models the
within-subject correlation of repeated event times. Applied to the BUGS Kidney data
(McGilchrist & Aisbett 1991; 2 infection recurrences per patient): women have a far lower
hazard (HR ≈ 0.15) and the frailty is real (σw ≈ 0.65, a ~10× robust-to-frail
spread). The honest headline is a method sensitivity — a Cox-frailty ML fit collapses
σw to 0 (boundary artefact, 38 clusters of 2) while the Bayesian posterior and
parametric ML keep it near 0.6. Cross-checked against PyMC, R parfm, and
coxme.
Bayesian Cox via Poisson — the Count–Survival Bridge
The semiparametric Cox proportional-hazards model fit as an ordinary
Poisson GLM on expanded person-time data —
the piecewise-exponential = Poisson identity (Holford 1980; Laird & Olivier
1981) behind BUGS Leuk and PyMC's survival case study. Splitting time at the event
times with a piecewise-constant baseline hazard turns survival estimation into a count model
with a log-exposure offset and interval intercepts — no parametric baseline assumed,
and eβ is just a Poisson-regression coefficient. Applied to two
datasets with the same module: Leuk (control-vs-6-MP HR ≈ 5, matching
coxph and the Weibull fit) and
mastectomy (metastasis raises death hazard ~2.3×). Closes the loop on the
recurring "survival is a count model" theme — and adding a random effect to this Poisson is
exactly the frailty model. Cross-checked against PyMC,
R survSplit + glm, and coxph.
Bayesian Interval-Censored Survival
The sequel to the Weibull survival model (which did
right-censoring only): when subjects are checked periodically, an event is known only to fall
between two visits — interval censoring. A single likelihood
S(l) − S(u) covers every censoring type at once (right when u=∞, left
when l=0, interval, and exact via the density), fit from scratch by MLE and Bayesian
RW-Metropolis. This completes the censoring tour started with right-censored survival and the
Tobit: censoring is one idea — a probability mass over
the region the value is known to lie in. Applied to the classic mouse lung-tumour data (Hoel
& Walburg 1972; no exact onset times): germ-free mice have ~2.2× the tumour hazard, with a
careful competing-risks/longevity reading of the "germ-free puzzle." Cross-checked against PyMC
and R (survreg interval2, icenReg::ic_par).