On 3/30/20 2:45 AM, varin sacha wrote:
Many thanks David,

But I am not sure the Dataset and newdata are the real problem. I have solved, at least I 
think so, what you were asking. Here below my new R code but still the same error 
message. IMHO the problem is with "boot.ci" function...

# # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # #
bmi=c(23,43,21,23,45,65,45,11,12,13,23,34,NA,NA,34,35,45,65,43,23,12,11,15,43,23,88,78,79,89,89,99,43,21,34,32,45,65,76,56,45,34,23,12,32)
glucose=c(NA,12,23,11,12,21,23,21,23,43,23,12,NA,23,11,12,32,12,14,12,11,10,9,8,9,8,7,90,76,32,12,11,12,23,11,123,32,12,14,34,54,65,76,87)
crp=c(123,212,154,342,123,111,121,765,453,123,213,211,NA,NA,32,123,213,145,143,123,132,143,165,176,181,123,87,567,342,123,143,132,143,234,345,32,123,132,143,345,321,543,231,123)
age=c(67,45,34,56,87,NA,NA,23,18,65,45,87,65,33,23,65,43,23,43,12,132,56,76,87,98,78,76,56,78,54,34,56,76,99,12,45,34,65,76,87,98,97,64,53)
sex=c(0,1,1,0,1,0,1,0,0,1,1,1,NA,NA,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0)

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) {
     d <- data[indices, ] # allows boot to select sample
     fastMM <- lmrob( crp ~ bmi+glucose+age+sex,data=newdata)
     fit <- lmrob(formula, data = d, method="MM")
     ypred <- predict(fit)
    mean((d[["fastMM"]]-ypred)^2)

At this point I do not see any reason for assuming there is a column in the d-object with the name "fastMM".


--

David


  }

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

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

str(Dataset)
str(newdata)
summary(results$t)
# # # # # # # # # # # # # # # # # # # # # # # # #







Le lundi 30 mars 2020 à 00:40:33 UTC+2, David Winsemius 
<dwinsem...@comcast.net> a écrit :






On 3/28/20 12:25 PM, varin sacha via R-help wrote:
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.

I do suggest you look at:


str(Dataset)

str(newdata)


The problem is actually in your construction of Dataset. Do not quote
object names next time.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to