Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. # Bland-Altman plot R function.
  2. # Author: jmmateos@mce.hggm.es
  3. baplot <- function(m1, m2, ...) {
  4. # m1 and m2 are the measurements
  5. means <- (m1 + m2) / 2
  6. diffs <- m1 - m2
  7. mdiff <- mean(diffs)
  8. sddiff <- sd(diffs)
  9.  
  10. # Compute the figure limits
  11. ylimh <- mdiff + 3 * sddiff
  12. yliml <- mdiff - 3 * sddiff
  13.  
  14. # Plot data
  15. plot(diffs ~ means, xlab = "Average values",
  16. ylab = "Differences", ylim = c(yliml, ylimh), ...)
  17. abline(h = mdiff) # Center line
  18. # Standard deviations lines
  19. abline(h = mdiff + 1.96 * sddiff, lty = 2)
  20. abline(h = mdiff - 1.96 * sddiff, lty = 2)
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement