# Bootstrap distribution of median for Mouse observed control group # Illustration of effect of B on the variability of # the bootstrap estimate of standard error. origsample<-c(52,104,146,10,50,31,40,27,46) # Initialise vectors Bvalues<- sdvalues<-c() cvvalues<-c() # Conduct experiment for (B in c(25,100,250,1000)) { for (i in 1:100) { brep<-rep(0,B) for(j in 1:B){ bsample<-sample(origsample,length(origsample),replace=T) brep[j]<-median(bsample) } Bvalues<-c(Bvalues,B) sdvalues<-c(sdvalues,sd(brep)) cvvalues<-c(cvvalues,sd(brep)/mean(brep)) } } # Plot results par(mfrow=c(1,2)) # Sets up multiple plots 1x2 plot(Bvalues,sdvalues) plot(Bvalues,cvvalues)