# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- library(alr3) data(wm1) attach(wm1) # get an initial linear model using all data: # m = lm( CSpd ~ RSpd ) # perform a single prediction: # predict( m, newdata=data.frame(RSpd=7.4285), interval="prediction", level=0.95 ) # to get bootstrap predictions we need to create a function: # wwx_prediction_function <- function(m) { predict( m, newdata=data.frame(RSpd=7.4285), interval="prediction", level=0.95 )[1] } pred.boot <- boot.case( m, B=999, f=wwx_prediction_function ) mean( pred.boot ) quantile( pred.boot, c(0.025,0.975) )