deepankardatta / blandr

blandr: a Bland-Altman Method Comparison package for R
21 stars 11 forks source link

Blandr.method.comparison function, plot labels #18

Open Hendrina1 opened 5 years ago

Hendrina1 commented 5 years ago

Apologies beforehand if my question isn't asked right.

In an attempt to understand a few things, I was looking at the blandr.method.comparison function and I noticed that method 1 and method 2 labels appear to be switched. I may be missing something, but can someone help me verify this? As shown below

> 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[2]

> multiplier <- as.numeric(multiplier)

> intercept <- model$coefficients[1]

> 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")

> }`

Since the plot function is plot(x,y) shouldn't xlab then be method 2 and ylab be method 1?

DanielEWeeks commented 4 years ago

I agree - in the function 'blandr.method.comparison', the x and y labels are switched in this line of the code:

    plot(comparison.data$method2, comparison.data$method1, main = "Plot of two methods with line of equality", 
        xlab = "Method 1", ylab = "Method 2")