Pedro Carmona Ibáñez
2013-Nov-21 07:19 UTC
[R] Cost function in cv. glm for a fitted logistic model when cutoff value of the model is not 0.5
I have a logistic model fitted with the following R function: glmfit<-glm(formula, data, family=binomial) A reasonable cutoff value in order to get a good data classification (or confusion matrix) with the fitted model is 0.2 instead of the mostly used 0.5. And I want to use the `cv.glm` function with the fitted model: cv.glm(data, glmfit, cost, K) Since the response in the fitted model is a binary variable an appropriate cost function is (obtained from "Examples" section of ?cv.glm): cost <- function(r, pi = 0) mean(abs(r-pi) > 0.5) As I have a cutoff value of 0.2, can I apply this standard cost function or should I define a different one and how? Thank you very much in advance, -- Pedro Carmona Departament de Comptabilitat Facultat d'Economia Universitat de València telf. 96 16 25 188 [[alternative HTML version deleted]]