13
$\begingroup$

I have a question regarding the validity of using RMSE (Root Mean Squared Error) to compare different logistic models. The response is either 0 or 1 and the predictions are probabilities between 0-1?

Is the way applied below valid with the binary responses also?

##### Using glmnet
require(glmnet)
load(url("https://github.com/cran/glmnet/raw/master/data/BinomialExample.RData"))
cvfit = cv.glmnet(x, y, family="binomial", type.measure="mse")
A     = predict(cvfit, newx=x, s="lambda.min", type="response")
RMSE1 = mean((y - A)^2)
# 0.05816881

##### glm
mydata      = read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
mydata$rank = factor(mydata$rank)
mylogit     = glm(admit~gre+gpa+rank, data=mydata, family="binomial")
AAA         = predict(mylogit, newdata=mydata, type="response")
RMSE2       = mean((mydata$admit - AAA)^2)
# 0.194714
$\endgroup$
2
  • 2
    $\begingroup$ In this case it is called the Brier score, see actuaries.org/ASTIN/Colloquia/Hague/Papers/Lo.pdf $\endgroup$
    – user83346
    Commented Sep 17, 2015 at 16:16
  • $\begingroup$ Small clarification: The code in the question (RMSE = mean((y - A)^2)) shows mean squared error (MSE) calculations, which happen to be the same formula for the Brier score. RMSE (root mean squared error) would have an extra step: sqrt(mean((y - A)^2)) $\endgroup$
    – Brian D
    Commented Jun 14, 2023 at 19:13

2 Answers 2

22
$\begingroup$

To understand why "[t]he response is either 0 or 1 [but] the predictions are probabilities between 0-1", you need to understand the type of model you are working with. Strip away the penalization methods and the cross validation, and you are running a basic logistic regression. The parameters are fit on the log odds / logistic scale. This is called the "linear predictor". (For more on this, it may help you to read my answer here: Difference between logit and probit models.) If you plugged in an x value and simplified, the value would be the model's predicted natural logarithm of the odds of 'success' (1). If you exponentiated that value, you would have the model's predicted odds of 'success'. To get a predicted probability, you would need to convert the odds into a probability via odds/(1+odds). (For more on this, it may help you to read my answer here: Interpretation of simple predictions to odds ratios in logistic regression.) This still doesn't get you to a predicted class. To get that, you would need to compare your predicted probability to some threshold, and if it is less than the threshold predict 'failure' (0), else 'success' (1). The most common default threshold is .5, but this is often not optimal. R's predict.glm() function will allow you to use type="link", which outputs predictions on the scale of the linear predictor (i.e., before all those transformations above), but that won't help you in this context. Using type="response" gives you the predicted probabilities.


When you are trying to assess how well a binary (e.g., logistic) regression model predicts a response, you have several options:

  1. The first, and most intuitive is to compare the predicted class with the observed class and compute the percent correct. Although it is intuitive, it has problems. It is contingent, in part, on the threshold being optimal in addition to the other aspects of the model being fit appropriately. It also throws a lot of information away (i.e., how far from the threshold the predicted probability is), which isn't a good thing to do.
  2. Your next option is to use the area under the Receiver Operating Characteristic (ROC) curve. Most people use this option; it is considerably better than using the percent correct. The thing about the AUC that most people don't realize, though, is that it is actually measuring the appropriate ordering of your predictions, not their actual accuracy. That is, if you had predicted probabilities for four observations of .2, .4, .6, .8, and you added .01 to all of them (.21, .41, .61, .81), the AUC would be the same even though both sets of predicted probabilities cannot be equally accurate.
  3. The third way to assess your model would be to use a proper score function. Perhaps the most popular score function in your context is the Brier score. As @fcoppens notes, the method in your code is the Brier score. It will assess not only if the model appropriately predicts that one observation is more likely to be a 'success' than another observation, but if the model's predicted probability is actually correct.

It is unfortunate that the Brier score is less well known and used. Although the relative intuitiveness of these methods is: percent correct > AUC > Brier score, their true informativeness is the opposite: Brier score > AUC > percent correct. If you only want a simple measure of the performance of your model, the distinction between these methods is less important, but if you want to use these methods to optimize a model or to select a model, using an inferior method will lead to worse performance.

$\endgroup$
4
  • $\begingroup$ Hi there, I came to this amazing answer since I'd been using AUC/RMSE for logistic regression performance metrics, so I diligently went and used Brier score instead of RMSE. Then I realized that if you use probabilities/truth in RMSE formula, actually: RMSE**(1/2) = Brier. I'll keep using Brier, but I would like to hear your thoughts on this @gung - Reinstate Monica♦ $\endgroup$
    – Kieleth
    Commented Jul 14, 2020 at 16:16
  • $\begingroup$ @Kieleth, I don't follow your question. $\endgroup$ Commented Jul 14, 2020 at 16:36
  • 1
    $\begingroup$ Hey, thanks for following up; well, the original question was whether we can use RMSE for logistic models, your answer leads to use Brier instead. But if you compare the formulae: Brier = RMSE^(1/2) given that you use y^=y_probs and y=0/1_truth, the same way that was done in the question. So in a sense, yes, we can use RMSE for logistic regression model comparison, since it's just the square root of Brier. I think, unless I'm doing some stupid mistake here, that's what I wanted to know your opinion. $\endgroup$
    – Kieleth
    Commented Jul 14, 2020 at 17:30
  • 1
    $\begingroup$ @Kieleth, I'm still not sure I follow your question. I never intended my answer to imply you can't use RMSE. My point was that RMSE is just fine. $\endgroup$ Commented Jul 15, 2020 at 19:03
0
$\begingroup$

Using RMSE makes a lot more sense if your error term is distributed normally with mean zero, but in binary outcomes it is not. Therefore, I think you should use different approaches that lend themselves to binary outcomes, like comparing differences in likelihood.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.