Learn R Programming

riskRegression (version 1.4.3)

SurvResponseVar: Extract the time and event variable from a Cox model

Description

Extract the time and event variable from a Cox model

Usage

SurvResponseVar(formula)

Arguments

formula

a formula

Examples

Run this code
# NOT RUN {
d <- sampleData(1e2, outcome = "survival")
d$entry <- 0

##
library(survival)
mCox <- coxph(Surv(time, event) ~ X1+X2, data = d)
SurvResponseVar(mCox$formula)

mCox <- coxph(Surv(entry, time, event) ~ X1+X2, data = d)
SurvResponseVar(mCox$formula)

mCox <- coxph(Surv(event, time = entry, time2 = time) ~ X1+X2, data = d)
SurvResponseVar(mCox$formula)

mCox <- coxph(Surv(time, event) ~ 1, data = d)
SurvResponseVar(mCox$formula)

# }

Run the code above in your browser using DataLab