| plot.ba_analysis | R Documentation |
Creates a Bland-Altman plot (difference vs. average) for visualizing agreement between two measurement methods. The plot displays the bias (mean difference) and limits of agreement with optional confidence intervals.
## S3 method for class 'ba_analysis'
plot(
x,
show_ci = TRUE,
show_points = TRUE,
point_alpha = 0.6,
point_size = 2,
line_colors = NULL,
title = NULL,
xlab = NULL,
ylab = NULL,
...
)
## S3 method for class 'ba_analysis'
autoplot(
object,
show_ci = TRUE,
show_points = TRUE,
point_alpha = 0.6,
point_size = 2,
line_colors = NULL,
title = NULL,
xlab = NULL,
ylab = NULL,
...
)
x |
An object of class |
show_ci |
Logical; if |
show_points |
Logical; if |
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 |
Character; x-axis label. If |
ylab |
Character; y-axis label. If |
... |
Additional arguments (currently ignored). |
object |
An object of class |
The Bland-Altman plot displays:
Points: Each point represents a paired observation, plotted as the difference (y - x) against the average ((x + y) / 2).
Bias line: Solid horizontal line at the mean difference.
Limits of agreement: Dashed horizontal lines at bias +/- 1.96 x SD.
Confidence intervals: Shaded bands showing the uncertainty in the bias and LoA estimates.
Patterns to look for:
Funnel shape: Suggests proportional bias (variance increases with magnitude).
Trend: Suggests systematic relationship between difference and magnitude.
Outliers: Points outside the LoA may warrant investigation.
A ggplot object that can be further customized.
ba_analysis() for performing the analysis,
summary.ba_analysis() for detailed results
# Basic Bland-Altman plot
set.seed(42)
method_a <- rnorm(50, mean = 100, sd = 15)
method_b <- method_a + rnorm(50, mean = 2, sd = 5)
ba <- ba_analysis(method_a, method_b)
plot(ba)
# Without confidence intervals
plot(ba, show_ci = FALSE)
# Customized appearance
plot(ba,
point_alpha = 0.8,
point_size = 3,
title = "Method Comparison: A vs B")
# Further customization with ggplot2
library(ggplot2)
plot(ba) +
theme_minimal() +
scale_color_brewer(palette = "Set1")
# Using autoplot (ggplot2-style)
autoplot(ba)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.