Description Usage Arguments Examples
Same as predictCox except that the survival is estimated using the product limit estimator.
1 2 |
object |
The fitted Cox regression model object either
obtained with |
times |
[numeric vector] Time points at which to return the estimated hazard/cumulative hazard/survival. |
newdata |
[data.frame or data.table] Contain the values of the predictor variables
defining subject specific predictions.
Should have the same structure as the data set used to fit the |
type |
[character vector] the type of predicted value. Choices are
Several choices can be
combined in a vector of strings that match (no matter the case)
strings |
keep.strata |
[logical] If |
keep.infoVar |
[logical] For internal use. |
... |
additional arguments to be passed to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | library(survival)
#### generate data ####
set.seed(10)
d <- sampleData(40,outcome="survival")
nd <- sampleData(4,outcome="survival")
d$time <- round(d$time,1)
#### Cox model ####
fit <- coxph(Surv(time,event)~ X1 + X2 + X6,
data=d, ties="breslow", x = TRUE, y = TRUE)
## exponential approximation
predictCox(fit, newdata = d, times = 1:5)
## product limit
predictCoxPL(fit, newdata = d, times = 1:5)
#### stratified Cox model ####
fitS <- coxph(Surv(time,event)~ X1 + strata(X2) + X6,
data=d, ties="breslow", x = TRUE, y = TRUE)
## exponential approximation
predictCox(fitS, newdata = d, times = 1:5)
## product limit
predictCoxPL(fitS, newdata = d, times = 1:5)
#### fully stratified Cox model ####
fitS <- coxph(Surv(time,event)~ 1,
data=d, ties="breslow", x = TRUE, y = TRUE)
## product limit
GS <- survfit(Surv(time,event)~1, data = d)
range(predictCoxPL(fitS)$survival - GS$surv)
fitS <- coxph(Surv(time,event)~ strata(X2),
data=d, ties="breslow", x = TRUE, y = TRUE)
## product limit
GS <- survfit(Surv(time,event)~X2, data = d)
range(predictCoxPL(fitS)$survival - GS$surv)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.