ccc | R Documentation |
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.
ccc(data, real, predito)
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. |
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
A data frame with the following columns:
r
: Pearson correlation coefficient
ccc
: Lin's Concordance Correlation Coefficient
rmse
: Root mean squared error
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.