Universal Agreement R
Menu location: Analysis_Agreement_Universal R.
The function calculates the Berry-Mielke Universal R coefficient of agreement and/or effect size (Mielke and Berry, 2007). It is a generalisation of Cohen's kappa to an interval and ordinal measurement scales, and can handle more than two raters. With categorical data R is equivalent to a linearly weighted kappa statistic.
R is chance-corrected and appropriate for the measurement of reliability. It is based on Euclidean distances in a multivariate framework, and it's significance is tested using Pearson Type III distribution (Berry and Mielke, 1988).
In addition to multiple observers, this function can handle multiple aspects or dimensions of observation per observer.
If one of the observers represents a gold standard or reference then you can specify that observer - in this case a slightly different calculation is performed (Berry and Mielke, 1997b).
A calculator is also provided for testing the significance of the difference between two R values from two independent sets of raters (Berry and Mielke, 1997a).
Example
From Mielke and Berry (2007).
Test workbook (Agreement worksheet: Measurement, Rater, Dimension).
Five objects are measured by three observers, each assessing the height, weight and depth of the object:
| Measurement | Object | Observer | Dimension |
| 8.0 | 1 | 1 | h |
| 10.5 | 2 | 1 | h |
| 17.6 | 3 | 1 | h |
| 9.0 | 4 | 1 | h |
| 14.6 | 5 | 1 | h |
| 9.2 | 1 | 1 | w |
| 2.5 | 2 | 1 | w |
| 4.5 | 3 | 1 | w |
| 12.0 | 4 | 1 | w |
| 6.0 | 5 | 1 | w |
| 6.0 | 1 | 1 | d |
| 11.0 | 2 | 1 | d |
| 13.0 | 3 | 1 | d |
| 14.2 | 4 | 1 | d |
| 7.5 | 5 | 1 | d |
| 8.2 | 1 | 2 | h |
| 11.2 | 2 | 2 | h |
| 20.0 | 3 | 2 | h |
| 9.0 | 4 | 2 | h |
| 14.2 | 5 | 2 | h |
| 9.0 | 1 | 2 | w |
| 3.0 | 2 | 2 | w |
| 4.5 | 3 | 2 | w |
| 12.5 | 4 | 2 | w |
| 6.0 | 5 | 2 | w |
| 6.5 | 1 | 2 | d |
| 11.5 | 2 | 2 | d |
| 15.0 | 3 | 2 | d |
| 14.0 | 4 | 2 | d |
| 8.0 | 5 | 2 | d |
| 8.2 | 1 | 3 | h |
| 9.5 | 2 | 3 | h |
| 21.4 | 3 | 3 | h |
| 9.5 | 4 | 3 | h |
| 14.5 | 5 | 3 | h |
| 9.0 | 1 | 3 | w |
| 2.8 | 2 | 3 | w |
| 4.5 | 3 | 3 | w |
| 13.5 | 4 | 3 | w |
| 5.5 | 5 | 3 | w |
| 6.5 | 1 | 3 | d |
| 12.5 | 2 | 3 | d |
| 17.0 | 3 | 3 | d |
| 14.4 | 4 | 3 | d |
| 9.2 | 5 | 3 | d |
To analyse these data using StatsDirect you must first enter them into a workbook or open the test workbook. Then select Universal R from the Agreement section of the Analysis menu.
Universal agreement (Berry-Mielke) R
| Measurement: | Measurement (height, weight, depth) | Measurement (height, weight, depth) |
| Number of measurements: | 45 | 45 |
| Number of observers: | 3 | 3 |
| Number of objects: | 5 | 5 |
| Number of dimensions: | 3 | 3 |
| Reference standard: | None | Observer 1 |
| Observed (realised) delta: | 1.607036 | 3.432041 |
| Expected (mean) delta: | 8.257518 | 16.218413 |
| Variance of delta: | 1.166045 | 6.363892 |
| Skewness of delta: | -0.777166 | -0.492177 |
| Agreement coefficient R: | 0.805385 | 0.788386 |
| Significance: | P < 0.0001 | P < 0.0001 |
The results indicate 81% agreement between observer, which is beyond chance. If the first observer is considered the gold standard then the agreement is 79%.
Comparison example
If two independent groups of observers were assessed using the R coefficient above, giving results: R(1) = 0.11578; R(2) = 0.19780; mean delta(1) = 1.27050; mean delta(2) = 1.60240; variance delta(1) = 0.4678E-03; variance delta(2) = 0.1010E-02; skewness delta(1) = -0.34145; skewness delta(2) = -0.28425.
Select menu item Analysis_Agreement_Compare two universal R values...
Comparison of two universal agreement R statistics
| Group 1 | Group 2 | Difference | |
| R: | 0.11578 | 0.1978 | -0.08202 |
| Mean delta: | 1.2705 | 1.6024 | -0.3319 |
| Variance delta: | 0.000468 | 0.00101 | 0.000683 |
| Skewness delta: | -0.34145 | -0.28425 | -0.029847 |
| Significance: | P < 0.0001 | P < 0.0001 | P = 0.002 |
The results indicate a statistically significant difference between the two groups of observers' ratings of the same set of objects.
R code
This R code reproduces the example and the comparison example above. It needs no packages and was checked with R 4.6.1. Paste it into R, or save it as a script and run it.
# Universal agreement R: the StatsDirect help example (Mielke and Berry 2007, five
# objects measured by three observers in three dimensions; the test workbook's
# Agreement worksheet columns Measurement, Object, Observer and Dimension) in R
measurement <- c(8, 10.5, 17.6, 9, 14.6, 9.2, 2.5, 4.5, 12, 6, 6, 11, 13, 14.2, 7.5,
8.2, 11.2, 20, 9, 14.2, 9, 3, 4.5, 12.5, 6, 6.5, 11.5, 15, 14, 8,
8.2, 9.5, 21.4, 9.5, 14.5, 9, 2.8, 4.5, 13.5, 5.5, 6.5, 12.5, 17, 14.4,
9.2)
object <- rep(1:5, 9)
observer <- rep(1:3, each = 15)
dimension <- rep(rep(c("h", "w", "d"), each = 5), 3)
n <- 5
b <- 3
# Each observer's measurements of each object as a point in three dimensions, and the
# distance between every two such points
x <- array(NA, c(n, b, 3))
x[cbind(object, observer, match(dimension, c("h", "w", "d")))] <- measurement
D <- array(0, c(n, b, n, b))
for (i in 1:n) for (r in 1:b) for (j in 1:n) for (s in 1:b) {
D[i, r, j, s] <- sqrt(sum((x[i, r, ] - x[j, s, ])^2))
}
# Delta is the mean distance between two observers' measurements of the same object,
# over the objects and the pairs of observers. R is 1 minus delta over its expected
# value when each observer's measurements are shuffled among the objects at random.
# Base R has no permutation function; this one lists the n! orderings of the objects.
# Observer 1's labels can stay as they are, so the shuffles of the other observers'
# labels give every distinct rearrangement (5!^2 = 14400 here) and the mean, variance
# and skewness of delta over them are exact
perms <- function(n) {
if (n == 1) return(matrix(1))
p <- perms(n - 1)
do.call(rbind, lapply(1:n, function(k) cbind(k, p + (p >= k))))
}
P <- perms(n)
shuffles <- as.matrix(expand.grid(rep(list(1:nrow(P)), b - 1)))
delta <- function(shuffle, pairs, average) {
labels <- rbind(1:n, P[shuffle, , drop = FALSE])
total <- 0
for (q in 1:ncol(pairs)) {
r <- pairs[1, q]
s <- pairs[2, q]
total <- total + mean(D[cbind(labels[r, ], r, labels[s, ], s)])
}
if (average) total / ncol(pairs) else total
}
# The P value refers delta, standardised by its mean and variance, to the Pearson type
# III distribution with the same skewness, which is a gamma distribution
six <- function(x) formatC(x, digits = 6, format = "f", drop0trailing = TRUE)
pv <- function(p) {
if (p < 0.0001) "P < 0.0001" else
paste("P =", formatC(p, digits = 4, format = "f", drop0trailing = TRUE))
}
p_type3 <- function(t, skew) {
if (abs(skew) < 1e-7) return(pnorm(t))
r <- 2 / abs(skew)
if (skew > 0) pgamma(t + r, shape = r^2, rate = r) else
pgamma(r - t, shape = r^2, rate = r, lower.tail = FALSE)
}
report <- function(pairs, average, reference) {
observed <- delta(rep(1, b - 1), pairs, average) # P's first row is 1:n
all <- apply(shuffles, 1, delta, pairs = pairs, average = average)
mu <- mean(all)
v <- mean((all - mu)^2)
skew <- mean((all - mu)^3) / v^1.5
cat("Reference standard:", reference, "\n")
cat("Observed (realised) delta:", six(observed), "\n")
cat("Expected (mean) delta:", six(mu), "\n")
cat("Variance of delta:", six(v), "\n")
cat("Skewness of delta:", six(skew), "\n")
cat("Agreement coefficient R:", six(1 - observed / mu), "\n")
cat("Significance:", pv(p_type3((observed - mu) / sqrt(v), skew)), "\n")
}
cat("Number of measurements:", length(measurement), " observers:", b, " objects:", n,
" dimensions: 3\n")
report(combn(b, 2), TRUE, "None")
# With observer 1 as the reference standard, delta is the sum over the other observers
# of their mean distance from the reference
report(rbind(1, 2:b), FALSE, "Observer 1")
# Comparison example: R for two independent groups of observers, with the mean,
# variance and skewness of delta that each group's report gives. The difference is
# tested on the delta scale (Berry and Mielke 1997a): its variance and skewness come
# from the two groups' moments, and the P value for the difference is two sided, twice
# the lesser of its two tails. The P value under each group is that of its own R: the
# delta that the group observed is its mean delta times 1 - R
r1 <- 0.11578
r2 <- 0.19780
mu1 <- 1.27050
mu2 <- 1.60240
var1 <- 0.4678E-03
var2 <- 0.1010E-02
skew1 <- -0.34145
skew2 <- -0.28425
vard <- (mu1^2 * var2 + mu2^2 * var1) / (mu1^2 * mu2^2)
skewd <- (mu1^3 * var2^1.5 * skew2 - mu2^3 * var1^1.5 * skew1) /
(mu1^3 * mu2^3 * vard^1.5)
cat("R:", six(r1), six(r2), six(r1 - r2), "\n")
cat("Delta:", six(mu1), six(mu2), six(mu1 - mu2), "\n")
cat("Variance:", six(var1), six(var2), six(vard), "\n")
cat("Skewness:", six(skew1), six(skew2), six(skewd), "\n")
lower <- p_type3((r1 - r2) / sqrt(vard), skewd)
upper <- p_type3((r2 - r1) / sqrt(vard), -skewd)
cat("Significance:", pv(p_type3((mu1 * (1 - r1) - mu1) / sqrt(var1), skew1)),
pv(p_type3((mu2 * (1 - r2) - mu2) / sqrt(var2), skew2)),
pv(min(1, 2 * min(lower, upper))), "\n")