# # 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(oldfaith) attach(oldfaith) # 2.12.1: # m = lm( Interval ~ Duration ) # plot this data: # postscript("../../WriteUp/Graphics/Chapter2/prob_12.eps", onefile=FALSE, horizontal=FALSE) plot(Duration,Interval,bty="l") abline( m ) dev.off() # 2.12.2: # predict( m, newdata=data.frame(Duration=250), interval="confidence", level=0.95 ) # 2.12.3: # predict( m, newdata=data.frame(Duration=250), interval="prediction", level=0.95 ) # 2.12.4: # SXX = sum( ( Duration - mean(Duration) )^2 ) bar_x = mean(Duration) n = length( Duration ) sigma = summary(m)$sigma alpha=0.1 F = qf(1-alpha,2,n-2) sqrt( 2 * F )