plot: Bland-Altman plot of differences versus averages.

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

For two vectors of equal length representing measurements of the same quantity by two different methods, the differences are plotted versus the average. The limits of agreement (prediction limits for the differences) are plotted, optionally a regression of differences of means is given too. Works with Meth and MethComp objects too.

A plot method for the "PBreg" class object, that is a result of Passing-Bablok regression.

When a method comparison model i fitted and stored in a MCmcmc object, then the posterior distributions of the variance components are plotted, in separate displays for method.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
BA.plot(
  y1,
  y2,
  meth.names = NULL,
  wh.comp = 1:2,
  pl.type = "BA",
  dif.type = "const",
  sd.type = "const",
  model = if (inherits(y1, "Meth") & has.repl(y1)) "exch" else NULL,
  eqax = FALSE,
  axlim = if (is.data.frame(y1)) range(y1$y) else range(c(y1, y2)),
  diflim = NULL,
  grid = TRUE,
  N.grid = 10,
  col.grid = grey(0.9),
  points = TRUE,
  col.points = "black",
  cex.points = 1,
  pch.points = 16,
  lwd = c(3, 1, 1),
  col.lines = "blue",
  repl.conn = FALSE,
  col.conn = "gray",
  lwd.conn = 1,
  xlab = NULL,
  ylab = NULL,
  eqn = FALSE,
  col.eqn = col.lines,
  font.eqn = 2,
  digits = 2,
  Transform = if (mult) "log" else NULL,
  mult = FALSE,
  alpha = NULL,
  ...
)

## S3 method for class 'PBreg'
plot(
  x,
  pch = 21,
  bg = "#2200aa33",
  xlim = c(0, max(x$model)),
  ylim = c(0, max(x$model)),
  xlab = x$meths[1],
  ylab = x$meths[2],
  subtype = 1,
  colors = list(CI = "#ccaaff50", fit = "blue", ref = "#99999955", bars = "gray", dens =
    "#8866aaa0", ref2 = c("#1222bb99", "#bb221299")),
  ...
)

## S3 method for class 'Meth'
plot(
  x,
  which = NULL,
  col.LoA = "blue",
  col.pt = "black",
  cex.name = 2,
  var.range,
  diff.range,
  var.names = FALSE,
  pch = 16,
  cex = 0.7,
  Transform,
  ...
)

## S3 method for class 'VarComp'
plot(
  x,
  which,
  lwd.line = rep(2, 4),
  col.line = c("red", "green", "blue", "black"),
  lty.line = rep(1, 4),
  grid = TRUE,
  col.grid = gray(0.8),
  rug = TRUE,
  probs = c(5, 50, 95),
  tot.var = FALSE,
  same.ax = TRUE,
  meth.names = TRUE,
  VC.names = "first",
  ...
)

Arguments

y1

Numerical vector of measurements by 1st method. Can also be a Meth or a MethComp object, see details.

y2

Numerical vector of measurements by 2nd method. Must of same length as x. Ignored if a Meth or a MethComp objects is given for y1.

meth.names

Should the names of the methods be put on the plots?

wh.comp

Which methods should be compared. Either numerical or character.

pl.type

What type of plot should be made, "BA" for differences versus averages, "conv" for method 1 versus method 2.

dif.type

How should difference depend on the averages. "const" or "lin".

sd.type

How should the standard deviation depend on the averages. "const" or "lin".

model

Should a variance component model be used to compute the limits of agreement? If NULL a simple analysis is made; other possibilities are "exch" or "linked" for exchangeable or linked replicates.

eqax

Should the axes be identical? If a Bland-Altman plot is drawn, the axis for the differences will have the same extent as the axis for the averages, but centered on 0 (see diflim).

axlim

The limits of the axes.

diflim

The limits of the difference axis.

grid

Logical. Should a vertical grid be set up? If numeric it is set up at the values specified. If same.ax, the range of the grid is taken to be the extent of the x-axis for all plots.

N.grid

How many grid-lines should be drawn.

col.grid

The color of the grid.

points

Logical. Should the observed points be drawn?

col.points

What color should they have?

cex.points

How large should they be?

pch.points

What plot character for the points

lwd

Numerical vector of 3, giving the width of the conversion line (mean difference) and the limits of agreement.

col.lines

What color should the lines have.

repl.conn

Should replicate measurements be connected (within items)?

col.conn

Color of connecting lines.

lwd.conn

Width of connecting lines.

xlab

Label on the x-axis.

ylab

Label on the y-axis.

eqn

Logical. Should the equations linking the methods be shown on the plot? If a Bland-Altman plot is made, both the equations linking the methods and the equation for the differences versus the averages are shown.

col.eqn

Color for equations

font.eqn

Font for equations

digits

How many digits after the decimal point should be used when showing the equations.

Transform

Transformation used to the measurements prior to plotting. Function or character, see choose.trans for possible values.

mult

Logical. If TRUE, ratios of measurement instead of differences will be plotted in the Bland-Altman plot on a logarithmic axis, and limits of agreement will be given on this scale? This gives the same analysis as using Transform="log", but a different plot. Using another transformation than the log is accommodated, but no LoA is shown on the axis.

alpha

1 minus the confidence level. If NULL a multiplier of 2 is used for constructing prediction limits, otherwise a t-quantile with d.f. equal th number of items minus 1.

...

Parameters passed on the density furnction that does the smoothing of the posterior samples.

x

A MCmcmc object.

pch

Plot character for points.

bg

Background colour for the plotting character.

xlim

Limits for the x-axis.

ylim

Limits for the y-axis.

subtype

a numeric value or vector, that selects the desired plot subtype. Subtype 1 is an x-y plot of raw data with regression line and confidence boundaries for the fit as a shaded area. This is the default. Subtype 2 is a ranked residuals plot. Subtype 3 is the "Cusum" plot useful for assessing linearity of the fit. Plot subtypes 1 through 3 are standard plots from the 1983 paper by Passing and Bablok - see the reference. Plot subtype 4 is a histogram (with overlaid density line) of the individual slopes. The range of this plot is limited to 5 x IQR for better visibility.

colors

A list of 6 elements allowing customization of colors of various plot elements. For plot subtype 1: "CI" is the color of the shaded confidence interval area; and "fit" is the color of fit line. For plot subtypes 2 & 3: "ref" is the color of the horizontal reference line. For plot subtype 4: "bars" is the bar background color, "dens" is the color of the density line, and "ref2" is a vector of two colors for lines indicating the median and confidence limits.

which

For which of the compared methods should the plot be made?

col.LoA

What color should be used for the limits of agreement.

col.pt

What color should be used for the points.

cex.name

Character expansion factor for plotting method names

var.range

The range of both axes in the scatter plot and the x-axis in the Bland-Altman plot be?

diff.range

The range of yaxis in the Bland-Altman plot. Defaults to a range as the x-axis, but centered around 0.

var.names

If logical: should the individual panels be labelled with the variable names?. If character, then the values of the character will be used to label the methods.

cex

Plot charcter expansion for points.

lwd.line

Line width for drawing the density.

col.line

Color for drawing the densities.

lty.line

Line type for drawing the densities.

rug

Should a small rug at the bottom show posterior quantiles?

probs

Numeric vector with numbers in the range from 0 to 100, indicating the posterior percentiles to be shown in the rug.

tot.var

Should the posterior of the total variance also be shown?

same.ax

Should the same axes be used for all methods?

VC.names

Should the names of the variance components be put on the first plot ("first"), the last ("last"), all ("all") or none ("none"). Only the first letter is needed.

Details

A plot of the relationship between the methods is produced; either a Bland-Altman plot of the differences versus averages, or a 45 degree rotation as a conversion between the methods. If model=NULL a simple regression of averages on differences is made by calling DA.reg, and the specified conversion plotted.

The function generates a series of plots, one for each method compared in the MCmcmc object supplied (or those chosen by which=). Therefore the user must take care to set mfrow or mfcol to capture all the plots.

Value

An object of class MethComp and either DA.reg (if model=NULL) or BA.est (if model is character).

A plot as a side effect

A list with one element for each method. Each element of this is a list of densities, i.e. of objects of class density, one for each variance component.

Author(s)

Bendix Carstensen bendix.carstensen@regionh.dk, http://BendixCarstensen.com.

Michal J. Figurski mfigrs@gmail.com

Bendix Carstensen, bendix.carstensen@regionh.dk

References

JM Bland and DG Altman: Statistical methods for assessing agreement between two methods of clinical measurement, Lancet, i, 1986, pp. 307-310.

JM Bland and DG Altman. Measuring agreement in method comparison studies. Statistical Methods in Medical Research, 8:136-160, 1999.

B Carstensen: Comparing methods of measurement: Extending the LoA by regression. Stat Med. 2010 Feb 10;29(3):401-10.

Passing, H. and Bablok, W. (1983), A New Biometrical Procedure for Testing the Equality of Measurements from Two Different Analytical Methods. Journal of Clinical Chemistry and Clinical Biochemistry, Vol 21, 709–720

See Also

BA.est, DA.reg, MCmcmc.

PBreg, Deming.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
data( ox )
ox <- Meth( ox )
# The simplest possible Bland-Altman plot
BA.plot( ox )

## With bells and whistles, comparing the naive and model
par( mfrow=c(2,2) )
BA.plot( ox, model=NULL, repl.conn=TRUE, col.lines="blue",
         axlim=c(0,100), diflim=c(-50,50), xaxs="i", yaxs="i",
         las=1, eqn=TRUE, dif.type="lin", pl.type="BA", sd.type="lin",
         grid=1:9*10, digits=3,font.eqn=1)
par(new=TRUE)
BA.plot( ox, model="linked", repl.conn=TRUE, col.lines="red",
         axlim=c(0,100), diflim=c(-50,50), xaxs="i", yaxs="i",
         las=1, eqn=FALSE, dif.type="lin", pl.type="BA", sd.type="lin",
        grid=1:0*10, digits=3)
BA.plot( ox, model=NULL, repl.conn=TRUE, col.lines="blue",
         axlim=c(0,100), diflim=c(-50,50), xaxs="i", yaxs="i",
         las=1, eqn=TRUE, dif.type="lin", pl.type="conv", sd.type="lin",
        grid=1:9*10, digits=3,font.eqn=1)
par(new=TRUE)
BA.plot( ox, model="linked", repl.conn=TRUE, col.lines="red",
         axlim=c(0,100), diflim=c(-50,50), xaxs="i", yaxs="i",
         las=1, eqn=FALSE, dif.type="lin", pl.type="conv", sd.type="lin",
         grid=1:9*10, digits=3)
# The same again, but now logit-transformed
BA.plot( ox, model=NULL, repl.conn=TRUE, col.lines="blue",
         axlim=c(0,100), diflim=c(-50,50), xaxs="i", yaxs="i",
         las=1, eqn=TRUE, dif.type="lin", pl.type="BA", sd.type="lin",
         grid=1:9*10, digits=3,font.eqn=1,Transform="pctlogit")
par(new=TRUE)
BA.plot( ox, model="linked", repl.conn=TRUE, col.lines="red",
         axlim=c(0,100), diflim=c(-50,50), xaxs="i", yaxs="i",
         las=1, eqn=FALSE, dif.type="lin", pl.type="BA", sd.type="lin",
         grid=1:0*10, digits=3,Transform="pctlogit")
BA.plot( ox, model=NULL, repl.conn=TRUE, col.lines="blue",
         axlim=c(0,100), diflim=c(-50,50), xaxs="i", yaxs="i",
         las=1, eqn=TRUE, dif.type="lin", pl.type="conv", sd.type="lin",
         grid=1:9*10, digits=3,font.eqn=1,Transform="pctlogit")
par(new=TRUE)
BA.plot( ox, model="linked", repl.conn=TRUE, col.lines="red",
         axlim=c(0,100), diflim=c(-50,50), xaxs="i", yaxs="i",
         las=1, eqn=FALSE, dif.type="lin", pl.type="conv", sd.type="lin",
         grid=1:9*10, digits=3,Transform="pctlogit")


  ## Model data frame generation
  a <- data.frame(x=seq(1, 30)+rnorm(mean=0, sd=1, n=30),
                  y=seq(1, 30)*rnorm(mean=1, sd=0.4, n=30))

  ## Call to PBreg
  x <- PBreg(a)
  print(x)
  par(mfrow=c(2,2))
  plot(x, s=1:4)

  ## Or the same using "Meth" object
  a <- Meth(a, y=1:2)
  x <- PBreg(a)
  print(x)
  par(mfrow=c(2,2))
  plot(x, s=1:4)

MethComp documentation built on Jan. 20, 2020, 1:12 a.m.

Related to plot in MethComp...