Concordance Correlation Coefficient

ccc.numeric R Documentation

Description

A generic function for the concordance correlation coefficient. Use weighted.ccc() for the weighted concordance correlation coefficient.

Usage

## S3 method for class 'numeric'
ccc(actual, predicted, correction = FALSE, ...)

## S3 method for class 'numeric'
weighted.ccc(actual, predicted, w, correction = FALSE, ...)

ccc(
 ...,
 correction = FALSE
)

weighted.ccc(
 ...,
 w,
 correction = FALSE
)

Arguments

actual

A <numeric>-vector of length \(n\). The observed (continuous) response variable.

predicted

A <numeric>-vector of length \(n\). The estimated (continuous) response variable.

correction

A vector of length \(1\) (default: FALSE). If TRUE the variance and covariance will be adjusted with \(\frac{1-n}{n}\)

Arguments passed into other methods.

w

A <numeric>-vector of length \(n\). The weight assigned to each observation in the data.

Value

A <numeric> vector of length 1.

Definition

Let \(\rho_c \in [0,1]\) measure the agreement between \(y\) and \(\upsilon\). The classifier agreement is calculated as,

\[ \rho_c = \frac{2 \rho \sigma_{\upsilon} \sigma_y}{\sigma_{\upsilon}^2 + \sigma_y^2 + (\mu_{\upsilon} - \mu_y)^2} \]

Where:

  • \(\rho\) is the pearson correlation coefficient

  • \(\sigma_y\) is the unbiased standard deviation of \(y\)

  • \(\sigma_{\upsilon}\) is the unbiased standard deviation of \(\upsilon\)

  • \(\mu_y\) is the mean of \(y\)

  • \(\mu_{\upsilon}\) is the mean of \(\upsilon\)

If correction == TRUE each \(\sigma_{i \in [y, \upsilon]}\) is adjusted by \(\frac{1-n}{n}\)

Examples

# 1) fit a linear
# regression
model <- lm(
  mpg ~ .,
  data = mtcars
)

# 1.1) define actual
# and predicted values
# to measure performance
actual    <- mtcars$mpg
predicted <- fitted(model)

# 2) evaluate in-sample model
# performance
cat(
  "Concordance Correlation Coefficient", ccc(
    actual     = actual,
    predicted  = predicted,
    correction = FALSE
  ),
  "Concordance Correlation Coefficient (corrected)", ccc(
    actual     = actual,
    predicted  = predicted,
    correction = TRUE
  ),
  "Concordance Correlation Coefficient (weigthed)", weighted.ccc(
    actual     = actual,
    predicted  = predicted,
    w          = mtcars$mpg/mean(mtcars$mpg),
    correction = FALSE
  ),
  sep = "\n"
)