plot.pmcalibration | R Documentation |
Plot a pmcalibration
object. For binary outcomes, also plot the distribution of predicted risks by outcome.
Alternatively you can use get_curve()
to get the data required to plot the calibration curve.
## S3 method for class 'pmcalibration'
plot(
x,
conf_level = 0.95,
riskdist = TRUE,
linecol = "black",
fillcol = "grey",
ideallty = 2,
idealcol = "red",
...
)
x |
a |
conf_level |
width of the confidence interval (0.95 gives 95% CI). Ignored if call to |
riskdist |
add risk distribution plot under calibration curve (TRUE) or not (FALSE) |
linecol |
color of the calibration curve line |
fillcol |
color of the confidence interval |
ideallty |
line type of the ideal unit slope line |
idealcol |
color of the ideal unit slope line |
... |
other args for |
No return value, called for side effects
library(pmcalibration)
# simulate some data with a binary outcome
n <- 500
dat <- sim_dat(N = n, a1 = .5, a3 = .2)
head(dat)
# predictions
p <- with(dat, invlogit(.5 + x1 + x2 + x1*x2*.1))
# fit calibration curve
cal <- pmcalibration(y = dat$y, p = p, smooth = "gam", k = 20, ci = "pw", plot = FALSE)
plot(cal, xlab = "Predicted Risk of Outcome") # customize plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.