Accord.Tests.Statistics.EmpiricalHazardDistributionTest.LeukemiaExampleCensoring_KaplanMeier_NelsonAalen C# (CSharp) Method

LeukemiaExampleCensoring_KaplanMeier_NelsonAalen() private method

private LeukemiaExampleCensoring_KaplanMeier_NelsonAalen ( ) : void
return void
        public void LeukemiaExampleCensoring_KaplanMeier_NelsonAalen()
        {
            // http://www-personal.umich.edu/~yili/lect2notes.pdf
            // 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 = EmpiricalHazardDistribution.Estimate(t, c,
                SurvivalEstimator.KaplanMeier, HazardEstimator.BreslowNelsonAalen);

            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.02);
            }
        }