Learn R Programming

alookr (version 0.5.0)

matthews: Compute Matthews Correlation Coefficient

Description

compute the Matthews correlation coefficient with actual and predict values.

Usage

matthews(predicted, y, positive)

Value

numeric. The Matthews Correlation Coefficient.

Arguments

predicted

numeric. the predicted value of binary classification

y

factor or character. the actual value of binary classification

positive

level of positive class of binary classification

Details

The Matthews Correlation Coefficient has a value between -1 and 1, and the closer to 1, the better the performance of the binary classification.

Examples

Run this code
# simulate actual data
set.seed(123L)
actual <- sample(c("Y", "N"), size = 100, prob = c(0.3, 0.7), replace = TRUE)
actual

# simulate predict data
set.seed(123L)
pred <- sample(c("Y", "N"), size = 100, prob = c(0.2, 0.8), replace = TRUE)
pred

# simulate confusion matrix
table(pred, actual)

matthews(pred, actual, "Y")

Run the code above in your browser using DataLab