gg_bland_altman: Bland-Altman drawing function for R

View source: R/gg_blandAltman.r

gg_bland_altmanR Documentation

Bland-Altman drawing function for R

Description

Bland-Altman drawing function. Depends on the blandr.statistics function in the package. Will generate a plot via the standard R plotting functions.

Usage

gg_bland_altman(
  method1,
  method2,
  method1name = "Method 1",
  method2name = "Method 2",
  plotTitle = "Bland-Altman plot for comparison of 2 methods",
  sig.level = 0.95,
  LoA.mode = 1,
  ciDisplay = TRUE,
  ciShading = TRUE,
  ciFillColors = c("steelblue3", "gray85"),
  normalLow = FALSE,
  normalHigh = FALSE,
  lowest_y_axis = FALSE,
  highest_y_axis = FALSE,
  point_size = 0.8,
  overlapping = FALSE,
  x.plot.mode = "means",
  y.plot.mode = "difference",
  plotProportionalBias = FALSE,
  plotProportionalBias.se = TRUE,
  assume.differences.are.normal = TRUE
)

Arguments

method1

A list of numbers.

method2

A list of numbers.

method1name

(Optional) Plotting name for 1st method, default "Method 1"

method2name

(Optional) Plotting name for 2nd method, default "Method 2"

plotTitle

(Optional) Title name, default "Bland-Altman plot for comparison of 2 methods"

sig.level

(Optional) Two-tailed significance level. Expressed from 0 to 1. Defaults to 0.95.

LoA.mode

(Optional) Switch to change how accurately the limits of agreement (LoA) are calculated from the bias and its standard deviation. The default is LoA.mode=1 which calculates LoA with the more accurate 1.96x multiplier. LoA.mode=2 uses the 2x multiplier which was used in the original papers. This should really be kept at default, except to double check calculations in older papers.

ciDisplay

(Optional) TRUE/FALSE switch to plot confidence intervals for bias and limits of agreement, default is TRUE

ciShading

(Optional) TRUE/FALSE switch to plot confidence interval shading to plot, default is TRUE

ciFillColors

(Optional) 2-vector of colors to use in the bias shading and confidence band shading

normalLow

(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its lower boundary

normalHigh

(Optional) If there is a normal range, entering a continuous variable will plot a vertical line on the plot to indicate its higher boundary

lowest_y_axis

(Optional) Defaults to NULL If given a continuous variable will use this as the lower boundary of the y axis. Useful if need multiple plots with equivalent y-axes.

highest_y_axis

(Optional) Defaults to NULL If given a continuous variable will use this as the upper boundary of the y axis. Useful if need multiple plots with equivalent y-axes.

point_size

(Optional) Default = 0.8

overlapping

(Optional) TRUE/FALSE switch to increase size of plotted point if multiple values using ggplot's geom_count, deafault=FALSE. Not currently recommend until I can tweak the graphics to make them better

x.plot.mode

(Optional) Switch to change x-axis from being plotted by means (="means") or by either 1st method (="method1") or 2nd method (="method2"). Default is "means". Anything other than "means" will switch to default mode.

y.plot.mode

(Optional) Switch to change y-axis from being plotted by difference (="difference") or by proportion magnitude of measurements (="proportion"). Default is "difference". Anything other than "proportional" will switch to default mode.

plotProportionalBias

(Optional) TRUE/FALSE switch. Plots a proportional bias line. Default is FALSE.

plotProportionalBias.se

(Optional) TRUE/FALSE switch. If proportional bias line is drawn, switch to plot standard errors. See stat_smooth for details. Default is TRUE.

assume.differences.are.normal

(Optional, not operationally used currently) Assume the difference of means has a normal distribution. Will be used to build further analyses

Note

Started 2015-11-14

Last update 2015-11-19

Originally designed for LAVAS and CVLA

Author(s)

Deepankar Datta deepankardatta@nhs.net

Examples

# Generates two random measurements
measurement1 <- rnorm(100)
measurement2 <- rnorm(100)

# Generates a plot, with no optional arguments
gg_bland_altman(measurement1, measurement2)

adamleejohnson/R-ajtools documentation built on April 4, 2022, 7:24 a.m.