1

I am trying to do a ROC curve in R but I am having some difficulty. I have the following code:

library(ROCR)
train.pred <- prediction(predict(LOL.out,type="response"),LOL.train$Win)
train.perf <- performance(train.pred,measure="tpr", x.measure="fpr")
plot(train.perf,xlab="1-specificity",ylab="sensitivity", main="ROC curve")
abline(0,1,col="gray")

The LOL.out is the output from my linear model and I am trying to predict wins. The difficultly I have is that when I run the code the first time in a new R environment, it runs fine. However, when I run the exact same code again, it gives me the following output:

Error in ets(object, lambda = lambda, biasadj = biasadj, allow.multiplicative.trend = allow.multiplicative.trend,  : 
  No model able to be fitted

When I restart R again, it sometimes runs fine but I cannot run the code more than once or I get the same error. In trying to implement this code elsewhere on other projects, I get the same error there. The problem lies in the prediction() function. I have been trying to find more information on this function and debugging it but there doesn't seem to be a lot of documentation on it. I have had issues with this in the past. Does anyone know a good solution to this? What experiences has everyone else had with the prediction() function?

Jason
  • 35
  • 4
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Nov 05 '21 at 02:00
  • Please provide enough code so others can better understand or reproduce the problem. – Community Nov 05 '21 at 09:19
  • Sorry for not providing enough code. The problem was that there is another prediction function in R that it sometimes uses. I had to specify the package that I need to use with ROCR:: – Jason Feb 22 '22 at 16:22

0 Answers0