[RsR] BCa bootstrapped CIs for glmrob

varin sacha v@r|n@@ch@ @end|ng |rom y@hoo@|r
Sun Aug 7 20:40:22 CEST 2016


Dear R-experts,

I am trying to calculate the BCa bootstrapped confidence intervals of a robust (binary) logistic regression. The end of my code is not working, I get an error message. Would it be possible to tell me what is going wrong ? Thanks


Here is the reproducible example (fake dataset) :

Dataset = data.frame(answered=c("femme","homme","homme","femme","femme","homme","homme","homme","femme","homme","femme","femme","homme","femme","homme","homme","femme","femme","homme","homme","femme","femme","homme","femme","homme","femme","homme","homme","femme","homme","homme","femme","homme","femme"),

QUALITESANSREDONDANCE=c(1082.5,1066.6,1079.3,1079.9,1074.9,1008.6,1007.5,1111.3,1108.2,1109.7,1059.6,1165.1,1026.7,1035.1,997.8,1044.8,1073.6,1085.7,1083.8,1021.6,1036.2,1075.3,1069.3,1101.4,1086.9,1072.1,1166.7,983.9,1004.5,1082.5,1123.5,1094.9,1105.1,1010.8),

competitivite=c(89,83,78,73,90,71,77,85,61,67,98,82,70,43,57,78,72,79,61,71,86,63,90,75,87,64,60,56,66,80,53,91,97,62),

innovation=c(56,52,53,54,57,43,54,60,47,55,58,62,52,35,47,59,56,56,45,52,58,33,57,57,61,40,45,41,50,61,50,65,68,34),

satisfait=c(1,2,3,4,3,2,1,2,3,4,4,3,2,2,1,1,2,3,4,3,2,1,2,3,4,1,2,3,4,3,2,1,2,3))

Dataset$satisfait=factor(Dataset$satisfait,levels=c(1,2,3,4),labels=c("pas satisfait", "moyennement satisfait", "satisfait", "très satisfait"))
as.ordered(Dataset$satisfait)

library("robustbase")
newdata=na.omit(Dataset)

fm.glmrob=glmrob(answered ~ QUALITESANSREDONDANCE + competitivite + innovation + satisfait, data=newdata, family=binomial)
fm.glmrob

boot.GLMrob=function(formula,data,indices)
{
d=data[indices,]
fit=glmrob(formula,data=d,family=binomial)
return(coef(fit))
}
library(boot)
results=boot(data=newdata, statistic=boot.GLMrob, R=1000, formula=answered ~ QUALITESANSREDONDANCE + competitivite + innovation + satisfait)
boot.ci(results, type= "bca",index=2)




More information about the R-SIG-Robust mailing list