| plot.pb_regression | R Documentation |
Creates publication-ready plots for Passing-Bablok regression results. Multiple plot types are available: scatter plot with regression line, residual plot, and CUSUM plot for linearity assessment.
## S3 method for class 'pb_regression'
plot(
x,
type = c("scatter", "residuals", "cusum"),
show_ci = TRUE,
show_identity = TRUE,
residual_type = c("fitted", "rank"),
point_alpha = 0.6,
point_size = 2,
line_colors = NULL,
title = NULL,
xlab = NULL,
ylab = NULL,
...
)
## S3 method for class 'pb_regression'
autoplot(
object,
type = c("scatter", "residuals", "cusum"),
show_ci = TRUE,
show_identity = TRUE,
residual_type = c("fitted", "rank"),
point_alpha = 0.6,
point_size = 2,
line_colors = NULL,
title = NULL,
xlab = NULL,
ylab = NULL,
...
)
x |
An object of class |
type |
Character; type of plot to create:
|
show_ci |
Logical; if |
show_identity |
Logical; if |
residual_type |
Character; for |
point_alpha |
Numeric; transparency of points (0-1, default: 0.6). |
point_size |
Numeric; size of points (default: 2). |
line_colors |
Named character vector with colors for |
title |
Character; plot title. If |
xlab, ylab |
Character; axis labels. If |
... |
Additional arguments (currently ignored). |
object |
An object of class |
Scatter plot (type = "scatter"):
Displays the raw data with the fitted Passing-Bablok regression line and
optional confidence band. The identity line (y = x) is shown for reference.
If the regression line overlaps substantially with the identity line, the
methods are in good agreement.
Residual plot (type = "residuals"):
Displays perpendicular residuals. Look for:
Random scatter around zero (good)
Patterns or trends (suggests non-linearity)
Funnel shape (suggests heteroscedasticity)
CUSUM plot (type = "cusum"):
Displays the cumulative sum of residual signs, used to assess linearity.
The CUSUM should stay within the critical bounds if the linearity assumption
holds.
A ggplot object that can be further customized.
pb_regression() for performing the analysis,
summary.pb_regression() for detailed results
set.seed(42)
method_a <- rnorm(50, mean = 100, sd = 15)
method_b <- 1.05 * method_a + 3 + rnorm(50, sd = 5)
pb <- pb_regression(method_a, method_b)
# Scatter plot with regression line
plot(pb)
# Without identity line
plot(pb, show_identity = FALSE)
# Residual plot
plot(pb, type = "residuals")
# Residuals by rank
plot(pb, type = "residuals", residual_type = "rank")
# CUSUM plot
plot(pb, type = "cusum")
# Customized appearance
plot(pb, point_size = 3, title = "Glucose: POC vs Reference")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.