
Computes the True and False Positive Rates (TPR and FPR, respectively) and Area Under the Curve (AUC) by comparing the true (observed) and predicted status using a range of thresholds on the predicted score.
ROC(observed, predicted, n_thr = NULL)
A list with:
True Positive Rate.
False Positive Rate.
Area Under the Curve.
vector of binary outcomes.
vector of predicted scores.
number of thresholds to use to construct the ROC curve. For
faster computations on large data, values below length(predicted)-1
can be used.
Other goodness of fit functions:
Concordance()
# \donttest{
# Data simulation
set.seed(1)
simul <- SimulateRegression(
n = 500, pk = 20,
family = "binomial", ev_xy = 0.8
)
# Logistic regression
fitted <- glm(simul$ydata ~ simul$xdata, family = "binomial")$fitted.values
# Constructing the ROC curve
roc <- ROC(predicted = fitted, observed = simul$ydata)
plot(roc)
# }
Run the code above in your browser using DataLab