Learn R Programming

wintime (version 0.2.0)

km: Fit a Kaplan-Meier model

Description

This function fits Kaplan-Meier models to calculate the state probabilities for each arm. In the wintime package, the returned state probability distributions are used in all non-pairwise methods. The Kaplan-Meier model is recommended for the Expected win time (EWT) method and the Restricted mean survival in favor of treatment (RMT) method.

Usage

km(n0, n1, m, Time, Delta)

Value

A list containing: a matrix of control arm state probabilities, a matrix of treatment arm state probabilities, a vector of unique control arm event times (days), a vector of unique treatment arm event times (days), the number of unique control arm event times, the number of unique treatment arm event times, the control arm max follow time (days), the treatment arm max follow time (days).

Arguments

n0

The number of participants in the control arm.

n1

The number of participants in the treatment arm.

m

The number of events in the hierarchy.

Time

A m x (n0 + n1) matrix of event times (days). Rows should represent events and columns should represent participants. Event rows should be in increasing order of clinical severity.

Delta

A m x (n0 + n1) matrix of event indicators. Rows should represent events and columns should represent participants. Event rows should be in increasing order of clinical severity.

Examples

Run this code
# -----------------------------
# Example inputs
# -----------------------------

# Event time vectors
TIME_1 <- c(256,44,29,186,29,80,11,380,102,33)
TIME_2 <- c(128,44,95,186,69,66,153,380,117,33)
TIME_3 <- c(435,44,95,186,69,270,1063,380,117,33)

# Event time matrix
Time <- rbind(TIME_1, TIME_2, TIME_3)

# Event indicator vectors
DELTA_1 <- c(1,0,1,0,1,1,1,0,1,0)
DELTA_2 <- c(1,0,0,0,0,1,1,0,0,0)
DELTA_3 <- c(0,0,0,0,0,0,0,0,0,0)

# Event indicator matrix
Delta <- rbind(DELTA_1, DELTA_2, DELTA_3)

# Treatment arm indicator vector
trt <- c(1,1,1,1,1,0,0,0,0,0)

# Number of control arm patients
n0 <- sum(trt == 0)

# Number of treatment arm patients
n1 <- sum(trt == 1)

# Number of events in the hierarchy
m <- nrow(Time)

# ------------------------
# km Examples
# ------------------------

z <- km(n0, n1, m, Time, Delta)
print(z)

Run the code above in your browser using DataLab