bland.altman.stats: Calculate statistics for Bland-Altman-Plot

Description Usage Arguments Value Author(s) See Also Examples

View source: R/bland.altman.R

Description

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.

Usage

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

Arguments

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

Value

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

Author(s)

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

See Also

bland.altman.plot

Examples

 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

Example output

$means
 [1] -0.93530023  1.34436708  0.56338965  0.06611654  0.04062908 -0.50435840
 [7] -0.33016523  0.20616244  1.08343743 -0.45071411  0.42979581 -0.57739308
[13]  0.67529092  0.06307145 -1.18608133 -0.51240798  0.08651163 -0.53841372
[19]  0.22641293  0.36333650

$diffs
 [1]  3.995970e-04  3.357877e-04 -4.015592e-04 -2.767952e-04  1.376904e-04
 [6]  1.530367e-04 -4.505990e-04  1.508949e-05  5.684838e-04 -4.992454e-05
[11] -3.293403e-04  4.366084e-04 -1.534298e-04  1.053347e-04 -6.994188e-05
[16] -1.538641e-04  4.072881e-04 -2.152407e-04  2.544490e-04  4.662167e-05

$groups
        group1      group2
1  -0.93510043 -0.93550003
2   1.34453497  1.34419919
3   0.56318887  0.56359043
4   0.06597814  0.06625494
5   0.04069793  0.04056024
6  -0.50428188 -0.50443492
7  -0.33039053 -0.32993993
8   0.20616998  0.20615489
9   1.08372167  1.08315319
10 -0.45073908 -0.45068915
11  0.42963114  0.42996048
12 -0.57717477 -0.57761138
13  0.67521420  0.67536763
14  0.06312412  0.06301879
15 -1.18611631 -1.18604636
16 -0.51248491 -0.51233104
17  0.08671528  0.08630799
18 -0.53852134 -0.53830610
19  0.22654016  0.22628571
20  0.36335981  0.36331319

$based.on
[1] 20

$lower.limit
[1] -0.0005473137

$mean.diffs
[1] 3.796462e-05

$upper.limit
[1] 0.000623243

$lines
  lower.limit    mean.diffs   upper.limit 
-5.473137e-04  3.796462e-05  6.232430e-04 

$CI.lines
lower.limit.ci.lower lower.limit.ci.upper   mean.diff.ci.lower 
       -0.0007893755        -0.0003052519        -0.0001017898 
  mean.diff.ci.upper upper.limit.ci.lower upper.limit.ci.upper 
        0.0001777191         0.0003811812         0.0008653047 

$two
[1] 1.96

$critical.diff
[1] 0.0005852783

[1] 0.0005852783
lower.limit.ci.lower lower.limit.ci.upper   mean.diff.ci.lower 
          -112.61914            -43.57547            -22.04884 
  mean.diff.ci.upper upper.limit.ci.lower upper.limit.ci.upper 
            17.81354             39.34017            108.38384 
lower.limit.ci.lower lower.limit.ci.upper   mean.diff.ci.lower 
          -114.16974            -45.12607            -22.04884 
  mean.diff.ci.upper upper.limit.ci.lower upper.limit.ci.upper 
            17.81354             40.89078            109.93445 

BlandAltmanLeh documentation built on May 1, 2019, 8:04 p.m.