mylogit <- function(formula, data){
m <- structure(
glm(formula=formula,data=data,family=binomial(link="logit")),
class=c("svrclass","glm") #IMPORTANT - must use the class svrclass to work correctly
)
return(m)
}
mypred <- function(m,newdata){
out <- predict.glm(m,newdata,type="response")
out <- factor(ifelse(out>0.5,1,0),levels=c("0","1"))
#Important - must specify levels to account for possibility of all
#observations being classified into the same class in smaller samples
return(out)
}
# \donttest{
library(parallel)
results <- estimate_accuracy(two_year_recid ~ race +
sex + age + juv_fel_count + juv_misd_count + priors_count +
charge_degree..misd.fel.,mylogit,br,predictfn = mypred,
nsample=10,
steps=1000,
coreoffset = (detectCores() -2))
resultsalt <- getpac(results,epsilon=0.5,delta=0.3)
print(resultsalt$Summary)
# }
Run the code above in your browser using DataLab