public void LeukemiaExampleCensoring_KaplanMeier_FlemingHarrington()
{
// The following are times of remission (weeks) for 21 leukemia
// patients receiving control treatment (Table 1.1 of Cox & Oakes):
double[] t = { 6, 6, 6, 6, 7, 9, 10, 10, 11, 13, 16, 17, 19, 20, 22, 23, 25, 32, 32, 34, 35 };
int[] c = { 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 };
var distribution = new EmpiricalHazardDistribution(SurvivalEstimator.FlemingHarrington);
distribution.Fit(t, new SurvivalOptions { Outcome = c.To<SurvivalOutcome[]>() });
int[] intervals = { 6, 7, 9, 10, 11, 13, 16, 17, 19, 20, 22, 23, 25, 32, 34, 35 };
double[] expected =
{
0.8571 , 0.8067, 0.8067, 0.7529, 0.7529, 0.6902,
0.6275, 0.6275, 0.6275, 0.6275, 0.5378, 0.4482,
0.4482, 0.4482, 0.4482, 0.4482
};
for (int i = 0; i < intervals.Length; i++)
{
double x = intervals[i];
double actual = distribution.ComplementaryDistributionFunction(x);
double e = expected[i];
Assert.AreEqual(e, actual, 0.1);
}
}