public void KaplanMeierTest()
{
double[,] data =
{
// time censor
{ 1, 0 }, // died at time 1
{ 2, 1 }, // lost at time 2
{ 3, 0 }, // died at time 3
{ 5, 0 }, // died at time 5
{ 7, 1 }, // lost at time 7
{ 11, 0 }, // ...
{ 4, 0 },
{ 6, 0 },
{ 8, 0 },
{ 9, 1 },
{ 10, 1 },
};
double[] time = data.GetColumn(0);
int[] censor = data.GetColumn(1).ToInt32();
var regression = new ProportionalHazards(inputs: 0);
var target = new ProportionalHazardsNewtonRaphson(regression)
{
Estimator = HazardEstimator.KaplanMeier
};
double error = target.Run(time, censor);
Assert.AreEqual(-5.7037824746562009, error);
}
}