Learn R Programming

EMA (version 1.4.7)

km: Compute survival curves and test difference between the curves

Description

Computes and draw estimates of survival curves for censored data using Kaplan-Meier's method. In case of >=2 survival curves, use logrank test to assess the difference between the survival curves. Missing values are removed

Usage

km(time, status, group = NULL, xlab="Time (years)", ylab="", ...)

Arguments

time

numeric, this is the follow up time (used with right censored data)

status

The status indicator, normally 0=alive, 1=dead (numeric). Other choices are TRUE/FALSE (TRUE = death) or 1/2 (2=death)

group

indicates the group to which is assigned each observation (factor). For one groupe only (no comparison), group is set to null (default)

xlab

(optional): a character string, xlabel of the Kaplan Meier's plot

ylab

(optional): a character string, ylabel of the Kaplan Meier's plot

...

(optional): Additional graphical parameters

Value

A list with

fit.km

results provided by Kaplan Meier analysis. See the R help on survfit for details

lr

results provided by logrank analysis. See the R help on survdiff for details

p.lr

pvalue of the logrank test

See Also

survfit, survdiff

Examples

Run this code
# NOT RUN {
require(survival)
data(leukemia)
time<-leukemia$time
status<-leukemia$status
# One group
res<-km(time,status)
res$fit.km

# Two groups
group<-leukemia$x
res<-km(time,status,group)
res<-km(time,status,group,title="Kaplan Meier curve")
res<-km(time,status,group,title="Kaplan Meier curve",pdfname="My survival curve")
res<-km(time,status,group,pdfname="My survival curve",pdfwidth=11.69,pdfheight=8.27)
res$fit.km
names(res$fit.km)
res$lr
names(res$lr)
res$p.lr
# }

Run the code above in your browser using DataLab