View source: R/pcoxtimeplots.R
plot.Score | R Documentation |
Plots predictive performance of pcoxtime
in comparison to other models. It uses risk scoring from Score
. pcoxtime
also supports performance measure scoring by R package pec
. See examples.
## S3 method for class 'Score'
plot(x, ..., type = c("roc", "auc", "brier"), pos = 0.3)
x |
|
... |
for future implementations. |
type |
metric to return. Choices are |
pos |
spacing between the lines. |
Implements plot method for Score
for time-dependent Brier score, AUC and ROC. However, currently, no support for time-dependent covariate models.
a ggplot
object.
if (packageVersion("survival")>="3.2.9") {
data(cancer, package="survival")
} else {
data(veteran, package="survival")
}
# pcoxtime
lam <- 0.1
alp <- 1
pfit1 <- pcoxtime(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
, data = veteran
, lambda = lam
, alpha = alp
)
# coxph
cfit1 <- coxph(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
, data = veteran
, method = "breslow"
, x = TRUE
, y = TRUE
)
# Evaluate model performance at 90, 180, 365 time points
score_obj <- Score(list("coxph" = cfit1, "pcox" = pfit1)
, Surv(time, status) ~ 1
, data = veteran
, plots = "roc"
, metrics = c("auc", "brier")
, B = 10
, times = c(90, 180, 365)
)
# Plot AUC
plot(score_obj, type = "auc")
# Plot ROC
plot(score_obj, type = "roc")
# Plot brier
plot(score_obj, type = "brier")
# Prediction error using pec package
## Not run:
if (require("pec")) {
pec_fit <- pec(list("coxph" = cfit1, "pcox" = pfit1)
, Surv(time, status) ~ 1
, data = veteran
, splitMethod = "Boot632plus"
, keep.matrix = TRUE
)
plot(pec_fit)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.