治療群と対照群の生存率を比べる
SurvivalModelFitを使って,治療群と対照群の信頼帯と生存曲線を視覚的に比べる.
trt = EventData[{10, 7, 32, 23, 22, 6, 16, 34, 32, 25, 11, 20, 19, 6, 17, 35, 6, 13, 9, 6, 10}, {0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1}];
ctr = EventData[{1, 22, 3, 12, 8, 17, 2, 11, 8, 12, 2, 5, 4, 15, 8, 23, 5, 11, 4, 1, 8}];mods = SurvivalModelFit[#, ConfidenceLevel -> .7]& /@ {trt, ctr};
p1 = Plot[{If[6 < t < 35, 1, Indeterminate]mods[[1]][t], If[1 < t < 23, 1, Indeterminate]mods[[2]][t]}, {t, 0, 35}, PlotStyle -> {{Thick, Darker@Red}, {Thick, Darker@Blue}}];
p2 = Plot[{mods[[1]]["UpperPointwiseBand"][t], mods[[1]]["LowerPointwiseBand"][t]}, {t, 0, 35}, PlotStyle -> Directive[Opacity[.3], Red], Filling -> {1 -> {{2}, Directive[Opacity[.1], Red]}}, PlotPoints -> 500, Exclusions -> mods[[1]]["EstimationPoints"]];
p3 = Plot[{mods[[2]]["UpperPointwiseBand"][t], mods[[2]]["LowerPointwiseBand"][t]}, {t, 0, 35}, PlotStyle -> Directive[Opacity[.3], Blue], Filling -> {1 -> {{2}, Directive[Opacity[.1], Blue]}}, PlotPoints -> 500, Exclusions -> mods[[2]]["EstimationPoints"]];
Labeled[Legended[Show[p1, p2, p3, ImageSize -> 450, GridLines -> Automatic, GridLinesStyle -> Dotted, PlotRange -> {0, 1}], Placed[LineLegend[{Directive@{Thick, Darker@Red}, Directive@{Thick, Darker@Blue}}, Style[#, Bold, FontFamily -> "Helvetica"]& /@ {"治療群", "対照群"}, LegendLayout -> "Row"], Bottom]], Column[{Style["臨床試験結果", FontSize -> 18, Bold, FontFamily -> "Times"], Style["薬品とプラシーボ", FontSize -> 14, Bold, FontFamily -> "Times", FontColor -> Gray]}], {{Top, Left}}]Gehanの重み付きLogRankTestは,ハザード率に有意な差異があるという視覚に同意する:
LogRankTest[{trt, ctr}, "Gehan", "TestDataTable"]