plot.calib_mlr: Plots calibration scatter plots for objects of class...

View source: R/plot_calib.R

plot.calib_mlrR Documentation

Plots calibration scatter plots for objects of class calib_mlr estimated using using calib_msm.

Description

Plots calibration scatter plots for the transition probabilities of a multistate model estimated using the MLR-IPCW approach.

Usage

## S3 method for class 'calib_mlr'
plot(
  x,
  ...,
  combine = TRUE,
  ncol = NULL,
  nrow = NULL,
  size.point = 0.5,
  size.text = 12,
  transparency.plot = 0.25,
  marg.density = FALSE,
  marg.density.size = 5,
  marg.density.type = "density",
  marg.rug = FALSE,
  marg.rug.transparency = 0.1,
  titles.include = TRUE,
  titles = NULL,
  axis.titles.x = NULL,
  axis.titles.text.x = "Predicted risk",
  axis.titles.y = NULL,
  axis.titles.text.y = "Observed risk"
)

Arguments

x

Object of class calib_mlr generated from calib_msm

...

Other

combine

Whether to combine into one plot using ggarrange, or return as a list of individual plots

ncol

Number of columns for combined calibration plot

nrow

Number of rows for combined calibration plot

size.point

Size of points in scatter plot

size.text

Size of text in plot

transparency.plot

Degree of transparency for points in the calibration scatter plot

marg.density

Whether to produce marginal density plots TRUE/FALSE

marg.density.size

Size of the main plot relative to the density plots (see ggMarginal)

marg.density.type

What type of marginal plot to show (see ggMarginal)

marg.rug

Whether to produce marginal rug plots TRUE/FALSE

marg.rug.transparency

Degree of transparency for the density rug plot along each axis

titles.include

Whether to include titles for each individual calibration plots

titles

Vector of titles for the calibration plots. Defaults to "State k" for each plot.

axis.titles.x

Position of plots for which to include title on x-axis

axis.titles.text.x

x-axis title

axis.titles.y

Position of plots for which to include title on y-axis

axis.titles.text.y

y-axis title

Value

If combine = TRUE, returns an object of classes gg, ggplot, and ggarrange, as all ggplots have been combined into one object. If combine = FALSE, returns an object of class list, each element containing an object of class gg and ggplot.

Examples

# Using competing risks data out of initial state (see vignette: ... -in-competing-risk-setting).
# Estimate and plot MLR-IPCW calibration scatter plots for the predicted transition
# probabilities at time t = 1826, when predictions were made at time
# s = 0 in state j = 1. These predicted transition probabilities are stored in tp.cmprsk.j0.

# To minimise example time we reduce the datasets to 150 individuals.
# Extract the predicted transition probabilities out of state j = 1 for first 150 individuals
tp.pred <- tp.cmprsk.j0 |>
 dplyr::filter(id %in% 1:150) |>
 dplyr::select(any_of(paste("pstate", 1:6, sep = "")))
# Reduce ebmtcal to first 150 individuals
ebmtcal <- ebmtcal |> dplyr::filter(id %in% 1:150)
# Reduce msebmtcal.cmprsk to first 150 individuals
msebmtcal.cmprsk <- msebmtcal.cmprsk |> dplyr::filter(id %in% 1:150)

# Now estimate the observed event probabilities for each possible transition.
dat.calib <-
calib_msm(data.ms = msebmtcal.cmprsk,
 data.raw = ebmtcal,
 j=1,
 s=0,
 t = 1826,
 tp.pred = tp.pred,
 calib.type = "mlr",
 w.covs = c("year", "agecl", "proph", "match"),
 mlr.ps.int = 2,
 mlr.degree = 2)

 # These are then plotted
 plot(dat.calib, combine = TRUE, nrow = 2, ncol = 3)


calibmsm documentation built on June 22, 2024, 9:33 a.m.