View source: R/goodness_of_fit.R
ROC | R Documentation |
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)
observed |
vector of binary outcomes. |
predicted |
vector of predicted scores. |
n_thr |
number of thresholds to use to construct the ROC curve. For
faster computations on large data, values below |
A list with:
TPR |
True Positive Rate. |
FPR |
False Positive Rate. |
AUC |
Area Under the Curve. |
Other goodness of fit functions:
Concordance()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.