mixle.ppl.survival module¶
Censored and truncated maximum-likelihood fitting for the mixle PPL.
Survival / reliability / detection-limit data are partially observed: a subject still alive at the
end of a study, a component that had not failed, or a measurement below an instrument’s threshold are
all right-censored – we know only that the value exceeds some bound. Truncation is the dual:
the sample is drawn conditionally on lying in a window (values outside it are never seen). The ordinary
likelihood is wrong for both; this module fits a distribution’s free parameters under the correct one,
using each distribution’s cdf. It closes the censored-leaf gap (a capability Stan has and most PPLs
lack a clean surface for).
- censored_loglik(dist, time, *, event=None, lower=None, upper=None)[source]
Total log-likelihood of right-censored and/or truncated
timeunder a fitteddist.event[i]true (default all true) meanstime[i]is an observed event contributinglog f(time[i]); false means it is right-censored, contributing the log-survivallog(1 - F(time[i])).lower/uppertruncate the support: every point then also subtractslog(F(upper) - F(lower))(useNonefor an open end). Requiresdist.cdf.
- fit_censored(model, time, *, event=None, lower=None, upper=None, seed=0)[source]
Fit a distribution’s free parameters to right-censored and/or truncated data by ML.
modelis a flat PPL distribution withfreeparameter slots, e.g.Weibull(free, free)orExponential(free).timeare the (possibly censored) values;eventflags which are observed events vs right-censored (default all observed);lower/uppermark truncation of the sampling window. Maximizescensored_loglik()over the free slots (Nelder-Mead in the unconstrained space, respecting each slot’s positivity/unit support) and returns the fitted model as a boundRandomVariable(with.summary()).
- kaplan_meier(time, event=None)[source]
Kaplan-Meier nonparametric survival estimate
S(t)from right-censored data.Returns
{'time', 'survival', 'at_risk', 'events'}over the distinct event times – the standard model-free survival curve to plot against, or compare a fitted parametric model to.