The function is computing all relevant Bland-Altman statistics, including bias, lower and upper limits of agreement and their confidence limits.
A data frame
1st variable to compare (unquoted)
2nd variable to compare (unquoted)
grouping variable (unquoted)
alpha level for the intervals
A tibble with three variables n (number of observations), parameter and value is returned.
library(tidyr)
tbl <- temperature %>% pivot_wider(names_from = method, values_from = temperature)
# simple example
ba_stat(data = tbl, var1 = infrared, var2 = rectal)
#> # A tibble: 9 × 3
#> n parameter value
#> <int> <chr> <dbl>
#> 1 450 bias 0.234
#> 2 450 lloa -2.85
#> 3 450 uloa 3.32
#> 4 450 bias.lcl 0.0879
#> 5 450 lloa.lcl -3.10
#> 6 450 uloa.lcl 3.07
#> 7 450 bias.ucl 0.379
#> 8 450 lloa.ucl -2.60
#> 9 450 uloa.ucl 3.57
## example with grouping
ba_stat(data = tbl, var1 = infrared, var2 = rectal, group = treatment) %>%
pivot_wider(names_from = parameter, values_from = value)
#> # A tibble: 6 × 11
#> treatment n bias lloa uloa bias.lcl lloa.lcl uloa.lcl bias.ucl lloa.…¹
#> <fct> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 healthy 75 0.202 -2.51 2.92 -0.116 -3.06 2.37 0.521 -1.96
#> 2 vehicle 75 0.0383 -3.23 3.30 -0.345 -3.88 2.65 0.422 -2.57
#> 3 low dose 75 0.0353 -3.16 3.23 -0.339 -3.80 2.58 0.410 -2.51
#> 4 mid dose 75 0.634 -2.45 3.72 0.273 -3.07 3.09 0.996 -1.83
#> 5 high dose 75 0.173 -3.15 3.50 -0.218 -3.82 2.83 0.563 -2.48
#> 6 SoC 75 0.319 -2.50 3.14 -0.0125 -3.07 2.57 0.650 -1.94
#> # … with 1 more variable: uloa.ucl <dbl>, and abbreviated variable name
#> # ¹lloa.ucl