Learn R Programming

riskRegression (version 1.4.3)

CoxFormula: Extract the formula from a Cox model

Description

Extract the formula from a Cox model

Usage

CoxFormula(object)

# S3 method for cph CoxFormula(object)

# S3 method for coxph CoxFormula(object)

# S3 method for phreg CoxFormula(object)

Arguments

object

The fitted Cox regression model object either obtained with coxph (survival package), cph (rms package), or phreg (mets package).

Examples

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

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

##
library(rms)
f <- Surv(time, event) ~ X1+X2
mCox <- cph(f, data = d, y = TRUE)
CoxFormula(mCox)
# }

Run the code above in your browser using DataLab