calcurve {ems}R Documentation

Calibration Curve

Description

calcurve function returns a data.frame containing the number of patients, the observed mortality rate and the predicted mortality rate for each category of the predicted mortality rate. If any other acute physiology score is given, the function will also return the mortality rate predicted by this score for each category.

Usage

calcurve(
  deaths,
  pred,
  score = NULL,
  name_score = "Saps3",
  other_score = NULL,
  name_other_score = NULL,
  categories_option = c("predicted", "score", "patients"),
  table = FALSE,
  plot = TRUE,
  title_label = "Calibration Curve",
  y1axis_label = "Patients (n)",
  y2axis_label = "Mortality Rate (%)",
  score_color = c("#cac7cc", "#ffc341", "#33cca3"),
  bar_color = "#1f77b4",
  points = c(19, 18, 17),
  cultureCode = "en-US",
  legend_inset = -0.7
)

## S3 method for class 'calcurve'
print(x, ...)

## S3 method for class 'calcurve'
plot(
  x,
  ...,
  xlab = NULL,
  ylab2 = NULL,
  main = x$title_label,
  text = x$y2axis_label,
  ylab = x$y1axis_label,
  col = c(x$bar_color, x$score_color),
  pch = x$points,
  cultureCode = x$cultureCode,
  legend_inset = x$legend_inset
)

Arguments

deaths

a numerical vector that only contains 0 and 1, indicating whether the patient was alive or dead, respectively.

pred

a numerical vector that contains the mortality rate predicted by the main score, in percentage, for each patient.

score

a numerical vector that contains the main score punctuation for each patient, or NULL.

name_score

a character string which determines the name of the main score.

other_score

a list of numerical vectors, where each vector contains the mortality rate predicted by other score, in percentage, for each patient, or NULL (the default).

name_other_score

if other_score variable is different from NULL, this argument must be a vector with the name(s) of the score(s) given.

categories_option

a character string which determines if the categories will refer to the main score or to the predicted mortality rate. Accepted values are 'predicted' (the default), 'score' or 'patients'.

table

logical; if TRUE prints the data.frame.

plot

logical; if TRUE (the default) plots the categories chosen versus the mortality rates in the secondary vertical axis. The main vertical axis refers to the number of patients in each category, represented by the bars.

title_label

main title for calcurve.

y1axis_label, y2axis_label

labels of the main vertical axis and the secondary axis, respectively, for calcurve.

score_color

a vector with the colors to be used in the score traces for calcurve.

bar_color

color of the bars for calcurve.

points

a vector with markers types of the scores for calcurve.

cultureCode

a character specifying which language should be used for plot x axis title and legends. Possible values are 'pt-BR' and 'en-US'. The default is 'en-US'.

legend_inset

inset distance(s) from the margins as a fraction of the plot region when legend is placed by keyword. See legend.

x

an object of class 'calcurve'.

...

further arguments passed to plot.

xlab

label of the horizontal axis for plot.calcurve, defaults to NULL.

ylab2

label of the secondary vertical axis for plot.calcurve, defaults to NULL.

main

main title for plot.calcurve.

text

label of the secondary vertical axis for plot.calcurve.

ylab

label of the main vertical axis for plot.calcurve.

col

character vector with the colors of the bars and score traces, in this order, for plot.calcurve.

pch

a vector with markers types of the scores for plot.curve.

Details

Author(s)

Camila Cardoso

Examples



# Loading the dataset
data(icu)

# Calibration Curve Plot
a <- calcurve(deaths = icu$UnitDischargeName,
pred = icu$Saps3DeathProbabilityStandardEquation,
score = icu$Saps3Points, name_score = 'Saps3',
categories_option = 'predicted', table = FALSE, plot = TRUE)



[Package ems version 1.3.11 Index]