LogrankA: Logrank Test for Aggregated Survival Data

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/LogrankA.R

Description

LogrankA provides a logrank test across unlimited groups with the possibility to input aggregated survival data.

Usage

1
LogrankA(surv, group, weight)

Arguments

surv

An object of type survival is expected as input argument surv. This object is generated with the function Surv of the package survival and holds information about the survival time and censoring status of each observation.

group

Argument group provides the group affiliation of each observation in the survival argument.

weight

The argument weight is optional. It specifies the number of occurrences for each value combination in an aggregated dataset. Expected is a non-negative numeric vector.

Details

The group and weight arguments must correspond to the entries in the surv argument. Therefore the group and weight vectors must be equal in length to the time and status columns in the survival object of surv

If the weight argument is not specified it is assumed that the input data is not aggregated.

More than a single group must be specified.

Value

p.chi2

P-value of chi-squared test of logrank test statistic.

df

Degrees of freedom used for chi-squared test.

LR

Value of logrank test statistic.

lr.parameter

Number of observations, observed events, expected events, (O-E)^2/E for each group.

In addition a short text summary of the logrank test is printed to the console.

Note

For an in-depth explanation of LogrankA please see the package vignette.

Author(s)

Jonas Richter-Dumke and Roland Rau

Maintainer: Jonas Richter-Dumke <jrd.r.project@gmail.com>

References

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.

See Also

Surv, survdiff

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
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)

Example output

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

LogrankA documentation built on May 2, 2019, 11:01 a.m.