comp: compare survival curves

Description Usage Arguments Details Value Note References Examples

View source: R/comp.R

Description

compare survival curves

Usage

1
2
3
4
5
comp(x, ...)

## S3 method for class 'ten'
comp(x, ..., p = 1, q = 1, scores = seq.int(attr(x, "ncg")),
  reCalc = FALSE)

Arguments

x

A tne object

p

p for Fleming-Harrington test

q

q for Fleming-Harrington test

scores

scores for tests for trend

...

Additional arguments (not implemented).

reCalc

Recalcuate the values?
If reCalc=FALSE (the default) and the ten object already has the calculated values stored as an attribute, the value of the attribute is returned directly.

Details

The log-rank tests are formed from the following elements, with values for each time where there is at least one event:

It is calculated as:

Q[i] = sum(W[i] * (e[i] - P[i]))^T * sum(W[i] * COV[, , i] * W[i])^-1 * sum(W[i] * (e[i] - P[i]))

If there are K groups, then K-1 are selected (arbitrary).
Likewise the corresponding variance-covariance matrix is reduced to the appropriate K-1 * K-1 dimensions.
Q is distributed as chi-square with K-1 degrees of freedom.

For 2 covariate groups, we can use:

Then:

Q = sum(W[i] * (e1[i] - n1[i] * e[i] / n[i])) / sqrt(sum(W[i]^2 * e1[i] / e[i] * (1 - n1[i] / n[i]) * (n[i] - e[i] / (n[i] - 1)) *e[i]))

Below, for the Fleming-Harrington weights, S(t) is the Kaplan-Meier (product-limit) estimator.
Note that both p and q need to be >=0.

The weights are given as follows:

1 log-rank
n[i] Gehan-Breslow generalized Wilcoxon
sqrt(n[i]) Tarone-Ware
S1[i] Peto-Peto's modified survival estimate S1(t) = cumprod(1 - e / (n + 1))
S2[i] modified Peto-Peto (by Andersen) S2(t) = S1[i] * n[i] / (n[i] + 1)
FH[i] Fleming-Harrington The weight at t_0 = 1 and thereafter is: S(t[i - 1])^p * (1 - S(t)[i - 1]^q)

The supremum (Renyi) family of tests are designed to detect differences in survival curves which cross.
That is, an early difference in survival in favor of one group is balanced by a later reversal.
The same weights as above are used.
They are calculated by finding

Z(t[i]) = SUM W(t[k]) [ e1[k] - n1[k]e[k]/n[k] ]

(which is similar to the numerator used to find Q in the log-rank test for 2 groups above).
and it's variance:

simga^2(tau) = sum(k=1, 2, ..., tau) W(t[k]) (n1[k] * n2[k] * (n[k] - e[k]) * e[k] / n[k]^2 * (n[k] - 1) ]

where tau is the largest t where both groups have at least one subject at risk.

Then calculate:

Q = sup( |Z(t)| ) / sigma(tau), t < tau

When the null hypothesis is true, the distribution of Q is approximately

Q ~ sup( |B(x)|, 0 <= x <= 1)

And for a standard Brownian motion (Wiener) process:

Pr[sup|B(t)| > x] = 1 - 4 / pi sum((-1)^k / (2 * k + 1) * exp(-pi^2 (2k + 1)^2 / x^2))

Tests for trend are designed to detect ordered differences in survival curves.
That is, for at least one group:

S1(t) >= S2(t) >= ... >= SK(t) for t <= tau

where tau is the largest t where all groups have at least one subject at risk. The null hypothesis is that

S1(t) = S2(t) = ... = SK(t) for t <= tau

Scores used to construct the test are typically s = 1,2,...,K, but may be given as a vector representing a numeric characteristic of the group.
They are calculated by finding:

Z[t(i)] = sum(W[t(i)] * (e[j](i) - n[j](i) * e(i) / n(i)))

The test statistic is:

Z = sum(j=1, ..., K) s[j] * Z[j] / sum(j=1, ..., K) sum(g=1, ..., K) s[j] * s[g] * sigma[jg]

where sigma is the the appropriate element in the variance-covariance matrix (see COV).
If ordering is present, the statistic Z will be greater than the upper alpha-th percentile of a standard normal distribution.

Value

The tne object is given additional attributes.
The following are always added:

lrt

The log-rank family of tests

lrw

The log-rank weights (used in calculating the tests).

An additional item depends on the number of covariate groups.
If this is =2:

sup

The supremum or Renyi family of tests

and if this is >2:

tft

Tests for trend. This is given as a list, with the statistics and the scores used.

Note

Regarding the Fleming-Harrington weights:

The example using alloauto data illustrates this. Here the log-rank statistic has a p-value of around 0.5 as the late advantage of allogenic transplants is offset by the high early mortality. However using Fleming-Harrington weights of p=0, q=0.5, emphasising differences later in time, gives a p-value of 0.04.
Stratified models (stratTen) are not yet supported.

References

Gehan A. A Generalized Wilcoxon Test for Comparing Arbitrarily Singly-Censored Samples. Biometrika 1965 Jun. 52(1/2):203–23. JSTOR

Tarone RE, Ware J 1977 On Distribution-Free Tests for Equality of Survival Distributions. Biometrika;64(1):156–60. JSTOR

Peto R, Peto J 1972 Asymptotically Efficient Rank Invariant Test Procedures. J Royal Statistical Society 135(2):186–207. JSTOR

Fleming TR, Harrington DP, O'Sullivan M 1987 Supremum Versions of the Log-Rank and Generalized Wilcoxon Statistics. J American Statistical Association 82(397):312–20. JSTOR

Billingsly P 1999 Convergence of Probability Measures. New York: John Wiley & Sons. Wiley (paywall)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Two covariate groups
data("leukemia", package="survival")
f1 <- survfit(Surv(time, status) ~ x, data=leukemia)
comp(ten(f1))
## K&M 2nd ed. Example 7.2, Table 7.2, pp 209--210.
data("kidney", package="KMsurv")
t1 <- ten(Surv(time=time, event=delta) ~ type, data=kidney)
comp(t1, p=c(0, 1, 1, 0.5, 0.5), q=c(1, 0, 1, 0.5, 2))
## see the weights used
attributes(t1)$lrw
## supremum (Renyi) test; two-sided; two covariate groups
## K&M 2nd ed. Example 7.9, pp 223--226.
data("gastric", package="survMisc")
g1 <- ten(Surv(time, event) ~ group, data=gastric)
comp(g1)
## Three covariate groups
## K&M 2nd ed. Example 7.4, pp 212-214.
data("bmt", package="KMsurv")
b1 <- ten(Surv(time=t2, event=d3) ~ group, data=bmt)
comp(b1, p=c(1, 0, 1), q=c(0, 1, 1))
## Tests for trend
## K&M 2nd ed. Example 7.6, pp 217-218.
data("larynx", package="KMsurv")
l1 <- ten(Surv(time, delta) ~ stage, data=larynx)
comp(l1)
attr(l1, "tft")
### see effect of F-H test
data("alloauto", package="KMsurv")
a1 <- ten(Surv(time, delta) ~ type, data=alloauto)
comp(a1, p=c(0, 1), q=c(1, 1))

Example output

Loading required package: survival
                   Q       Var      Z    pNorm  
1            3.68934   4.04897 1.8335 0.066731 .
n           50.00000 925.00000 1.6440 0.100178  
sqrtN       12.83792  55.81480 1.7184 0.085727 .
S1           2.10453   1.64882 1.6390 0.101222  
S2           1.95449   1.45827 1.6185 0.105553  
FH_p=1_q=1   0.45686   0.14587 1.1962 0.231616  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
             maxAbsZ       Var      Q  pSupBr
1            3.68934   4.04897 1.8335 0.13346
n           50.00000 925.00000 1.6440 0.20035
sqrtN       12.83792  55.81480 1.7184 0.17145
S1           2.10453   1.64882 1.6390 0.20244
S2           1.95449   1.45827 1.6185 0.21110
FH_p=1_q=1   0.45686   0.14587 1.1962 0.46257
                         Q         Var         Z     pNorm   
1              -3.9636e+00  6.2368e+00 -1.587104 0.1124892   
n               9.0000e+00  3.8919e+04  0.045621 0.9636127   
sqrtN          -1.3203e+01  4.3384e+02 -0.633875 0.5261626   
S1             -2.4692e+00  4.3725e+00 -1.180837 0.2376674   
S2             -2.3134e+00  4.2087e+00 -1.127672 0.2594583   
FH_p=0_q=1     -1.4134e+00  2.0778e-01 -3.100747 0.0019303 **
FH_p=1_q=0     -2.5501e+00  4.7072e+00 -1.175397 0.2398361   
FH_p=1_q=1     -1.0206e+00  1.0661e-01 -3.125846 0.0017729 **
FH_p=0.5_q=0.5 -2.4695e+00  6.6091e-01 -3.037697 0.0023839 **
FH_p=0.5_q=2   -3.2350e-01  1.2842e-02 -2.854717 0.0043075 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
                  maxAbsZ        Var      Q    pSupBr   
1              3.9636e+00 6.2368e+00 1.5871 0.2249746   
n              2.8200e+02 3.8919e+04 1.4294 0.3057172   
sqrtN          2.6224e+01 4.3384e+02 1.2590 0.4157260   
S1             2.4692e+00 4.3725e+00 1.1808 0.4745421   
S2             2.3134e+00 4.2087e+00 1.1277 0.5174828   
FH_p=0_q=1     1.4134e+00 2.0778e-01 3.1007 0.0038607 **
FH_p=1_q=0     2.5501e+00 4.7072e+00 1.1754 0.4788290   
FH_p=1_q=1     1.0206e+00 1.0661e-01 3.1258 0.0035459 **
FH_p=0.5_q=0.5 2.4695e+00 6.6091e-01 3.0377 0.0047679 **
FH_p=0.5_q=2   3.2350e-01 1.2842e-02 2.8547 0.0086150 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    1   n     sqrtN        S1        S2 FH_p=0_q=1 FH_p=1_q=0 FH_p=1_q=1
 1: 1 119 10.908712 0.9500000 0.9420833 0.00000000  1.0000000 0.00000000
 2: 1 103 10.148892 0.9408654 0.9318186 0.05042017  0.9495798 0.04787797
 3: 1  98  9.899495 0.9218580 0.9125463 0.05963939  0.9403606 0.05608253
 4: 1  89  9.433981 0.9013723 0.8913570 0.07883042  0.9211696 0.07261619
 5: 1  79  8.888194 0.8788380 0.8678525 0.09953086  0.9004691 0.08962447
 6: 1  73  8.544004 0.8669618 0.8552461 0.12232755  0.8776725 0.10736352
 7: 1  66  8.124038 0.8540220 0.8412754 0.13435046  0.8656495 0.11630041
 8: 1  55  7.416198 0.8235213 0.8088155 0.14746636  0.8525336 0.12572003
 9: 1  49  7.000000 0.8070508 0.7909098 0.17846759  0.8215324 0.14661691
10: 1  45  6.708204 0.7895063 0.7723431 0.19523355  0.8047664 0.15711741
11: 1  40  6.324555 0.7702500 0.7514634 0.21311725  0.7868827 0.16769829
12: 1  25  5.000000 0.7110000 0.6836538 0.23278932  0.7672107 0.17859845
13: 1  23  4.795832 0.6813750 0.6529844 0.29416617  0.7058338 0.20763244
14: 1  20  4.472136 0.6489286 0.6180272 0.32485460  0.6751454 0.21932409
15: 1   9  3.000000 0.5840357 0.5256321 0.35861187  0.6413881 0.23000940
16: 1   5  2.236068 0.4866964 0.4055804 0.42987722  0.5701228 0.24508280
    FH_p=0.5_q=0.5 FH_p=0.5_q=2    t
 1:      0.0000000  0.000000000  0.5
 2:      0.2188104  0.002477276  1.5
 3:      0.2368175  0.003449162  2.5
 4:      0.2694739  0.005964273  3.5
 5:      0.2993735  0.009400478  4.5
 6:      0.3276637  0.014018927  5.5
 7:      0.3410285  0.016793815  6.5
 8:      0.3545702  0.020078982  8.5
 9:      0.3829059  0.028868954  9.5
10:      0.3963804  0.034193523 10.5
11:      0.4095098  0.040289532 11.5
12:      0.4226091  0.047466086 15.5
13:      0.4556670  0.072700383 16.5
14:      0.4683205  0.086711501 18.5
15:      0.4795929  0.102993492 23.5
16:      0.4950584  0.139531756 26.5
                     Q         Var        Z    pNorm  
1           2.1463e+00  1.9862e+01  0.48159 0.630098  
n           4.9100e+02  6.0322e+04  1.99913 0.045594 *
sqrtN       4.3629e+01  9.8798e+02  1.38803 0.165129  
S1          5.4126e+00  7.2723e+00  2.00710 0.044739 *
S2          5.3864e+00  7.0411e+00  2.02993 0.042364 *
FH_p=1_q=1 -8.9383e-02  7.1790e-01 -0.10549 0.915985  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
              maxAbsZ        Var      Q    pSupBr   
1              9.8049    19.8617 2.2001 0.0556044 . 
n            725.0000 60322.4412 2.9519 0.0063169 **
sqrtN         84.1532   987.9774 2.6773 0.0148437 * 
S1             7.9752     7.2723 2.9574 0.0062054 **
S2             7.8688     7.0411 2.9654 0.0060450 **
FH_p=1_q=1     1.3396     0.7179 1.5811 0.2277168   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
             chiSq df     pChisq    
1          13.8037  2 0.00100591 ** 
n          16.2407  2 0.00029743 ***
sqrtN      15.6529  2 0.00039904 ***
S1         15.7260  2 0.00038472 ***
S2         15.7781  2 0.00037483 ***
FH_p=1_q=0 15.6725  2 0.00039515 ***
FH_p=0_q=1  6.1097  2 0.04713019 *  
FH_p=1_q=1  9.9331  2 0.00696710 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
$tft
                     Q         Var        Z    pNorm  
1             -10.6695     42.7801 -1.63127 0.102834  
n           -1294.0000 439987.8847 -1.95081 0.051080 .
sqrtN        -118.1769   4202.2583 -1.82302 0.068301 .
S1             -9.2667     23.2023 -1.92379 0.054380 .
S2             -9.1996     22.7588 -1.92839 0.053806 .
FH_p=1_q=0     -9.3529     23.6462 -1.92339 0.054432 .
FH_p=0_q=1     -1.3166      4.5757 -0.61551 0.538219  
FH_p=1_q=1     -1.0948      1.4957 -0.89516 0.370703  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

$scores
[1] 1 2 3

            chiSq df     pChisq    
1          22.763  3 4.5252e-05 ***
n          23.177  3 3.7093e-05 ***
sqrtN      23.141  3 3.7746e-05 ***
S1         23.171  3 3.7199e-05 ***
S2         23.170  3 3.7213e-05 ***
FH_p=1_q=1 16.661  3 0.00082967 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
$tft
                     Q         Var       Z      pNorm    
1             -25.8061     48.1505 -3.7190 0.00020005 ***
n           -1939.0000 210644.6590 -4.2248 2.3919e-05 ***
sqrtN        -221.9185   2990.6169 -4.0580 4.9493e-05 ***
S1            -21.3895     26.8311 -4.1293 3.6380e-05 ***
S2            -21.0942     26.0075 -4.1363 3.5292e-05 ***
FH_p=1_q=1     -2.9412      1.5056 -2.3970 0.01653027 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

$scores
[1] 1 2 3 4

$tft
                     Q         Var       Z      pNorm    
1             -25.8061     48.1505 -3.7190 0.00020005 ***
n           -1939.0000 210644.6590 -4.2248 2.3919e-05 ***
sqrtN        -221.9185   2990.6169 -4.0580 4.9493e-05 ***
S1            -21.3895     26.8311 -4.1293 3.6380e-05 ***
S2            -21.0942     26.0075 -4.1363 3.5292e-05 ***
FH_p=1_q=1     -2.9412      1.5056 -2.3970 0.01653027 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

$scores
[1] 1 2 3 4

                     Q         Var          Z    pNorm  
1           2.1698e+00  1.2353e+01  0.6173547 0.537001  
n          -8.1000e+01  6.7778e+04 -0.3111290 0.755703  
sqrtN       1.8488e+00  8.7383e+02  0.0625435 0.950130  
S1          1.4514e-02  7.0860e+00  0.0054524 0.995650  
S2         -6.8838e-02  6.8889e+00 -0.0262274 0.979076  
FH_p=0_q=1  2.0925e+00  1.0430e+00  2.0488836 0.040473 *
FH_p=1_q=1  1.0900e+00  4.0186e-01  1.7193838 0.085545 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
              maxAbsZ        Var      Q   pSupBr  
1          4.5493e+00 1.2353e+01 1.2944 0.390844  
n          4.1500e+02 6.7778e+04 1.5941 0.221844  
sqrtN      4.3433e+01 8.7383e+02 1.4693 0.283499  
S1         4.0680e+00 7.0860e+00 1.5282 0.252920  
S2         4.0239e+00 6.8889e+00 1.5331 0.250497  
FH_p=0_q=1 2.0925e+00 1.0430e+00 2.0489 0.080947 .
FH_p=1_q=1 1.0900e+00 4.0186e-01 1.7194 0.171089  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

survMisc documentation built on May 29, 2017, 3:50 p.m.