Learn R Programming

MethComp (version 1.22.2)

BA.plot: Bland-Altman plot of differences versus averages.

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.

Usage

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, ... )

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
Label for the method names.
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
Should a grid be drawn? If numeric it indicates the places where the grid is drawn.
N.grid
How many grid-lines should be drawn.
col.grid
What should be 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
x-axis label.
ylab
y-axis label.
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 applied to data prior to analysis. Plots are made on the original scale after back-transformation.
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.
...
Further parameters passed on to plot.MethComp

Value

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

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.

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.

See Also

BA.est, DA.reg, MCmcmc.

Examples

Run this code
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")

Run the code above in your browser using DataLab