Learn R Programming

survMisc (version 0.4.6)

as.Surv: Convert time and status to a right-censored survival object, ordered by time

Description

Convert time and status to a right-censored survival object, ordered by time

Usage

as.Surv(ti, st)

Arguments

ti
Vector of time points
st
Vector of status (e.g. death) at time points

Value

  • An object of class Surv.

Details

A traditional Surv object will only allow discrete events, i.e. status $s \in N$. Typically, $s \in {0,1}$. There may be times when allowing non-binary values is of interest, e.g. in constructing expected survival. Caution is required when using this function with functions that assume binary values for status.

See Also

dx ?survival::Surv

Examples

Run this code
c1 <- coxph(formula = Surv(time, status == 2) ~ age + log(bili), data=pbc)
E <- predict(c1, type="expected")
as.Surv(pbc$time, E)
summary(coxph(as.Surv(pbc$time, E) ~ log(pbc$bili)))
### Warning:
### In Surv(stime, sstat) : Invalid status value, converted to NA

Run the code above in your browser using DataLab