ggcalibrate_original: The Original Calibration plot

View source: R/rap.R

ggcalibrate_originalR Documentation

The Original Calibration plot

Description

ggcalibrate_original plots the stats::predicted events against the actual event rate using the "old" form.

Usage

ggcalibrate_original(
  x1,
  x2 = NULL,
  y = NULL,
  n_cut = 5,
  cut_type = c("interval", "number", "width"),
  include_margin = FALSE
)

Arguments

x1

Either a logistic regression fitted using glm (base package) or lrm (rms package) or calculated probabilities (eg through a logistic regression model) of the baseline model. Must be between 0 & 1

x2

Either a logistic regression fitted using glm (base package) or lrm (rms package) or calculated probabilities (eg through a logistic regression model) of the new (alternative) model. Must be between 0 & 1

y

Binary of outcome of interest. Must be 0 or 1 (if fitted models are provided this is extracted from the fit which for an rms fit must have x = TRUE, y = TRUE).

n_cut

An integer indicating either the number of intervals of the same width, the number of intervals of the same number of subjects, or the width (as a percentage) of the intervals.

cut_type

One of three strings:

  • interval applies the cut_interval() function to get n_cut intervals of approximately equal width;

  • number applies the cut_number() function to get n_cut intervals of approximately equal number of subjects;

  • width applies the cut_width() function to get ~ 100/n_cut intervals of n_cut width.

include_margin

TRUE for including producing a bar plot of the counts of in each of the intervals. Default is FALSE. Note if the output is saved to my_graphs then using the library gridExtra the function grid.arrange(graphs$g, graphs$g_marg , nrow = 2, heights = c(2,1)) will produce a plot with both the calibration plot and the marginal plot.

Value

a list of one or two ggplots

Examples

## Not run: 
data(data_risk)
y<-data_risk$outcome 
x1<-data_risk$baseline
x2<-data_risk$new
#e.g.
output <- ggcalibrate(x1, x2 = NULL , y = NULL,  n_cut = 5, cut_type = "interval", include_margin = FALSE) 

## End(Not run)

JohnPickering/risk-assessment-plot-package documentation built on July 3, 2023, 8:41 a.m.