View source: R/model_diagnostics.R
model_diagnostics | R Documentation |
This function calculates martingale and deviance residuals.
model_diagnostics(explainer)
## S3 method for class 'surv_explainer'
model_diagnostics(explainer)
explainer |
an explainer object - model preprocessed by the |
An object of class c("model_diagnostics_survival")
. It's a list with the explanations in the result
element.
library(survival)
library(survex)
cph <- coxph(Surv(time, status) ~ ., data = veteran, model = TRUE, x = TRUE, y = TRUE)
rsf_ranger <- ranger::ranger(Surv(time, status) ~ .,
data = veteran,
respect.unordered.factors = TRUE,
num.trees = 100,
mtry = 3,
max.depth = 5
)
cph_exp <- explain(cph)
rsf_ranger_exp <- explain(rsf_ranger,
data = veteran[, -c(3, 4)],
y = Surv(veteran$time, veteran$status)
)
cph_residuals <- model_diagnostics(cph_exp)
rsf_residuals <- model_diagnostics(rsf_ranger_exp)
head(cph_residuals$result)
plot(cph_residuals, rsf_residuals, xvariable = "age")
plot(cph_residuals, rsf_residuals, plot_type = "Cox-Snell")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.