比较治疗组和对照组的生存率
用 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 -> "Helvetica"], Style["药物与安慰剂", FontSize -> 14, Bold, FontFamily -> "Helvetica", FontColor -> Gray]}], {{Top, Left}}]格翰氏(Gehan)加权 LogRankTest 和绘图结果相一致,都表明两组的风险率存在明显的差异:
LogRankTest[{trt, ctr}, "Gehan", "TestDataTable"]