#1. data x <- c(0.7, 1.7, 2.7, 3.6, 4.6, 5.6, 6.7, 7.7, 8.7, 9.7, 10.7, 11.7, 12.7, 40.0, 42.0, 44.0, 46.0, 48.1, 50.1, 52.0, 58.0, 60.5, 64.2, 65.0, 66.6, 68.2); y1 <- c(37.35919, 37.76691, 38.18161, 38.56008, 38.98462, 39.37577, 39.85856, 40.25928, 40.66312, 41.07523, 41.48165, 41.91396, 42.29605, 52.50859, 53.52060, 54.53649, 55.60367, 56.65532, 57.70697, 58.67772, 61.75177, 65.10610, 67.04761, 67.45209, 68.26105, 69.07001) plot(x, y1); #2. linear model fmY1 = lm(y1 ~ x); fmY1 max(abs(residuals(fmY1))) #3. quadratic model x2 = x*x; fmY1qu = lm(y1 ~ x + x2); fmY1qu max(abs(residuals(fmY1qu))) #4. plot everything plot(x, y1) abline(fmY1, col="red") lines(x, fitted(fmY1qu), col='blue')