R/CONCORD.r

Defines functions CONCORD

Documented in CONCORD

### ====================================================================================
### function to compute concordance measure (closeness to a 45 degree line through zero)
### i.e., closeness to exact numerical agreement
CONCORD <- function(x1,x2, scaled=FALSE) {
  # Scale x2 when scaled = TRUE
  if (scaled) {
    beta <- sum(x1 * x2) / sum(x2^2) # regression coeff. for x1 = b* x2
    x2 <- beta * x2
  }
  
  # Lin's coefficient of concordance
  s1 <- sd(x1)
  s2 <- sd(x2)
  corr <- cor(x1,x2)
  concord <- 2*corr*s1*s2 / ((mean(x1) - mean(x2))^2 + s1^2 + s2^2)
  concord
}

Try the easyCODA package in your browser

Any scripts or data that you put into this service are public.

easyCODA documentation built on Nov. 24, 2026, 1:07 a.m.