# # EPage 240 # # 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(DAAG) # Plot the two sets of elastic bands (from EPage 167): # source('../Chapter5/chap_5_prob_1.R') elastic1$type = 1 elastic2$type = 2 elastic = rbind( elastic1, elastic2 ) elastic$type = as.factor(elastic$type) # We will comare the regression lines following the models built in 7.3: fitting multiple lines: # elastic.lm1 = lm( distance ~ 1, data=elastic ) elastic.lm2 = lm( distance ~ stretch, data=elastic ) elastic.lm3 = lm( distance ~ stretch + type, data=elastic ) # a different intercept for each set of data (common slope) elastic.lm4 = lm( distance ~ stretch + type + stretch:type, data=elastic ) # a different slope and intercept for each set of data # Compare all of the models: # anova( elastic.lm1, elastic.lm2, elastic.lm3, elastic.lm4 ) # Lets look for outliers (7 is an outlier): plot( elastic.lm2, which=1 )