[R] glmer() -> corrected AUC optimism by bootstraping technic bootMer() [internal validation of a mixed-effects-model]

Andreu Ferrero Gmail fromnorden at gmail.com
Thu Mar 24 14:34:45 CET 2016



> 
> 
> I would like to do an internal validation of a discriminative ability of a mixed effects models.
> 
> Here is my scrip:
> 
> ###########################
> ####bootMer-> boot AUC#####
> ###########################
> 
> library(lme4)
> library(lattice)
> data(cbpp)
> 
> #fit a model
> 
> cbpp$Y<-cbpp$incidence>=1
> glmm<-glmer(Y~period + size + (1|herd), family=binomial, data=cbpp)
> glmm
> 
> ##### funcio: versio 3 - no cal posar endpoint en la funcio
> ##########################################################
> 
> 
> 
> AUCFun <- function(fit) {
>  library(pROC)
>  pred<-predict(fit, type="response")
>  AUC<-as.numeric(auc(fit at resp$y, pred))
> }
> 
> 
> #test
> 
> (AUCFun(glmm))
> 
> ###run bootMer: AUCFun
> 
> 
> 
> system.time(AUC.boot <- bootMer(glmm,nsim=100,FUN=AUCFun,seed=1982, use.u=TRUE,
>                                type="parametric", parallel="multicore", ncpus=2))
> 
> 
> #...
> 
> (boot.ci(AUC.boot, index =c(1,1), type="norm"))
> 
> roc(cbpp$Y, predict(glmm, type="response"))
> 
> 
> #Now it seems more reasonable, bias as "optimism"... but still do not know #if I am just doing a AUC with bootstrap CI 
> **************************************************************************************************************************************
> 
> 
> 



More information about the R-help mailing list