Fit Nonparametric Distributions to Survival Data
Fit Nonparametric Distributions to Survival Data
Any of the nonparametric distributions can be fit directly to censored and truncated data.
𝒟 = EventData[{10, 11, 12, 13, 14, 15, 16, 17, 18}, {{4, 0, 0}, {12, 0, 0}, {19, 2, 0}, {24, 15, 1}, {20, 24, 2}, {13, 18, 3}, {3, 14, 2}, {1, 6, 3}, {0, 4, 1}}];edist = EmpiricalDistribution[𝒟];
hdist = HistogramDistribution[𝒟, {.8}];
sdist = SmoothKernelDistribution[𝒟, .3];
kdist = KernelMixtureDistribution[𝒟];
Mean /@ {edist, hdist, sdist, kdist}Cumulative hazard estimates for the doubly censored EventData:
npd = {EmpiricalDistribution, HistogramDistribution, SmoothKernelDistribution, KernelMixtureDistribution};
dists = Table[If[i === HistogramDistribution, i[𝒟, {.8}], If[i === SmoothKernelDistribution, i[𝒟, .3], i[𝒟]]], {i, npd}];
col = ColorData[32, "ColorList"][[-4 ;; -1]];Grid[Partition[Table[Labeled[Plot[-Log[SurvivalFunction[dists[[i]], t]], {t, 10, 18}, Exclusions -> None, Filling -> Axis, Background -> White, PlotStyle -> {Thick, Darker@col[[i]]}, FillingStyle -> Lighter@col[[i]], PlotRange -> {0, 1.5}, ImageSize -> 200, Frame -> True, FrameTicks -> None], Style[npd[[i]], Bold, FontSize -> 15, FontFamily -> "Helvetica"]], {i, 4}], 2]]