plotCalibration {riskRegression} | R Documentation |
Plot Calibration curve
Description
Plot Calibration curves for risk prediction models
Usage
plotCalibration(
x,
models,
times,
method = "nne",
cens.method,
round = TRUE,
bandwidth = NULL,
q = 10,
bars = FALSE,
hanging = FALSE,
names = "quantiles",
pseudo = FALSE,
rug,
show.frequencies = FALSE,
plot = TRUE,
add = FALSE,
diag = !add,
legend = !add,
auc.in.legend,
brier.in.legend,
axes = !add,
xlim = c(0, 1),
ylim = c(0, 1),
xlab = ifelse(bars, "Risk groups", "Predicted risk"),
ylab,
col,
lwd,
lty,
pch,
type,
percent = TRUE,
na.action = na.fail,
cex = 1,
...
)
Arguments
x |
Object obtained with function |
models |
Choice of models to plot |
times |
Time point specifying the prediction horizon. |
method |
The method for estimating the calibration curve(s):
|
cens.method |
For right censored data only. How observed proportions are calculated. Either
|
round |
If |
bandwidth |
The bandwidth for |
q |
The number of quantiles for |
bars |
If |
hanging |
Barplots only. If |
names |
Barplots only. Names argument passed to
|
pseudo |
If |
rug |
If |
show.frequencies |
Barplots only. If |
plot |
If |
add |
If |
diag |
If |
legend |
Logical. If |
auc.in.legend |
Logical. If |
brier.in.legend |
Logical. If |
axes |
If |
xlim |
Limits of x-axis. |
ylim |
Limits of y-axis. |
xlab |
Label for y-axis. |
ylab |
Label for x-axis. |
col |
Vector with colors, one for each element of
object. Passed to |
lwd |
Vector with line widths, one for each element of
object. Passed to |
lty |
lwd Vector with line style, one for each element of
object. Passed to |
pch |
Passed to |
type |
Passed to |
percent |
If TRUE axes labels are multiplied by 100 and thus interpretable on a percent scale. |
na.action |
what to do with NA values. Passed to
|
cex |
Default cex used for legend and labels. |
... |
Used to control the subroutines: plot, axis, lines,
barplot, legend, addtable2plot, points (pseudo values), rug. See
|
Details
In uncensored data, the observed frequency of the outcome event is calculated locally at the predicted risk. In right censored data with and without competing risks, the actual risk is calculated using the Kaplan-Meier and the Aalen-Johansen method, respectively, locally at the predicted risk.
Examples
library(prodlim)
# binary
set.seed(10)
db=sampleData(100,outcome="binary")
fb1=glm(Y~X1+X5+X7,data=db,family="binomial")
fb2=glm(Y~X1+X3+X6+X7,data=db,family="binomial")
xb=Score(list(model1=fb1,model2=fb2),Y~1,data=db,
plots="cal")
plotCalibration(xb,brier.in.legend=TRUE)
plotCalibration(xb,bars=TRUE,model="model1")
plotCalibration(xb,models=1,bars=TRUE,names.cex=1.3)
# survival
library(survival)
library(prodlim)
dslearn=sampleData(56,outcome="survival")
dstest=sampleData(100,outcome="survival")
fs1=coxph(Surv(time,event)~X1+X5+X7,data=dslearn,x=1)
fs2=coxph(Surv(time,event)~strata(X1)+X3+X6+X7,data=dslearn,x=1)
xs=Score(list(Cox1=fs1,Cox2=fs2),Surv(time,event)~1,data=dstest,
plots="cal",metrics=NULL)
plotCalibration(xs)
plotCalibration(xs,cens.method="local",pseudo=1)
plotCalibration(xs,method="quantile")
# competing risks
## Not run:
data(Melanoma)
f1 <- CSC(Hist(time,status)~age+sex+epicel+ulcer,data=Melanoma)
f2 <- CSC(Hist(time,status)~age+sex+logthick+epicel+ulcer,data=Melanoma)
x <- Score(list(model1=f1,model2=f2),Hist(time,status)~1,data=Melanoma,
cause= 2,times=5*365.25,plots="cal")
plotCalibration(x)
## End(Not run)