Skip to contents

Calculates various performance metrics for an oblr model.

Usage

computeMetrics(object, newdata = NULL, cutoff = 0.5)

Arguments

object

An object of class "oblr".

newdata

A data frame or data.table containing new data for evaluation. If NULL, uses the data from the fit.

cutoff

The probability cutoff for class prediction. Default is 0.5.

Value

A data.table with the calculated metrics.

Details

This function calculates the following metrics:

  1. Log-likelihood (LogLik): $$LogLik = \sum_{i=1}^n [y_i \log(p_i) + (1-y_i) \log(1-p_i)]$$ where \(y_i\) are the observed values and \(p_i\) are the predicted probabilities.

  2. Akaike Information Criterion (AIC): $$AIC = 2k - 2LogLik$$ where \(k\) is the number of parameters in the model.

  3. Bayesian Information Criterion (BIC): $$BIC = k\log(n) - 2LogLik$$ where \(n\) is the number of observations.

  4. Area Under the ROC Curve (AUC): AUC is the area under the Receiver Operating Characteristic curve, which plots the true positive rate against the false positive rate.

  5. Gini Coefficient: $$Gini = 2 * AUC - 1$$

  6. Kolmogorov-Smirnov Statistic (KS): $$KS = \max|F_1(x) - F_0(x)|$$ where \(F_1(x)\) and \(F_0(x)\) are the cumulative distribution functions for the positive and negative classes, respectively.

  7. Accuracy: $$Accuracy = \frac{TP + TN}{TP + TN + FP + FN}$$ where TP = True Positives, TN = True Negatives, FP = False Positives, FN = False Negatives.

  8. Recall (Sensitivity): $$Recall = \frac{TP}{TP + FN}$$

  9. Precision: $$Precision = \frac{TP}{TP + FP}$$

  10. F1-Score: $$F1 = 2 * \frac{Precision * Recall}{Precision + Recall}$$

These metrics provide a comprehensive view of the model's performance, including its predictive capability (AUC, KS), fit to the data (LogLik, AIC, BIC), and performance in classification tasks (Accuracy, Recall, Precision, F1-Score).