elastic2                package:DAAG                R Documentation

_E_l_a_s_t_i_c _B_a_n_d _D_a_t_a _R_e_p_l_i_c_a_t_e_d _A_g_a_i_n

_D_e_s_c_r_i_p_t_i_o_n:

     The 'elastic2' data frame has 9 rows and 2 columns giving, for
     each amount by which an elastic band is stretched over the end of
     a ruler, the distance that the band traveled when released.

_U_s_a_g_e:

     elastic2

_F_o_r_m_a_t:

     This data frame contains the following columns:

     _s_t_r_e_t_c_h the amount by which the elastic band was stretched

     _d_i_s_t_a_n_c_e the distance traveled

_S_o_u_r_c_e:

     J. H. Maindonald

_E_x_a_m_p_l_e_s:

     plot(elastic2)
     pause()

     print("Chapter 5 Exercise")

     yrange <- range(c(elastic1$distance, elastic2$distance))
     xrange <- range(c(elastic1$stretch, elastic2$stretch))
     plot(distance ~ stretch, data = elastic1, pch = 16, ylim = yrange, xlim = 
     xrange)
     points(distance ~ stretch, data = elastic2, pch = 15, col = 2)
     legend(xrange[1], yrange[2], legend = c("Data set 1", "Data set 2"), pch = 
     c(16, 15), col = c(1, 2))

     elastic1.lm <- lm(distance ~ stretch, data = elastic1)
     elastic2.lm <- lm(distance ~ stretch, data = elastic2)
     abline(elastic1.lm)
     abline(elastic2.lm, col = 2)
     summary(elastic1.lm)
     summary(elastic2.lm)
     pause()

     predict(elastic1.lm, se.fit=TRUE)
     predict(elastic2.lm, se.fit=TRUE)

