Good afternoon, Here below my reproducible R code. I don't get any results. I am looking for MSE_fastMM value and the bootstrap CIs around MSE_fastMM value. How can I finish/correct my R code to get the results ? Many thanks for your help.
#################### install.packages( "robustbase",dependencies=TRUE ) install.packages( "boot",dependencies=TRUE ) library(boot) library(robustbase) my.experiment <- function() {{ n<-2000 b<-runif(n, 0, 5) z <- rnorm(n, 2, 3) a <- runif(n, 0, 5) y_model<- 0.1*b - 0.5 * z - a + 10 y_obs <- y_model +c( rnorm(n*0.9, 0, 0.1), rnorm(n*0.1, 0, 0.5) ) fastMM <- lmrob( y_obs ~ b+z+a) MSE_fastMM<-mean((fastMM$fitted.values - y_model)^2) return( c(MSE_fastMM) ) } my.data = t(replicate( 50, my.experiment() )) colnames(my.data) <- c("MSE_fastMM") summary(my.data) data <- data.frame(a, z, b, y_obs) boot.ci.type <- c("norm","basic", "perc") MSE_fastMM <- function(data,i) { boot.MM <- lmrob(y_obs~b+z+a,data=data[i,]) mean(boot.MM$residuals^2) } bootResults_MM <-boot(data=data, statistic=MSE_fastMM, R=100) boot.ci(bootResults_MM, type = boot.ci.type) } ############################### ______________________________________________ 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.