# Which algorithm to compute p-value of logrank test with three or more groups is best?

There seem to be two different algorithms for comparing three or more survival curves using the logrank test.

Algorithm A. Found in books by Altman and Machin. Computed by GraphPad Prism. This method uses an algorithm that is easy to understand, computing chi-square from the discrepancy between observed and expected numbers of deaths (with df=# of groups minus 1). Basically:

Chi2 = SumForAllCurves[(Oi - Ei)^2 / Ei]


Algorithm B. Computed by SAS and SPSS and NCSS. Also computes chi-square (also with df=# groups minus 1), but using a more complicated equation. Basically:

    Chi2 = U'*(V^-1)*U, where
U, V - vector and covariance matrix defined at p.6 of the same pdf


Method A computes chi-square = 4.094; df = 2; P = 0.1291
Method B computes chi-square = 4.844; df = 2; P = 0.0888

Why the difference? Is one a simplification? Do they make different assumptions? Is one outmoded? (Note that both are variations of the logrank method that gives equal weight to deaths at any time. You can get different results by weighting deaths differently using Gehan-Wilcoxon, or Tarone-Ware or Peto-Peto..., but those choices don't explain the distinction I've seen.)

As far as I know, the simpler formula is known to be a conservative approximation of the more complicated version. In the classical Cox and Oakes "Analysis of Survival Data" book, chapter 7.7 describes the derivation of the log-rank test as a score test in the two-sample case, and shows how the simpler formula corresponds to using a different (larger) estimator of the information matrix. I assume that this argument would generalize to more than two samples.

If you want to see the derivation of the longer formula, it is quite straightforward, and is written out, for example, in the Klein and Moeschberger "Survival Analysis" textbook.

In summary, there is no doubt that the more complicated formula is the "correct" one, but is approximated by the easier-to-understand and compute-by-hand simpler formula.

• You begin with "as far as I know..." and end with "there is no doubt...". How sure are you? I'll wait until I hear from others to be sure... Sep 9, 2011 at 21:08
• It did turn out funny. I became more sure as I wrote the comment, and looked up the references :) Sep 14, 2011 at 12:50
• Thanks. In that case, why not edit your answer to delete "As far as I know,". With that phrase, it sounds like you wish to contribute to a discussion. Without it, it sounds like you answer the question. Sep 14, 2011 at 13:56

This amazingly complete handout about survival analysis (from Michael Vaeth, at the University of Aarhus) states on page 40:

"Some computer packages and text books use the name log rank test for a slightly different test statistic, namely: AltChi2 = (O1 - E1)^2/E1 + (O2 - E2)^2/E2. The alternative version of the log rank test is (slightly) conservative, since AltChi2 < Chi2 is always satisfied. The p value from the alternative test is therefore too large. If the data contain no tied event times the discrepancy is minimal, but the difference increases with the number of ties among the uncensored observations."

A lecture handout is not quite a book chapter or journal article, but he agrees that the simpler method is purely a calculation shortcut that gives a less accurate (more conservative, i.e. larger) P value.