bland.altman.repeated.vary <- function(fmla, dat) { ## Purpose: Calculate LoA (Limit of Agreement) when data has repeated measurements (true value varies) ## Arguments: ## fmla: something like "Difference ~ Subject". ## dat: data frame with "Difference" and "Subject". ## Return: LoA ## Author: Feiming Chen ## Reference: ## Bland, J. Martin, and Douglas G. Altman. "Agreement between methods of measurement with multiple observations per ## individual." Journal of biopharmaceutical statistics 17.4 (2007): 571-582. ## ________________________________________________ ans <- var.comp.one.way.model(fmla, dat) s <- ans$VCA$SD[3] m <- ans$Mean cat("\nMean =", m, ", SD =", s, "\n") loa <- c(m - 1.96*s, m + 1.96*s) cat("\n95% Limits of Agreement: (", loa[1], ",", loa[2], ")\n") invisible(list(m=m, s=s, loa=loa)) } if (F) { # Unit Test dat <- data.frame(Subject = factor(c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3)), A = rnorm(10, 10), B = rnorm(10, 10)) dat$Difference <- dat$A - dat$B fmla <- Difference ~ Subject bland.altman.repeated.vary(fmla, dat) ## Mean = 0.0997215 , SD = 1.851 ## 95% Limits of Agreement: ( -3.528239 , 3.727681 ) }
Tuesday, March 5, 2019
Bland Altman Limit of Agreement Calculation with the presence of repeated measurements where the true value vary
Refer to this blog post for the function var.comp.one.way.model
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment