model.matrix.coxph {survival} | R Documentation |
Reconstruct the model matrix for a cox model.
## S3 method for class 'coxph': model.matrix(object, data, contrast.arg = object$contrasts, ...)
object |
the result of a coxph model |
data |
optional, a data frame from which to obtain the data |
contrast.arg |
optional, a contrasts object describing how factors should be coded |
... |
other possible argument to model.frame |
for details see the documentation of the generic method.
The model matrix for the fit
Terry Therneau
fit1 <- coxph(Surv(time, status) ~ age + factor(ph.ecog), data=lung) linear.predictor <- model.matrix(fit1) fit2 <- coxph(Surv(time, status) ~ age + factor(ph.ecog), data=lung, x=TRUE) all.equal(model.matrix(fit1), fit2$x)