Dear R-experts, I am trying to bootstrap (and average) the median squared error evaluation metric for a robust regression. I can't get it. What is going wrong ?
Here is the reproducible example. ############################# install.packages( "quantreg" ) library(quantreg) crp <-c(12,14,13,24,25,34,45,56,25,34,47,44,35,24,53,44,55,46,36,67) bmi <-c(34,32,12,76,54,34,21,18,92,32,11,13,45,46,56,57,67,87,12,13) glucose <-c(23,54,11,12,13,21,32,12,45,54,65,87,21,23,12,12,23,23,43,54) # Create a list to store the results lst<-list() # Numbers of bootstrap samples nboot=100 bootstrap.MedAESQ =rep(NA,nboot) for(i in 1 :nboot) { fit <- rq( crp ~ bmi+glucose, tau = 0.5) ypred=predict(fit) y=new$crp bootstrap.MedAESQ [i]=median(y-ypred)^2 lst[i]<-bootstrap.MedAESQ } mean(unlist(lst)) ################################### ______________________________________________ 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.