#deviance loss function loss = function(y,phat,wht=0.0000001) { #y should be 0/1 #wht shrinks probs in phat towards .5, don't log 0! if(is.factor(y)) y = as.numeric(y)-1 phat = (1-wht)*phat + wht*.5 py = ifelse(y==1,phat,1-phat) return(-2*sum(log(py))) }