ROC curves
Cut-off values other than 0.5 can be chosen as well but, the number of potential cut-offs is high and looking at hundreds of tables can be time-consuming. Creating a ROC curve can help you.
Such a graph can be created by using the function roc() from the add-on package pROC. The function roc() takes as inputs the vector of observed responses (typically encoded as 0 and 1) and a vector of predicted values of the same length. Again, you obtain the observed HOPPINESS purchases from the choice.data object. The predicted values are obtained by applying the function fitted() on the extended.model object. The corresponding ROC curve is created by applying the function plot() on the resulting roc object.
Este ejercicio forma parte del curso
Building Response Models in R
Instrucciones del ejercicio
- Load the add-on package
pROCby using the functionlibrary(). - Obtain the observed purchases for
HOPPINESSfromchoice.dataand assign them to an objectobserved. - Create an
rocobject by using the functionrocon the observed responses entailedchoice.dataand the predicted values obtained from theextended.model. Assign the result to an object calledROC. - Plot the ROC curve by using the function
plot()on theROCobject.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Load the pROC package
# Obtain the observed purchases
observed <- ___
# Create the Roc object
ROC <- roc(predictor = ___, response = ___)
# Plot the ROC curve