Description Details Author(s) References See Also Examples
LogrankA
provides a logrank test across unlimited groups with the
possibility to input aggregated survival data.
Package: | LogrankA |
Type: | Package |
Version: | 1.0 |
Date: | 2013-07-15 |
License: | GPL-2 |
The package contains the function LogrankA
.
Jonas Richter-Dumke and Roland Rau
Maintainer: Jonas Richter-Dumke <jrd.r.project@gmail.com>
Peto, R. et al. (1977). "Design and analysis of randomized clinical trials requiring prolonged observation of each patient". II. analysis and examples. In: British journal of cancer 35.1, pp. 1-39.
Ziegler, A., S. Lange, and R. Bender (2007). "Ueberlebenszeitanalyse: Der Log-Rang-Test". In: Deutsche Medizinische Wochenschrift 132, pp. 39-41.
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 | library(survival)
library(MASS)
## data: survival of australian aids patients (individual and aggregated)
aids2.ind <- Aids2 # import australian aids data
aids2.ind$status <- as.numeric(aids2.ind$status) - 1 # recode status to 0/1
stime.days <- aids2.ind$death - aids2.ind$diag # generate survival time in weeks
aids2.ind$stime <- round(stime.days / 7, 0)
aids2.ind$agegr <- cut(aids2.ind$age, # generate age groups
c(0, 20, 40, 60, 100), right = FALSE)
aids2.ind <- aids2.ind[ , c(5, 8, 9)] # keep only important columns
aids2.aggr <- aggregate(aids2.ind$stime, # transform to aggregated data
by = list(aids2.ind$status, aids2.ind$stime,
aids2.ind$agegr),
FUN = length)
colnames(aids2.aggr) <- c("status", "stime", "agegr", "n")
# generate survival objects for individual and aggregated data
surv.ind <- Surv(aids2.ind$stime, aids2.ind$status)
surv.aggr <- Surv(aids2.aggr$stime, aids2.aggr$status)
## logrank test on individual and aggregated data
# logrank on individual data
LogrankA(surv = surv.ind,
group = aids2.ind$agegr)
# logrank on aggregated data
LogrankA(surv = surv.aggr,
group = aids2.aggr$agegr,
weight = aids2.aggr$n)
|
Valid observations: 2843
Dropped observations: 0
Logrank test statistic = 42.03813 on 3 degrees of freedom,
p = 3.93806e-09
$p.chi2
[1] 3.93806e-09
$df
[1] 3
$LR
[1] 42.03813
$lr.parameter
N Obs. events Exp. events (O-E)^2/E
[0,20) 39 24 24.02395 2.387355e-05
[20,40) 1727 1063 1145.09080 5.885036e+00
[40,60) 1000 616 563.62149 4.867644e+00
[60,100) 77 58 28.26376 3.128543e+01
Valid observations: 2843
Dropped observations: 0
Logrank test statistic = 42.03813 on 3 degrees of freedom,
p = 3.93806e-09
$p.chi2
[1] 3.93806e-09
$df
[1] 3
$LR
[1] 42.03813
$lr.parameter
N Obs. events Exp. events (O-E)^2/E
[0,20) 39 24 24.02395 2.387355e-05
[20,40) 1727 1063 1145.09080 5.885036e+00
[40,60) 1000 616 563.62149 4.867644e+00
[60,100) 77 58 28.26376 3.128543e+01
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.