multi_lr: (Weighted) Log-rank test for comparison of two or more...

View source: R/multi_lr.R

multi_lrR Documentation

(Weighted) Log-rank test for comparison of two or more survival curves.

Description

Performs a global log-rank test for comparing two or more survival curves.

Usage

multi_lr(df, weights, test = c("lr", "gw", "fh"), rho = 1, gamma = 0)

Arguments

df

A data frame with columns :

  • time : positive numbers, time-to-event;

  • status : vector of integer, 0 or 1. 0 is (right) censoring, 1 is event;

  • arm : a factor or object that can be coerced to one. The group the patient belongs to. Must have at least two levels.

weights

An object that can be coerced to a matrix. The weights used for the tests. Can be omitted (see Details);

test

If weights is omitted, specify the test to perform. Possible values are lr for log-rank, gw for Gehan-Wilcoxon, and fh for Flemming-Harrington;

rho, gamma

The parameters for Flemming-Harrington test. Default is (rho,gamma)=(1,0), which is also called the Peto-Peto test.

Details

weights contains the chosen weights for the test. It must be a vector, a matrix or an object that can be coerced to a matrix, like a data frame (passed as argument to as.matrix). Can be omitted.

If not given (default), then perform either a log-rank test, a Gehan-Wilcoxon test or a Fleming-Harrington test depending on the choice of test.

If weights is a one-dimension vector, its length must be equal to the number of distinct time of event and throws an error if it is not true. In this case, multi_lr() performs a weighted log-rank test with the specified weights.

If weights is a matrix (or a two-dimension object), its number of rows must be equal to the number of distinct time of event and throws an error if it is not true. In this case, multi_lr() performs as many tests as the number of columns in weights. The first test is a weighted log-rank test with weights the first column of weights, the second test is a weighted log-rank test with weights the second column of weights, and so on.

Value

An object of class multi_lr containing:

  • U : Statistics of tests;

  • p : The corresponding p-values;

  • degree : Degrees of freedom of the statistics of tests;

  • The argument test, changed to "chosen" if weights are given.

Examples

  # Log-rank test
  multi_lr(data_not_PH)

  # Gehan-Wilcoxon test
  multi_lr(data_not_PH, test="gw")

  # It is possible to run several tests with different weights at a time
  evt_time = unique(data_not_PH$time[data_not_PH$status == 1])
  nb_evt_time = length(evt_time)
  weights = matrix(runif(nb_evt_time*3), ncol=3)
  multi_lr(data_not_PH, weights=weights)

MSCCT documentation built on Aug. 8, 2025, 6:26 p.m.