 # understanding a blandr function for method comparison plot

I was trying to edit an inbuilt function from `blandr` package in order to switch method 1 and method 2 axes. Looking at the code, I think there might be a small error to begin with and would like expert advice on this. The original code is

``````function (method1, method2, sig.level = 0.95)
{
comparison.data <- blandr.data.preparation(method1, method2,
sig.level)
cat("\nNote as per Bland and Altman 1986 linear correlation DOES NOT mean agreement. ")
cat("Data which seem to be in poor agreement can produce quite high correlations. ")
cat("Line of equality in dashed black, linear regression model in solid red.\n")
model <- lm(comparison.data\$method1 ~ comparison.data\$method2)
multiplier <- model\$coefficients
multiplier <- as.numeric(multiplier)
intercept <- model\$coefficients
intercept <- as.numeric(intercept)
plot(comparison.data\$method2, comparison.data\$method1, main = "Plot of two methods with line of equality",
xlab = "Method 1", ylab = "Method 2")
abline(0, 1, lty = 2)
abline(model, col = "red")
results.paired.t.test <- t.test(comparison.data\$method1,
comparison.data\$method2, paired = TRUE)
cat("\nPaired T-tests evaluate for significant differences between the means of two sets of data. It does not test agreement, as the results of a T-test can be hidden by the distribution of differences. See the references for further reading.\n")
cat("Paired T-test p-value: ", results.paired.t.test\$p.value,
"\n")
cat("\nCorrelation coefficients only tell us the linear relationship between 2 variables and nothing about agreement.\n")
cat("Correlation coefficient:", cor(comparison.data\$method1,
comparison.data\$method2), "\n")
cat("\nLinear regression models, are conceptually similar to correlation coefficients, and again tell us nothing about agreement.\n")
cat("Using method 1 to predict the dependent method 2, using least squares regression.\n")
cat("Regression equation: method 2 = ", multiplier, "x method 1 + ",
intercept, "\n")
}
#> function (method1, method2, sig.level = 0.95)
#> {
#>   comparison.data <- blandr.data.preparation(method1, method2,
#>     sig.level)
#>   cat("\nNote as per Bland and Altman 1986 linear correlation DOES NOT mean agreement. ")
#>   cat("Data which seem to be in poor agreement can produce quite high correlations. ")
#>   cat("Line of equality in dashed black, linear regression model in solid red.\n")
#>   model <- lm(comparison.data\$method1 ~ comparison.data\$method2)
#>   multiplier <- model\$coefficients
#>   multiplier <- as.numeric(multiplier)
#>   intercept <- model\$coefficients
#>   intercept <- as.numeric(intercept)
#>   plot(comparison.data\$method2, comparison.data\$method1, main = "Plot of two methods with line of equality",
#>     xlab = "Method 1", ylab = "Method 2")
#>   abline(0, 1, lty = 2)
#>   abline(model, col = "red")
#>   results.paired.t.test <- t.test(comparison.data\$method1,
#>     comparison.data\$method2, paired = TRUE)
#>   cat("\nPaired T-tests evaluate for significant differences between the means of two sets of data. It does not test agreement, as the results of a T-test can be hidden by the distribution of differences. See the references for further reading.\n")
#>   cat("Paired T-test p-value: ", results.paired.t.test\$p.value,
#>     "\n")
#>   cat("\nCorrelation coefficients only tell us the linear relationship between 2 variables and nothing about agreement.\n")
#>   cat("Correlation coefficient:", cor(comparison.data\$method1,
#>     comparison.data\$method2), "\n")
#>   cat("\nLinear regression models, are conceptually similar to correlation coefficients, and again tell us nothing about agreement.\n")
#>   cat("Using method 1 to predict the dependent method 2, using least squares regression.\n")
#>   cat("Regression equation: method 2 = ", multiplier, "x method 1 + ",
#>     intercept, "\n")
#> }
``````

About 12 lines down, the plot function shows method 2 versus method 1. Using the plot function it would be `plot(x,y)` making method 2=x and method 1= y no? but looking at the axis labels, they seem switched and I get this output

What I want is to have method 2 on the x axis and method 1 on the y axis, so is it right to assume that I just need to change the labels to `xlab="method2", ylab="method1"` and nothing else? Or do i still need to change the order of method 1 and 2 in the whole function.

Hi,

It's always a good idea that if you think there is something wrong (or can be improved) with a specific R package, you open an issue on the package's gitHub page. This will directly involve the creators of the package and people who are familiar with it.

Of course there might be some people on here who can help you as well, but if there is an error or something that needs to be changed, you need to contact the creators anyway through gitHub.

Hope this helps,
PJ

Thanks for the input. I will try gitHub

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.