*! version 1.0 23 Mar 2021

Title

batplot -- Produces a Bland-Altman plot when there is a relationship between paired differences and their average

Syntax

batplot
varlist
(min=2
max=2)
[if]
[in]
[,
options]

Optional
notrend specifies that the original Bland-Altman plot (without a trend) be plotted.

info specifies that the percentage of points outside the limits of agreement are
displayed as a subtitle.

valabel(varname) pecifies that the points outside the limits of agreement be labelled using
the variable varname.

moptions(string asis) specifies options for the markers that lie outside the limits of agreement.

shading(numlist min=2 max=2) specifies the extent of shading beyond the range of the data.

scatter(string asis) specifies options for the scatter part of the final plot.

nograph specifies that the graph is not displayed to the graphics window.

dp(#) specifies the precision of the numbers in the title of the graph.

rarea(string asis) specifies options for the rarea part of the final plot.

* specifies other twoway options, for example titles and labels.

Description

batplot produces a Bland-Altman plot adjusted (or not) for trend.

The standard Bland-Altman plot is between the difference of paired variables versus the average,
this is produced using the notrend option. The main addition that this command handles is when
there is a linear relationship between the the paired difference and the paired average. A
regression model is used to adjust the limits of agreement accordingly. This is particularly
useful when the two variables might be measured on different scales and hence a straight conversion
factor would recalibrate the two variables.

Options

Main

notrend specifies that the original Bland-Altman plot (without a trend) be plotted.

info specifies that the percentage of points outside the limits of agreement are displayed as a
subtitle. Additionally when using the notrend option the limits of agreement and mean
difference are included in the subtitle.

valabel(varname) specifies that the points outside the limits of agreement be labelled using the
variable varname.

moptions(string asis) specifies options for the markers that lie outside the limits of agreement, the options
can be anything from the scatter marker options.

shading(numlist min=2 max=2) specifies the extent of shading beyond the range of the data. The default is that
the limits of shading is determined by the values in the xlabel option.

scatter(string asis) specifies options for the scatter part of the final plot.

nograph specifies that the graph is not displayed to the graphics window.

dp(#) specifies the precision of the numbers in the title of the graph. The default is 2 decimal
places.

rarea(string asis) specifies options for the rarea part of the final plot.

* specifies other twoway options, for example titles and labels.

Examples

Using the auto.dta dataset supplied with STATA 8 this command can check whether there is agreement
between turning circle (ft) and miles per gallon, click the highlighted text in order,

sysuse auto, clear

batplot mpg turn

This is the most basic graphic and using twoway options the look can be improved by clicking below,

batplot mpg turn, title(Agreement between mpg and turn) xlab(26(4)38)

By specifying extra options the outlying points can be labelled and identified by the car make,

batplot mpg turn, title(Agreement between mpg and turn) info valabel(make) xlab(26(4)38)

To obtain the original Bland Altman plot use the notrend option,

batplot mpg turn, title(Agreement between mpg and turn) info valabel(make) notrend xlab(26(4)38)

To improve the labelling of the point VW it may be preferable to change the clock position of the
label i.e. labels could appear to the left of the point. This is handled below with moptions().

batplot mpg turn, title(Agreement between mpg and turn) info valabel(make) notrend xlab(26(4)38) moptions(mlabp(9))

Additionally in the case of multiple scatter points by using the scatter() option the user can
specify to "jitter" datapoints

batplot mpg turn, notrend xlab(26(4)38) moptions(mlabp(9)) sc(jitter(4))

Add a line at 0 to the above plot and also changes the transparency in the area plot so the
yline() option can be seen.

batplot mpg turn, notrend xlab(26(4)38) moptions(mlabp(9)) sc(jitter(4)) rarea(bc(gs13%50)) yline(0, lc(black))

Stored results

Locals

r(mean) is the mean.

r(b0) is the intercept.

r(b1) is the slope.

r(c0) is the intercept for the trend line.

r(c1) is the slope for the trend line.

r(eqn) is the equation.

r(upper) is the upper limit equation.

r(lower) is the lower limit equation.

References

Bland JM, Altman DG. (1999) Measuring agreement in method comparison studies. Statistical Methods in Medical Research 8, 135-160.

Author

Prof Adrian Mander, Cardiff University.

Email mandera@cardiff.ac.uk