Skip to main content

Deming Regression: Do the Blood Pressure Machine and the Stethoscope Agree?

Deming (errors-in-variables) regression in R, by hand and with the deming package, on 4,212 US adults whose blood pressure was measured both by a physician with a stethoscope and by a machine (NHANES 2017-2018): attenuation, why two ordinary regressions contradict each other, the error variance ratio from repeated readings, jackknife standard errors, testing slope 1 and intercept 0, sensitivity to the ratio, Bland-Altman limits of agreement and APA reporting.

The question: can the machine replace the physician?

For decades the US health survey NHANES measured blood pressure with a mercury column and a stethoscope. Mercury is poisonous, so the survey wanted to change to an automatic machine. But if the machine reads differently, every trend in the nation’s blood pressure would jump on the day of the change. So in 2017–2018 the survey did both: each person was measured by a physician with the stethoscope and by a technician with the machine, in random order (Ostchega et al., 2021).

This page asks the question of every comparison of two instruments:

  1. Does the machine read higher or lower by a constant amount? (constant bias)
  2. Does it read higher or lower in proportion, for example more wrong for high blood pressures? (proportional bias)

The natural idea is a regression of the machine on the stethoscope, and a test of whether the slope is 1 and the intercept 0. It gives a wrong answer. Ordinary regression assumes that \(x\) is measured without error, and here both instruments err. Deming regression is the regression for two variables that are both measured with error.

Code
library(foreign)   # read.xport(): the SAS transport files of the CDC (comes with R)
library(ggplot2)
library(deming)    # deming(): the packaged version

line_colours <- c("equal readings" = "grey40", "OLS: machine on stethoscope" = "#eb6834",
                  "OLS: stethoscope on machine" = "#eda100", "Deming" = "#2a78d6")

# number formats for the text
f1   <- function(x) formatC(x, format = "f", digits = 1, big.mark = ",")
f2   <- function(x) formatC(x, format = "f", digits = 2, big.mark = ",")
f3   <- function(x) formatC(x, format = "f", digits = 3, big.mark = ",")
# no leading zero
nz <- function(x, d = 2) sub("^(-?)0", "\\1", formatC(x, format = "f", digits = d))
pval <- function(p) if (p < .001) "< .001" else paste("=", nz(p, 3))
num  <- function(x) trimws(format(x, big.mark = ","))

1. The data

The CDC publishes the files free and with no login (National Center for Health Statistics, 2021): BPX_J (physician, mercury, stethoscope), BPXO_J (technician, automatic “oscillometric” machine) and DEMO_J (age). Each instrument took three readings, one after the other, which will be important later.

Code
nhanes <- function(file) {
  path <- tempfile(fileext = ".xpt")
  download.file(
    paste0("https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2017/DataFiles/", file, ".xpt"),
    path,
    mode = "wb",
    quiet = TRUE
  )
  read.xport(path)
}
steth_names   <- paste0("BPXSY",  1:3)    # systolic, stethoscope, readings 1 to 3 (mmHg)
machine_names <- paste0("BPXOSY", 1:3)    # systolic, machine, readings 1 to 3

bp <- merge(nhanes("BPX_J")[, c("SEQN", steth_names)], nhanes("BPXO_J")[, c("SEQN", machine_names)])
bp <- merge(bp, nhanes("DEMO_J")[, c("SEQN", "RIDAGEYR")])
bp <- subset(bp, RIDAGEYR >= 18)
bp <- bp[complete.cases(bp), ]            # all six readings
nrow(bp)
[1] 4212
Code
bp$steth   <- rowMeans(bp[, steth_names])      # the mean of three readings
bp$machine <- rowMeans(bp[, machine_names])
summary(bp[, c("steth", "machine")])
     steth          machine      
 Min.   : 74.0   Min.   : 76.33  
 1st Qu.:112.0   1st Qu.:110.00  
 Median :122.7   Median :121.00  
 Mean   :125.2   Mean   :123.87  
 3rd Qu.:134.7   3rd Qu.:134.33  
 Max.   :218.7   Max.   :214.00  

We keep the adults with all six readings, 4,212 people, and the systolic pressure (the upper number), in millimeters of mercury (mmHg). The machine reads 1.3 mmHg lower on average.


2. Look at the data, and get two answers that contradict each other

Code
x <- bp$steth
y <- bp$machine
n <- length(x)

ols     <- lm(y ~ x)               # machine predicted from stethoscope
reverse <- lm(x ~ y)               # stethoscope predicted from machine
slopes  <- c(machine_on_steth = coef(ols)[["x"]], steth_on_machine = coef(reverse)[["y"]])
slopes
machine_on_steth steth_on_machine 
       0.8716357        0.8464101 
Code
# the second line, drawn in the same axes (machine as a function of stethoscope)
rev_line <- c(intercept = -coef(reverse)[[1]] / coef(reverse)[[2]], slope = 1 / coef(reverse)[[2]])
rev_line
intercept     slope 
-24.02711   1.18146 
Code
dem_slope <- function(x, y, lambda) {        # the formula is explained in section 3
  sxx <- var(x); syy <- var(y); sxy <- cov(x, y)
  b1 <- (syy - lambda * sxx + sqrt((syy - lambda * sxx)^2 + 4 * lambda * sxy^2)) / (2 * sxy)
  c(b0 = mean(y) - b1 * mean(x), b1 = b1)
}

lines_ols <- data.frame(
  line = factor(c("equal readings", "OLS: machine on stethoscope", "OLS: stethoscope on machine"),
                levels = names(line_colours)),
  intercept = c(0, coef(ols)[[1]], rev_line[["intercept"]]),
  slope     = c(1, coef(ols)[[2]], rev_line[["slope"]]))

ggplot(bp, aes(steth, machine)) +
  geom_point(alpha = 0.12, size = 1, colour = "grey30") +
  geom_abline(
    data = lines_ols,
    aes(intercept = intercept, slope = slope, colour = line),
    linewidth = 1
  ) +
  scale_colour_manual(values = line_colours, name = NULL) +
  coord_fixed(xlim = c(75, 225), ylim = c(75, 225)) +
  labs(
    title = "Systolic blood pressure, two ways",
    x = "stethoscope (mmHg)",
    y = "machine (mmHg)"
  ) +
  theme_bw() +
  theme(legend.position = "bottom", legend.direction = "vertical")

Plot: 2. Look at the data, and get two answers that contradict each other

  • Regress the machine on the stethoscope: the slope is 0.87. A person at 180 mmHg would get only 171.7 from the machine. Conclusion: the machine underestimates high blood pressure.
  • Regress the stethoscope on the machine: the slope is 0.85, also below 1. Turned around, one mmHg of the stethoscope is 1.18 mmHg of the machine. Conclusion: the machine overestimates high blood pressure.

The same people, the same numbers, and opposite conclusions. Neither is right. Both slopes are pulled below 1 by measurement error in the variable on the right-hand side.


3. The model step by step, with formulas

Step 1: two noisy readings of two hidden values

Each person has a true value that nobody sees. The two instruments read it with errors:

\[x_i = \xi_i + \delta_i, \qquad y_i = \eta_i + \varepsilon_i, \qquad \eta_i = \beta_0 + \beta_1 \xi_i\]

\(\xi_i\) (xi) is what the stethoscope would show without error, \(\eta_i\) (eta) what the machine would. The errors \(\delta_i\) and \(\varepsilon_i\) are independent of everything, with variances \(\sigma_\delta^2\) and \(\sigma_\varepsilon^2\). The instruments agree perfectly, apart from the errors, if \(\beta_0 = 0\) and \(\beta_1 = 1\).

Step 2: why ordinary regression gives a slope that is too small

Ordinary regression uses \(x\), not \(\xi\). The covariance of \(x\) with \(y\) is not affected by the errors, because they are independent, but the variance of \(x\) is larger than that of \(\xi\). So the OLS slope tends to

\[b_{OLS} \longrightarrow \beta_1 \cdot \frac{\sigma_\xi^2}{\sigma_\xi^2 + \sigma_\delta^2}\]

The fraction is the reliability of \(x\). It is below 1, so the slope is too small: attenuation. More data do not help, because it is not a problem of sampling. And it has the same form as the regression to the mean of Galton’s heights.

Step 3: which distance should be small?

OLS assumes that all the error is in \(y\), so it minimizes the vertical distances. If both are wrong, a point should be allowed to move in both directions to reach the line, and the more precise variable should move less. Deming regression minimizes

\[\sum_i \left[ \frac{(x_i - \hat\xi_i)^2}{\sigma_\delta^2} + \frac{(y_i - \beta_0 - \beta_1 \hat\xi_i)^2}{\sigma_\varepsilon^2} \right]\]

over the line and over the hidden \(\hat\xi_i\). Only the ratio of the two variances matters for the line:

\[\lambda = \frac{\sigma_\varepsilon^2}{\sigma_\delta^2} = \frac{\text{error variance of } y}{\text{error variance of } x}\]

Step 4: the formula

With the sample variances \(s_{xx}\), \(s_{yy}\) and the covariance \(s_{xy}\), the minimum has a closed form:

\[b_1 = \frac{s_{yy} - \lambda s_{xx} + \sqrt{(s_{yy} - \lambda s_{xx})^2 + 4 \lambda s_{xy}^2}}{2 s_{xy}}, \qquad b_0 = \bar y - b_1 \bar x\]

Three special cases show what \(\lambda\) does:

\(\lambda\) Means The line becomes
\(\lambda \to \infty\) no error in \(x\) OLS of \(y\) on \(x\)
\(\lambda = 1\) equally large errors orthogonal regression, perpendicular distances
\(\lambda \to 0\) no error in \(y\) OLS of \(x\) on \(y\), turned around
Code
rbind(`lambda = 10000`  = dem_slope(x, y, 10000),
      `lambda = 1`      = dem_slope(x, y, 1),
      `lambda = 0.0001` = dem_slope(x, y, 0.0001))
                        b0        b1
lambda = 10000   14.754226 0.8716592
lambda = 1       -3.470046 1.0172422
lambda = 0.0001 -24.023341 1.1814303

So the two contradicting answers of section 2 are the two extremes, and the truth lies between them. Where, depends on \(\lambda\).

Step 5: \(\lambda\) must come from somewhere else

The cloud of points alone cannot say which instrument is noisier: a wide cloud can come from either. We need outside information. The best source are repeated readings with each instrument: they differ only by error. For person \(i\) with readings \(x_{i1}, x_{i2}, x_{i3}\), the variance of the three around their own mean estimates the error variance, and we average it over the people:

\[\hat\sigma_\delta^2 = \frac{1}{n}\sum_i \text{var}(x_{i1}, x_{i2}, x_{i3})\]

This is why NHANES took three readings with each.

Step 6: the standard error

There is no simple formula that is exact, so we use the jackknife: leave out one person at a time, compute the slope again, and see how much it moves. With \(b_{(-i)}\) the slope without person \(i\), the pseudo-values are \(b_i^* = n\,b - (n - 1)\,b_{(-i)}\), and the standard error is their standard deviation divided by \(\sqrt n\).


4. Fitting the model

The error variances, from the repeated readings

Code
X <- as.matrix(bp[, steth_names])
Y <- as.matrix(bp[, machine_names])
var_steth   <- mean(apply(X, 1, var))      # error variance of one reading
var_machine <- mean(apply(Y, 1, var))
lambda <- var_machine / var_steth
c(sd_steth = sqrt(var_steth), sd_machine = sqrt(var_machine), lambda = lambda)
  sd_steth sd_machine     lambda 
  3.677141   4.499340   1.497191 

One reading of the stethoscope has an error of about \(\pm\) 3.7 mmHg (one SD), one reading of the machine \(\pm\) 4.5. So the machine is a little noisier, and \(\lambda\) = 1.50. The variables \(x\) and \(y\) are means of three readings, so both error variances are divided by 3, and the ratio stays the same. If \(x\) were the mean of three readings and \(y\) a single one, we would have to multiply.

The line by hand

Code
b <- dem_slope(x, y, lambda)
b
       b0        b1 
0.6265246 0.9845171 
Code
# jackknife: the slope and the intercept without person i, for every i
leave_out <- t(sapply(seq_len(n), function(i) dem_slope(x[-i], y[-i], lambda)))
pseudo    <- sweep(-(n - 1) * leave_out, 2, n * b, "+")
se        <- apply(pseudo, 2, sd) / sqrt(n)
ci        <- cbind(lower = b - qt(0.975, n - 2) * se, upper = b + qt(0.975, n - 2) * se)
cbind(estimate = b, SE = se, ci)
    estimate        SE      lower    upper
b0 0.6265246 1.3220256 -1.9653432 3.218392
b1 0.9845171 0.0109259  0.9630966 1.005938

The line with the package

deming() takes the standard deviations of the errors of each row. Ours are means of three readings, so the error variance of one reading is divided by 3. For the line, only the ratio of the two matters:

Code
fit <- deming(machine ~ steth, data = bp,
              xstd = rep(sqrt(var_steth / 3), n), ystd = rep(sqrt(var_machine / 3), n))
fit

Call:
deming(formula = machine ~ steth, data = bp, xstd = rep(sqrt(var_steth/3),     n), ystd = rep(sqrt(var_machine/3), n))

n= 4212
               Coef   se(coef) lower 0.95 upper 0.95
Intercept 0.6263895 1.32217419 -1.9650243   3.217803
Slope     0.9845182 0.01092712  0.9631014   1.005935

   Scale= 2.974178 

Reading the output

Code
z_slope     <- (b[["b1"]] - 1) / se[["b1"]]
z_intercept <- b[["b0"]] / se[["b0"]]
p_slope     <- 2 * pnorm(-abs(z_slope))
p_intercept <- 2 * pnorm(-abs(z_intercept))
at_mean     <- mean(y) - mean(x)
  • Slope = 0.985, 95% CI [0.963, 1.006]. The interesting value is 1, and the question is whether the interval contains it. It does (z = -1.42, p = .156): there is no clear sign of a proportional bias.
  • Intercept = 0.63, 95% CI [-1.97, 3.22]. It is the difference at a blood pressure of 0, where nobody is, so it is very uncertain, and its test is not very useful.
  • The bias in the middle of the data is the useful number: at the average blood pressure (125.2), the machine reads 1.3 mmHg lower. At 180 mmHg, the line says 177.8, a difference of -2.2, where the first OLS line claimed -8.3.
  • Scale measures how far the points are from the line, in units of the errors we gave. It should be about 1 if those errors were the whole story. It is 3.0. This is a warning, which section 6 follows.
Code
lines_all <- rbind(lines_ols, data.frame(line = "Deming", intercept = b[["b0"]], slope = b[["b1"]]))

ggplot(bp, aes(steth, machine)) +
  geom_point(alpha = 0.1, size = 1, colour = "grey30") +
  geom_abline(
    data = lines_all,
    aes(intercept = intercept, slope = slope, colour = line),
    linewidth = 1
  ) +
  scale_colour_manual(values = line_colours, name = NULL) +
  coord_fixed(xlim = c(75, 225), ylim = c(75, 225)) +
  labs(
    title = "The Deming line lies between the two OLS lines",
    x = "stethoscope (mmHg)",
    y = "machine (mmHg)"
  ) +
  theme_bw() +
  theme(legend.position = "bottom", legend.direction = "vertical")

Plot: Reading the output


5. Two proofs that OLS is the one that is wrong

With the data: make \(x\) noisier on purpose

We have three readings. A single reading is noisier than the mean of three, so if attenuation is real, the OLS slope must fall when we use one reading only, although the two instruments are still the same:

Code
one_x <- bp$BPXSY1
one_y <- bp$BPXOSY1
proof <- rbind(
  `mean of 3 readings` = c(OLS = coef(lm(y ~ x))[[2]], Deming = dem_slope(x, y, lambda)[["b1"]]),
  `first reading only` = c(
    OLS = coef(lm(one_y ~ one_x))[[2]],
    Deming = dem_slope(one_x, one_y, lambda)[["b1"]]
  )
)
round(proof, 3)
                     OLS Deming
mean of 3 readings 0.872  0.985
first reading only 0.853  0.985

OLS falls from 0.872 to 0.853. Deming stays at 0.985 and 0.985.

With a simulation: a known truth

2,000 studies of 300 people. The two instruments agree perfectly apart from their errors (\(\beta_0 = 0\), \(\beta_1 = 1\)), with an error SD of 7 mmHg each:

Code
set.seed(11)
sim <- t(replicate(2000, {
  xi <- rnorm(300, mean(x), sd(x)) # the true blood pressures
  xs <- xi + rnorm(300, 0, 7)
  ys <- xi + rnorm(300, 0, 7)
  c(
    OLS = cov(xs, ys) / var(xs),
    reversed = var(ys) / cov(xs, ys),
    Deming = dem_slope(xs, ys, 1)[["b1"]]
  )
}))
reliability <- var(x) / (var(x) + 49)
c(colMeans(sim), expected_OLS = reliability)
         OLS     reversed       Deming expected_OLS 
   0.8750500    1.1409452    0.9989920    0.8764626 
Code
sim_long <- data.frame(
  slope = as.vector(sim),
  method = factor(
    rep(c("OLS: machine on stethoscope", "OLS: stethoscope on machine", "Deming"), each = 2000),
    levels = names(line_colours)
  )
)

ggplot(sim_long, aes(slope, colour = method, fill = method)) +
  geom_density(alpha = 0.25, linewidth = 0.8) +
  geom_vline(xintercept = 1, linetype = "dashed", colour = "grey40") +
  scale_colour_manual(values = line_colours, name = NULL) +
  scale_fill_manual(values = line_colours, name = NULL) +
  labs(title = "2,000 simulated studies of two instruments that agree perfectly",
       subtitle = "Dashed line: the true slope", x = "estimated slope", y = "density") +
  theme_bw() + theme(legend.position = "bottom", legend.direction = "vertical")

With a simulation: a known truth

OLS averages 0.88, which is the reliability, as step 2 promised. Deming averages 1.00. The narrowness of the OLS curve is worth a thought: it is a precise estimate of the wrong number.


6. The weak point: is \(\lambda\) right?

Everything depends on \(\lambda\), and the Scale of 3.0 warned us. If the error variances of the repeated readings were the whole story, the difference between the two instruments would vary by their sum:

Code
difference <- y - x
expected   <- var_steth / 3 + var_machine / 3       # both are means of three readings
c(observed_variance = var(difference), expected_from_repeated_readings = expected,
  ratio = var(difference) / expected)
              observed_variance expected_from_repeated_readings                           ratio 
                      99.610126                       11.255144                        8.850187 

The differences vary 8.9 times as much as the repeated readings say. The three readings of an instrument were taken in a row, by the same examiner, with the same cuff. They share everything that changes from one occasion to the next: the mood, the position, the cuff, how the physician hears. These errors are in each instrument’s mean, and the repeats cannot show them. So the repeated readings underestimate the errors, and we cannot know whether they underestimate both in the same proportion. What we can do is to ask how much it matters:

Code
ratios <- c(0.25, 0.5, 1, lambda, 2, 4)
sens <- t(sapply(ratios, function(l) dem_slope(x, y, l)))
data.frame(lambda = round(ratios, 2), intercept = round(sens[, 1], 2), slope = round(sens[, 2], 3))
  lambda intercept slope
1   0.25    -16.11 1.118
2   0.50    -10.52 1.074
3   1.00     -3.47 1.017
4   1.50      0.63 0.985
5   2.00      3.29 0.963
6   4.00      8.26 0.924
Code
grid <- exp(seq(log(1/20), log(20), length.out = 200))
path <- data.frame(lambda = grid, slope = sapply(grid, function(l) dem_slope(x, y, l)[["b1"]]))

ggplot(path, aes(lambda, slope)) +
  annotate("rect", xmin = 0.5, xmax = 2, ymin = -Inf, ymax = Inf, fill = "grey85", alpha = 0.6) +
  geom_hline(yintercept = 1, linetype = "dashed", colour = "grey40") +
  geom_hline(
    yintercept = c(slopes[[1]], rev_line[["slope"]]),
    colour = c("#eb6834", "#eda100"),
    linewidth = 0.8
  ) +
  geom_line(colour = "#2a78d6", linewidth = 1) +
  geom_point(data = data.frame(lambda = lambda, slope = b[["b1"]]), size = 3, colour = "#2a78d6") +
  scale_x_log10(breaks = c(0.1, 0.5, 1, 2, 10)) +
  labs(
    title = "The Deming slope for every possible λ",
    subtitle = "Horizontal lines: the two OLS slopes. Grey band: one error variance up to twice the other",
    x = "λ = error variance of the machine / error variance of the stethoscope (log scale)",
    y = "slope"
  ) +
  theme_bw()

Sensitivity chart – 6. The weak point: is λ right?

As long as neither error variance is more than twice the other, the slope is between 0.96 and 1.07, close to 1. The exact value, and whether it is “significantly” different from 1, does depend on \(\lambda\): the confidence interval of section 4 takes it as known, and it is too narrow for that reason. The OLS slope of 0.87 would be right only if the stethoscope made no errors at all, which nobody believes.

The lesson for the design of a comparison: repeat the measurement on different occasions, by different examiners, so that the repeats contain all the errors.


7. Agreement is more than a line

Deming regression compares the instruments on average. It says nothing about one person. For that, the usual tool is the plot of Bland and Altman (1986): the difference against the mean of the two.

Code
middle <- (x + y) / 2
limits <- mean(difference) + c(-1.96, 1.96) * sd(difference)
trend  <- lm(difference ~ middle)
c(bias = mean(difference), lower = limits[1], upper = limits[2])
      bias      lower      upper 
 -1.311649 -20.873404  18.250106 
Code
round(coef(summary(trend)), 3)
            Estimate Std. Error t value Pr(>|t|)
(Intercept)   -3.279      1.068  -3.069    0.002
middle         0.016      0.008   1.861    0.063
Code
ggplot(data.frame(middle, difference), aes(middle, difference)) +
  geom_point(alpha = 0.12, size = 1, colour = "grey30") +
  geom_hline(yintercept = 0, colour = "grey60") +
  geom_hline(yintercept = mean(difference), colour = "#2a78d6", linewidth = 1) +
  geom_hline(yintercept = limits, colour = "#eb6834", linetype = "dashed", linewidth = 0.8) +
  labs(
    title = "Machine minus stethoscope, against the mean of the two",
    subtitle = "Blue: mean difference. Orange: limits of agreement, which hold 95% of the differences",
    x = "mean of the two (mmHg)",
    y = "difference (mmHg)"
  ) +
  theme_bw()

Bland altman chart – 7. Agreement is more than a line

Code
crosses <- mean((x >= 130) != (y >= 130))
  • The mean difference is -1.3 mmHg. The differences do not depend clearly on the level (slope 0.016, p = .063), which agrees with a Deming slope near 1.
  • The limits of agreement run from -20.9 to 18.3 mmHg. For one person the two methods can differ a lot: for 14.4% of the adults, one method says 130 mmHg or more and the other says less. 130 is the line that current US guidelines use for high blood pressure.

So for averages of thousands of people the machine can replace the stethoscope, with a correction of about one mmHg. For one visit of one patient neither instrument is precise. Both statements are needed, and they answer different questions.


8. Things to keep in mind

  • Use Deming when neither variable is the outcome and both measure the same thing with error. If you want to predict one reading from the other, OLS is right: the best prediction of \(y\) from a noisy \(x\) does regress towards the mean.
  • \(\lambda\) is an assumption unless it comes from repeats that contain all the sources of error. Report it, and show how the slope changes with it. A wrong \(\lambda\) also makes the tests wrong (Linnet, 1998).
  • Errors that grow with the level. Deming regression assumes the same error variance everywhere. Here the repeats of both instruments vary more at higher pressures. The weighted version lets the error SD of each instrument grow in proportion to the level, that is, it assumes a constant coefficient of variation (Linnet, 1990). The argument stdpat gives the pattern: a constant and a multiplier for \(x\), then for \(y\):
Code
level_bands <- cut(middle, quantile(middle, 0:4 / 4), include.lowest = TRUE)
spread_by_level <- data.frame(stethoscope = tapply(apply(X, 1, var), level_bands, mean),
                              machine     = tapply(apply(Y, 1, var), level_bands, mean))
round(sqrt(spread_by_level), 1)           # error SD of one reading, by quarter of blood pressure
           stethoscope machine
[78.7,112]         3.2     3.8
(112,122]          3.4     4.2
(122,134]          3.6     4.5
(134,209]          4.4     5.3
Code
weighted_fit <- deming(
  machine ~ steth,
  data = bp,
  stdpat = c(0, sqrt(var_steth / 3) / mean(x), 0, sqrt(var_machine / 3) / mean(y))
)
coef(weighted_fit)
(Intercept)       steth 
-0.04151314  0.98987924 
  • The weighted slope is 0.990, against 0.985. The change, 0.005, is about 0.5 times the standard error: the choice of the error model is part of the uncertainty, and the confidence interval does not contain it.
  • Outliers pull the Deming line as they pull OLS. deming::pbreg() (Passing–Bablok) and deming::thielsen() are versions based on ranks.
  • Test the pair (intercept, slope) against (0, 1) together if you need one test, or better, report the expected difference at values that matter, as we did for 180 mmHg.
  • With several predictors measured with error, use a structural equation model with latent variables, or multiple indicators (see the factor models of measurement invariance).
  • Survey weights. We compared instruments within persons, and did not estimate the blood pressure of the US population, for which NHANES needs its weights.

9. Reporting the results in APA style

A report (APA 7th edition) needs the two instruments, the number of readings, where \(\lambda\) came from, the slope and intercept with their uncertainty, and the agreement for individuals. The numbers come from the R objects:

Code
apa_table <- data.frame(
  Method = c(
    "OLS, machine on stethoscope", "OLS, stethoscope on machine (turned around)",
    "Deming, λ from the repeated readings", "Deming, λ = 1"
  ),
  Intercept = f2(c(coef(ols)[[1]], rev_line[[1]], b[["b0"]], dem_slope(x, y, 1)[["b0"]])),
  Slope = f3(c(coef(ols)[[2]], rev_line[[2]], b[["b1"]], dem_slope(x, y, 1)[["b1"]])),
  At180 = f1(
    c(
      coef(ols)[[1]] + 180 * coef(ols)[[2]],
      rev_line[[1]] + 180 * rev_line[[2]],
      b[["b0"]] + 180 * b[["b1"]],
      sum(dem_slope(x, y, 1) * c(1, 180))
    ) -
      180
  )
)

Method (data analysis):

We compared systolic blood pressure measured by a physician with a mercury sphygmomanometer and a stethoscope and by a technician with an oscillometric device, in random order, in 4,212 adults of NHANES 2017–2018 with three readings by each method (Ostchega et al., 2021). The means of the three readings were compared with Deming regression, because both methods have measurement error. The ratio of the error variances (λ = 1.50, device to stethoscope) was estimated from the repeated readings; standard errors were obtained with the jackknife. Because the repeated readings were taken on one occasion, we also report the slope for λ between 0.5 and 2. Agreement for individuals is described by the limits of agreement (Bland & Altman, 1986). Analyses were conducted in R (Version 4.6.2; R Core Team, 2026) with the package deming (Therneau, 2024).

Results:

The device read lower than the stethoscope on average (M = 123.9 against 125.2 mmHg), mean difference = -1.3 mmHg, 95% limits of agreement [-20.9, 18.3]. The Deming slope was 0.985, 95% CI [0.963, 1.006], and the intercept 0.63 mmHg, 95% CI [-1.97, 3.22], which shows no clear proportional bias. For λ between 0.5 and 2 the slope was between 0.963 and 1.074. Ordinary least squares, which ignores the error of the stethoscope, gave a slope of 0.872 (Table 1).

Table 1

Oscillometric Device Against Stethoscope: Systolic Blood Pressure

Method Intercept Slope Difference at 180 mmHg
OLS, machine on stethoscope 14.76 0.872 -8.3
OLS, stethoscope on machine (turned around) -24.03 1.181 8.6
Deming, λ from the repeated readings 0.63 0.985 -2.2
Deming, λ = 1 -3.47 1.017 -0.4

Note. N = 4,212. Difference at 180 mmHg: the reading of the device that the line expects when the stethoscope reads 180, minus 180.

Points to remember:

  • Say how many readings each value rests on, and when they were taken.
  • Report λ, where it came from, and how sensitive the slope is to it.
  • Test the slope against 1, not against 0, and do not report the correlation as agreement: r = .86 here, and it would be the same if the machine read twice as high.
  • Give the limits of agreement for individuals.

10. Summary

When Two measurements of the same thing, both with error: instruments, laboratories, raters, self-report against measurement
Why not OLS Error in \(x\) flattens the slope (attenuation), and more data do not help
The model \(x = \xi + \delta\), \(y = \beta_0 + \beta_1 \xi + \varepsilon\), with \(\lambda = \sigma^2_\varepsilon / \sigma^2_\delta\) known
How (R) deming::deming(y ~ x, xstd = , ystd = ); errors that grow with the level: stdpat = c(0, cv_x, 0, cv_y)
λ From repeated measurements; \(\lambda = 1\) is orthogonal regression
Reading it Slope 1 and intercept 0 mean agreement on average; look at the expected difference at values that matter
Standard errors Jackknife or bootstrap
Also report Bland–Altman limits of agreement, for individuals
Related pages Simple linear regression, weighted least squares

References

Bland, J. M., & Altman, D. G. (1986). Statistical methods for assessing agreement between two methods of clinical measurement. The Lancet, 327(8476), 307–310. https://doi.org/10.1016/S0140-6736(86)90837-8

Linnet, K. (1990). Estimation of the linear relationship between the measurements of two methods with proportional errors. Statistics in Medicine, 9(12), 1463–1473. https://doi.org/10.1002/sim.4780091210

Linnet, K. (1998). Performance of Deming regression analysis in case of misspecified analytical error ratio in method comparison studies. Clinical Chemistry, 44(5), 1024–1031. https://doi.org/10.1093/clinchem/44.5.1024

National Center for Health Statistics. (2021). National Health and Nutrition Examination Survey 2017–2018: Blood pressure, oscillometric measurements (BPXO_J) [Data set]. https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2017/DataFiles/BPXO_J.htm

Ostchega, Y., Nwankwo, T., Chiappa, M., Graber, J., & Nguyen, D. T. (2021). Comparing blood pressure values obtained by two different protocols: National Health and Nutrition Examination Survey, 2017–2018 (Vital and Health Statistics, Series 2, No. 187). National Center for Health Statistics. https://doi.org/10.15620/cdc:104185

Therneau, T. (2024). deming: Deming, Theil-Sen, Passing-Bablock and total least squares regression [R package]. https://CRAN.R-project.org/package=deming