[R] Error message using boot.ci function

varin sacha v@r|n@@ch@ @end|ng |rom y@hoo@|r
Sat Mar 28 20:25:35 CET 2020


Dear R-experts,

Here below my "toy" reproducible example showing many warnings and an error message. What I am interested in is the error message.
Of course I can access and view the results doing : summary(results$t) to give me an idea of what is going on. But I don't know how to correct/solve my problem. Any help to solve my problem would be highly appreciated.

# # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # 
bmi=c(23,43,21,23,45,65,45,11,12,13,23,34,NA,NA)
glucose=c(NA,12,23,11,12,21,23,21,23,43,23,12,NA,23)
crp=c(123,212,154,342,123,111,121,765,453,123,213,211,NA,NA)
age=c(67,45,34,56,87,NA,NA,23,18,65,45,87,65,33)
sex=c(0,1,1,0,1,0,1,0,0,1,1,1,NA,NA)

Dataset=data.frame("bmi","glucose","crp","age","sex")
newdata=na.omit(Dataset) 

#install.packages( "robustbase",dependencies=TRUE )
#install.packages( "boot",dependencies=TRUE )
library(boot)
library(robustbase)

 # function to obtain MSE
 MSE <- function(data, indices, formula,method) {
fastMM <- lmrob( crp ~ bmi+glucose+age+sex, data=newdata)
    d <- data[indices, ] # allows boot to select sample
    fit <- lmrob(formula, data = d, method="MM")
    ypred <- predict(fit)
   mean((d[["fastMM"]]-ypred)^2)
 }

 # bootstrapping with 1000 replications
 results <- boot(data = newdata, statistic = MSE,
                  R = 1000, formula = crp ~ bmi+glucose+age+sex,method="MM")

str(results)
boot.ci(results, type="norm" )

summary(results$t)
# # # # # # # # # # # # # # # # # # # # # # # # #



More information about the R-help mailing list