Description Usage Arguments References Examples
Creates a scatter plot using the method of Bland and Altman where the x-
and y-axes are the means of and differences between x
and y
,
respectively. Lines for the mean and +/-1.96
times the standard
deviation of the difference between x
and y
are shown.
1 2 3 4 |
x, y |
measurements |
trend |
character string giving the type of trend line, one of
|
span |
if |
trend.n |
integer value for the number of data points to be used by
|
alpha |
confidence level affecting the critical values and trend confidence bands |
xlab, ylab |
x- and y-axis labels |
xlim, ylim |
x- and y-axis limits |
panel.first |
an expression to be evaluated after the plot axes are
set up but before any plotting takes place (default is just a |
panel.last |
an expression to be evaluated after plotting has taken
place but before the axes, title, and box are added; see comments about
|
... |
additional parameters passed to |
line_pars |
additional graphical parameters passed to |
Altman DG, Bland JM (1983). Measurement in medicine: the analysis of method comparison studies. The Statistician 32: 307-317.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | set.seed(1)
x <- rnorm(100)
y <- rnorm(100, 0.5)
## basic usage
ba_plot(x, y)
ba_plot(x, y, trend = 'gam')
ba_plot(x, y, trend = 'none', alpha = 0.1)
## use line_pars to set graphical parameters of individual lines
ba_plot(x, y, col = c('black', 'green')[(abs(x - y) > 2) + 1L],
pch = '.', cex = 5, line_pars = list(col = c('yellow', 'red')))
## panel.first/panel.last is used as in plot.default
ba_plot(x, y, cex = 2, las = 1,
col = as.numeric(cut(x - y, c(-Inf, -2, 2, Inf))) + 2,
panel.first = {
p <- par('usr')
rect(p[1L], p[3L], p[2L], p[4L], col = 'cornsilk')
grid(col = 'grey90', lty = 1)
},
line_pars = list(col = 3:5, family = 'HersheySerif'))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.