title: How to plot ROC-curve for logistic regression (LASSO) in R?
body: <p>I am fitting a logistic regression model to a training data set in R, more specifically a LASSO regression with an L1 penalty. I used the <code>glmnet</code>package for that. The code for the model looks like this.</p>
  
  <pre><code>t1 &lt;- Sys.time()
  glmnet_classifier &lt;- cv.glmnet(x = dtm_train_tfidf,
                             y = tweets_train[['sentiment']], 
                             family = 'binomial', 
                             # L1 penalty
                             alpha = 1,
                             # interested in the area under ROC curve
                             type.measure = "auc",
                             # 5-fold cross-validation
                             nfolds = 5,
                             # high value is less accurate, but has faster training
                             thresh = 1e-3,
                             # again lower number of iterations for faster training
                             maxit = 1e3)
  print(difftime(Sys.time(), t1, units = 'mins'))
  
  preds &lt;- predict(glmnet_classifier, dtm_test_tfidf, type = 'response')[ ,1]
  </code></pre>
  
  <p>Now I would like to plot the ROC-curve. However, I cannot figure out how to accurately plot it. </p>
  
  <p>When I <code>plot(glmnet_classifier)</code>this is what I receive:
  <a href="https://i.stack.imgur.com/BORT1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BORT1.png" alt="Plot of classifier"></a></p>
  
  <p>Since this is not the Roc-curve, I would like to know if anybody knows how to plot it in R? I already referred to the <code>ROCR</code>package, but it gives me an error:</p>
  
  <pre><code>roc.perf = performance(preds, measure = "tpr", x.measure = "fpr")
  </code></pre>
  
  <p>Can anybody help? 
  Thank you very much!</p>