matthews_coeff: Matthews Correlation Coefficient (MCC)

View source: R/metrics.R

matthews_coeffR Documentation

Matthews Correlation Coefficient (MCC)

Description

Given the observed and predicted values of binary data computes the Matthews Correlation Coefficient (MCC) also known as Phi Coefficient or Mean Square Contingency Coefficient.

Usage

matthews_coeff(observed, predicted, remove_na = TRUE)

Arguments

observed

(factor) The observed values. It has to have the same length as predicted.

predicted

(factor) The observed values. It has to have the same length as observed.

remove_na

(logical(1)) Should NA values be removed?. TRUE by default.

Details

Given the following binary confusion matrix:

Binary confusion matrix

Matthews Correlation Coefficient (MCC) is computed as:

(TN x TP - FN x FP) / (sqrt((TP + FP)(TP + FN)(TN + FP)(TN + FN)))

Value

A single numeric value with the Matthews Correlation Coefficient.

See Also

Other categorical_metrics: accuracy(), brier_score(), categorical_summary(), confusion_matrix(), f1_score(), kappa_coeff(), math_mode(), pccc(), pcic(), pr_auc(), precision(), recall(), roc_auc(), sensitivity(), specificity()

Examples

## Not run: 
matthews_coeff(factor(c("a", "b")), factor(c("a", "b")))
matthews_coeff(factor(c("a", "b")), factor(c("b", "a")))
matthews_coeff(factor(c("a", "b")), factor(c("b", "b")))
matthews_coeff(factor(c(TRUE, FALSE)), factor(c(FALSE, TRUE)))

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.