ccc: Lin's Concordance Correlation Coefficient (CCC)

View source: R/utilities.R

cccR Documentation

Lin's Concordance Correlation Coefficient (CCC)

Description

Computes Lin's Concordance Correlation Coefficient (CCC) between observed and predicted values. Also returns Pearson's correlation coefficient and root mean squared error (RMSE). If the input is a grouped data frame (grouped_df), the function will return results for each group.

Usage

ccc(data, real, predito)

Arguments

data

A data frame containing the columns for observed and predicted values.

real

The column name (unquoted) corresponding to the observed values.

predito

The column name (unquoted) corresponding to the predicted values.

Details

The CCC is defined as:

\rho_c = \frac{2 \cdot \text{Cov}(x, y)}{\text{Var}(x) + \text{Var}(y) + (\bar{x} - \bar{y})^2}

where:

  • \text{Cov}(x, y) is the covariance between observed and predicted values

  • \text{Var}(x) and \text{Var}(y) are the variances of the observed and predicted values

  • \bar{x} and \bar{y} are the means of the observed and predicted values

Value

A data frame with the following columns:

  • r: Pearson correlation coefficient

  • ccc: Lin's Concordance Correlation Coefficient

  • rmse: Root mean squared error

Examples

library(dplyr)
library(pliman)
df <- data.frame(
  group = rep(c("A", "B"), each = 5),
  real = c(1:5, 2:6),
  predicted = c(1.1, 2, 2.9, 4.1, 5, 2.2, 3.1, 4, 4.8, 6.1)
)

# Without grouping
ccc(df, real, predicted)

# With grouping
df |>
  group_by(group) |>
  ccc(real, predicted)


pliman documentation built on Aug. 21, 2025, 5:46 p.m.

Related to ccc in pliman...