Learn R Programming

valytics (version 0.4.0)

pb_regression: Passing-Bablok Regression for Method Comparison

Description

Performs Passing-Bablok regression to assess agreement between two measurement methods. This non-parametric regression method is robust to outliers and does not assume normally distributed errors. The implementation uses a fast O(n log n) algorithm from the robslopes package for point estimation.

Usage

pb_regression(
  x,
  y = NULL,
  data = NULL,
  conf_level = 0.95,
  ci_method = c("analytical", "bootstrap"),
  boot_n = 1999,
  na_action = c("omit", "fail")
)

Value

An object of class c("pb_regression", "valytics_comparison", "valytics_result"), which is a list containing:

input

List with original data and metadata:

  • x, y: Numeric vectors (after NA handling)

  • n: Number of paired observations

  • n_excluded: Number of pairs excluded due to NAs

  • var_names: Named character vector with variable names

results

List with statistical results:

  • intercept: Intercept point estimate

  • slope: Slope point estimate

  • intercept_ci: Named numeric vector with lower and upper CI

  • slope_ci: Named numeric vector with lower and upper CI

  • residuals: Perpendicular residuals

  • fitted_x: Fitted x values

  • fitted_y: Fitted y values

cusum

List with CUSUM linearity test results (if calculable):

  • statistic: CUSUM test statistic

  • critical_value: Critical value at alpha = 0.05

  • p_value: Approximate p-value

  • linear: Logical; TRUE if linearity assumption holds

settings

List with analysis settings:

  • conf_level: Confidence level used

  • ci_method: CI method used

  • boot_n: Number of bootstrap samples (if applicable

call

The matched function call.

Arguments

x

Numeric vector of measurements from method 1 (reference method), or a formula of the form method1 ~ method2.

y

Numeric vector of measurements from method 2 (test method). Ignored if x is a formula.

data

Optional data frame containing the variables specified in x and y (or in the formula).

conf_level

Confidence level for intervals (default: 0.95).

ci_method

Method for calculating confidence intervals: "analytical" (default) uses the original Passing-Bablok (1983) method, "bootstrap" uses BCa bootstrap resampling.

boot_n

Number of bootstrap resamples when ci_method = "bootstrap" (default: 1999).

na_action

How to handle missing values: "omit" (default) removes pairs with any NA, "fail" stops with an error.

Interpretation

  • Slope = 1: No proportional difference between methods

  • Slope != 1: Proportional (multiplicative) difference exists

  • Intercept = 0: No constant difference between methods

  • Intercept != 0: Constant (additive) difference exists

Use the confidence intervals to test these hypotheses: if 1 is within the slope CI and 0 is within the intercept CI, the methods are considered equivalent.

Assumptions

  • Linear relationship between X and Y (test with CUSUM)

  • Measurement range covers the intended clinical range

  • Data are continuously distributed

CUSUM Test for Linearity

The CUSUM (cumulative sum) test checks the linearity assumption. A significant result (p < 0.05) suggests non-linearity, and Passing-Bablok regression may not be appropriate.

Details

Passing-Bablok regression is a non-parametric method for fitting a linear relationship between two measurement methods. Unlike ordinary least squares, it:

  • Makes no assumptions about error distribution

  • Accounts for measurement error in both variables

  • Is robust to outliers

  • Produces results independent of which variable is assigned to X or Y (when using the equivariant form)

The slope is estimated as the median of all pairwise slopes (in absolute value for the equivariant version), and the intercept is the median of y - slope * x.

References

Passing H, Bablok W (1983). A new biometrical procedure for testing the equality of measurements from two different analytical methods. Application of linear regression procedures for method comparison studies in clinical chemistry, Part I. Journal of Clinical Chemistry and Clinical Biochemistry, 21(11):709-720. tools:::Rd_expr_doi("10.1515/cclm.1983.21.11.709")

Passing H, Bablok W (1984). Comparison of several regression procedures for method comparison studies and determination of sample sizes. Application of linear regression procedures for method comparison studies in Clinical Chemistry, Part II. Journal of Clinical Chemistry and Clinical Biochemistry, 22(6):431-445. tools:::Rd_expr_doi("10.1515/cclm.1984.22.6.431")

Bablok W, Passing H, Bender R, Schneider B (1988). A general regression procedure for method transformation. Application of linear regression procedures for method comparison studies in clinical chemistry, Part III. Journal of Clinical Chemistry and Clinical Biochemistry, 26(11):783-790. tools:::Rd_expr_doi("10.1515/cclm.1988.26.11.783")

Raymaekers J, Dufey F (2022). Equivariant Passing-Bablok regression in quasilinear time. arXiv preprint. tools:::Rd_expr_doi("10.48550/arXiv.2202.08060")

See Also

plot.pb_regression() for visualization, summary.pb_regression() for detailed summary, ba_analysis() for Bland-Altman analysis

Examples

Run this code
# Simulated method comparison data
set.seed(42)
method_a <- rnorm(50, mean = 100, sd = 15)
method_b <- 1.05 * method_a + 3 + rnorm(50, sd = 5)  # slope=1.05, intercept=3

# Basic analysis
pb <- pb_regression(method_a, method_b)
pb

# Using formula interface with data frame
df <- data.frame(reference = method_a, test = method_b)
pb <- pb_regression(reference ~ test, data = df)

# With bootstrap confidence intervals
pb_boot <- pb_regression(method_a, method_b, ci_method = "bootstrap")

# Using package example data
data(glucose_methods)
pb <- pb_regression(reference ~ poc_meter, data = glucose_methods)
summary(pb)
plot(pb)

Run the code above in your browser using DataLab