Does the computation for Bland Altman plots. This will usually be called from
graphic functions like `bland.altman.plot`

but will be usefull for
customized plot (see examples for color coded BA plot). Offers symmetric
confidence intervalls for bias and upper and lower limits.

1 | ```
bland.altman.stats(group1, group2, two = 1.96, mode = 1, conf.int = 0.95)
``` |

`group1` |
vector of numerics to be compared to group2 |

`group2` |
vector of numerics to be compared to group1 |

`two` |
numeric defines how many standard deviations from mean are to be computed, defaults to 1.96 as this gives proper 95 percent CI. However, in the original publication a factor of 2 is used. |

`mode` |
if 1 then difference group1 minus group2 is used, if 2 then group2 minus group1 is used. Defaults to 1. |

`conf.int` |
usefull |

`means`

vector of means, i. e. data for the x axis

`diffs`

vector of differences, i. e. data for the y axis

`groups`

data.frame containing pairwise complete cases of group1 and
group2. NAs are removed.

`based.on`

count of pairwise complete cases in groups

`lower.limit`

lower limit for BA plot

`mean.diffs`

mean of differences, also called 'bias'

`upper.limit`

upper limit for BA plot

`lines`

vector containing y values where to draw horizontal
lines, i. e. mean of differences minus "two" standard deviations, mean of
differences and mean of differences plus "two" standard deviations (i. e.
`c(lower.limit, mean.diffs, upper.limit`

). This is convenient for
printing.

`CI.lines`

vector of confidence intervalls for the values of
lines (based on the assumption of normal distribution of differences
`diffs`

).

`two`

the argument 'two'

`critical.diff`

critical difference, i. e. 'two' times standard
deviation of differences, equals half the difference of lower.limit and
upper.limit

Bernhard Lehnert <bernhard.lehnert@uni-greifswald.de>

`bland.altman.plot`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
# simple calculation of stats:
a <- rnorm(20)
b <- jitter(a)
print(bland.altman.stats(a, b))
print(bland.altman.stats(a, b)$critical.diff)
# drawing Bland-Altman-Plot with color coding sex:
example.data <- data.frame(sex = gl(2,6,labels=c("f","m")),
m1 = c(16,10,14,18,16,15,18,19,14,11,11,17),
m2 = c(18, 9,15,19,19,13,19,20,14,11,13,17))
ba <- bland.altman.stats(example.data$m1, example.data$m2)
plot(ba$means, ba$diffs, col=example.data$sex, ylim=c(-4,4))
abline(h=ba$lines, lty=2)
# compute 95%-CIs for the bias and upper and lower limits of PEFR data as
# in Bland&Altman 1986
bland.altman.stats(bland.altman.PEFR[,1],bland.altman.PEFR[,3])$CI.lines
# apparently wrong results? CAVE: Bland&Altman are using two=2, thus
bland.altman.stats(bland.altman.PEFR[,1],bland.altman.PEFR[,3], two=2)$CI.lines
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.