| ba_analysis | R Documentation |
Performs Bland-Altman analysis to assess agreement between two measurement methods. Calculates bias (mean difference), limits of agreement, and confidence intervals following the approach of Bland & Altman (1986, 1999).
ba_analysis(
x,
y = NULL,
data = NULL,
conf_level = 0.95,
type = c("absolute", "percent"),
na_action = c("omit", "fail")
)
x |
Numeric vector of measurements from method 1 (reference method),
or a formula of the form |
y |
Numeric vector of measurements from method 2 (test method).
Ignored if |
data |
Optional data frame containing the variables specified in
|
conf_level |
Confidence level for intervals (default: 0.95). |
type |
Type of difference calculation: |
na_action |
How to handle missing values: |
The Bland-Altman method assesses agreement between two quantitative measurements by analyzing the differences against the averages. The key outputs are:
Bias: The mean difference between methods, indicating systematic difference. A bias significantly different from zero suggests one method consistently measures higher or lower than the other.
Limits of Agreement (LoA): The interval within which 95\ differences are expected to lie (bias +/- 1.96 x SD). These define the range of disagreement between methods.
Confidence Intervals: CIs for bias and LoA quantify the uncertainty in these estimates due to sampling variability.
The confidence intervals for limits of agreement are calculated using the exact method from Bland & Altman (1999), which accounts for the uncertainty in both the mean and standard deviation.
An object of class c("ba_analysis", "valytics_comparison", "valytics_result"),
which is a list containing:
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
List with statistical results:
differences: Numeric vector of differences (y - x or percent)
averages: Numeric vector of means ((x + y) / 2)
bias: Mean difference (point estimate)
bias_se: Standard error of the bias
bias_ci: Named numeric vector with lower and upper CI for bias
sd_diff: Standard deviation of differences
loa_lower: Lower limit of agreement (bias - 1.96 * SD)
loa_upper: Upper limit of agreement (bias + 1.96 * SD)
loa_lower_ci: Named numeric vector with CI for lower LoA
loa_upper_ci: Named numeric vector with CI for upper LoA
List with analysis settings:
conf_level: Confidence level used
type: Type of difference calculation
multiplier: Multiplier for LoA (default: 1.96 for 95\
The matched function call.
The standard Bland-Altman analysis assumes:
Differences are approximately normally distributed
No proportional bias (constant bias across the measurement range)
No repeated measurements per subject
Bland JM, Altman DG (1986). Statistical methods for assessing agreement between two methods of clinical measurement. Lancet, 1(8476):307-310. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/S0140-6736(86)90837-8")}
Bland JM, Altman DG (1999). Measuring agreement in method comparison studies. Statistical Methods in Medical Research, 8(2):135-160. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1177/096228029900800204")}
plot.ba_analysis() for visualization,
summary.ba_analysis() for detailed summary
# Simulated method comparison data
set.seed(42)
method_a <- rnorm(50, mean = 100, sd = 15)
method_b <- method_a + rnorm(50, mean = 2, sd = 5) # Method B has +2 bias
# Basic analysis
ba <- ba_analysis(method_a, method_b)
ba
# Using formula interface with data frame
df <- data.frame(reference = method_a, test = method_b)
ba <- ba_analysis(reference ~ test, data = df)
# Percentage differences
ba_pct <- ba_analysis(method_a, method_b, type = "percent")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.