Survival logrank - CyrilB1531/lodestar GitHub Wiki
Home āŗ Survival āŗ Survival estimators
LogRank
The log-rank family: two groups or more, weighted, pairwise.
public static class LogRank
Example ā Freireich's two arms, which is what the test was published to compare.
using Lodestar.Survival;
double[] treatment = [6, 6, 6, 7, 10, 13, 16, 22, 23, 6, 9, 10, 11, 17, 19, 20, 25, 32, 32, 34, 35];
bool[] treatmentObserved = [true, true, true, true, true, true, true, true, true,
false, false, false, false, false, false, false, false, false, false, false, false];
double[] control = [1, 1, 2, 2, 3, 4, 4, 5, 5, 8, 8, 8, 8, 11, 11, 12, 12, 15, 17, 22, 23];
bool[] controlObserved = [true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true, true, true];
LogRankResult result = LogRank.Test(treatment, treatmentObserved, control, controlObserved);
double statistic = result.Statistic; // => 16.79ā¦
double p = result.PValue; // => 4.168ā¦
Remarks ā at each time carrying an event in either arm, the first group's observed events are compared against what the pooled risk sets would give it. The statistic is the squared total difference over the summed variance, so it is never negative and is zero when the two curves agree step for step.
Ties are handled by the hypergeometric variance, not by an approximation of it. With one event
at a time it reduces to the familiar nānā/n²; with several it carries the (n - d) / (n - 1)
factor that a naive implementation drops, and that factor is what makes a heavily tied comparison
come out at the reference's number.
Its p-value is the published chi-squared tail, not a second one:
Distributions.ChiSquaredSf on one degree of
freedom. Decision 0003
published that member for this call rather than let a second far-tail approximation into the tree,
and a test asserts the two routes agree.
A time that only censors, or a time where one subject remains, contributes nothing: the hypergeometric variance is zero there and the term carries no information. Where no time compares both groups at all, the result is a statistic of zero and a p-value of one ā there is nothing to reject rather than an error to raise.
The weightings, the truncation and the subject weights are LogRankOptions
and the weighted overloads: Wilcoxon, Tarone-Ware, Peto and Fleming-Harrington weigh each time before
it is summed, and a truncation censors every event past it.
Reference behaviour is lifelines.statistics 0.30.3 ā logrank_test, multivariate_logrank_test
and pairwise_logrank_test ā matched under every weighting, with and without subject weights.
Applies to ā net10.0, netstandard2.0.
See also ā the estimators index, KaplanMeier.
Members
| Member | What it does |
|---|---|
LogRank.MultiGroup |
Compares several groups at once. |
LogRank.Pairwise |
Runs the two-sample test on every pair of groups. |
LogRank.Test |
Compares the survival of two right-censored samples, under any weighting. |