1

I am doing some analysis regarding a binomial glm model that I have fitted earlier in R. While looking at my data, I figured out that the suitable cutoff point for my binary outcome should be 0.75 instead of 0.5. I am trying to get the cost() function of the cv.glm() {boot package} to use the 0.75 cutoff point, but I have failed to get the right syntax.

I know for the 0.5 cutoff we normally use:

cost <- function(r, pi = 0) mean(abs(r-pi) > 0.5)

Can someone show me what is the right way to change the cutoff point in this function? (let's stick to 0.75 maybe).

tshepang
  • 12,111
  • 21
  • 91
  • 136
Error404
  • 6,959
  • 16
  • 45
  • 58
  • 2
    Is it possible that you are confusing cross validation with some other sort of penalty with coefficient estimations? If you look at the code for `cv.glm` you will see that the default cost function is `cost = function(y, yhat) mean((y - yhat)^2)`. It is only calculating a "cost" between the predicted `yhat`and the observed `y`(in this case "mean squared error"). – Marc in the box Mar 10 '14 at 12:51
  • Oh so the MSE does not change with changing the cutoff point. I see what you mean. Thanks for pointing this out! – Error404 Mar 10 '14 at 12:57
  • The MSE does not change with changing the cutoff point, but it is not the best performance measure for binomial outcomes. You could implement an ad hoc cost function with choice of threshold looking at this thread: http://stackoverflow.com/questions/16781551/cost-function-in-cv-glm-of-boot-library-in-r – Avitus Jul 24 '14 at 09:28

0 Answers0