# We demonstrated the standard error for individual prediction: > se <- sqrt( 50.290426 * ( + 1 + 1^2 * .54593567 + 13^2 * .0029356502 + 2^2 * .0025897097 + + 2 * (1 * 13 * -.037302111 + 1*2 * -.002472899 + 2*13 * -.000763273))) > se [1] 7.207575 # Here's a 95% confidence interval using that se: > yhat <- 63.22702455 + 13*.87062304 + 2* 0.98784561 > tcrit <- qt(.975, 97) > yhat - tcrit*se [1] 62.21577 > yhat + tcrit * se [1] 90.82586 # We saw that the base of a logarithmic transformation does not matter. Here, # we calculate log base e and log base 10 of the same variable, and note that # the two are perfectly linearly related. > Peabody [1] 69 72 94 64 80 77 96 86 89 69 92 71 81 90 84 76 100 57 61 [20] 84 81 65 87 92 89 79 91 65 91 81 86 85 95 93 83 76 84 90 [39] 95 67 > log(Peabody) [1] 4.234107 4.276666 4.543295 4.158883 4.382027 4.343805 4.564348 4.454347 [9] 4.488636 4.234107 4.521789 4.262680 4.394449 4.499810 4.430817 4.330733 [17] 4.605170 4.043051 4.110874 4.430817 4.394449 4.174387 4.465908 4.521789 [25] 4.488636 4.369448 4.510860 4.174387 4.510860 4.394449 4.454347 4.442651 [33] 4.553877 4.532599 4.418841 4.330733 4.430817 4.499810 4.553877 4.204693 > log10(Peabody) [1] 1.838849 1.857332 1.973128 1.806180 1.903090 1.886491 1.982271 1.934498 [9] 1.949390 1.838849 1.963788 1.851258 1.908485 1.954243 1.924279 1.880814 [17] 2.000000 1.755875 1.785330 1.924279 1.908485 1.812913 1.939519 1.963788 [25] 1.949390 1.897627 1.959041 1.812913 1.959041 1.908485 1.934498 1.929419 [33] 1.977724 1.968483 1.919078 1.880814 1.924279 1.954243 1.977724 1.826075 > plot(log(Peabody),log10(Peabody)) # Here, we compare the regression of polishing time on object size using the # raw metric and using a log transformation for time. > Diameter <- c(10.7, 14.0, 9.0, 8.0, 10.0, 10.5, 16.0, 15.0, 6.5, 5.0, + 25.0, 10.4, 7.4, 5.4, 15.4, 12.4, 6.0, 9.0, 9.0, 12.4, + 7.5, 14.0, 7.0, 9.0, 12.0, 5.5, 6.0, 12.0, 5.5, 14.2, + 11.0, 16.0, 13.5, 11.1, 9.8, 10.0, 13.0, 13.0, 11.7, 12.3, + 19.5, 15.2, 10.0, 11.0, 17.8, 11.5, 12.7, 8.0, 7.5, 9.0, + 14.0, 12.4, 8.8, 8.5, 6.0, 11.0, 11.1, 14.5, 5.0) > > Time <- c(47.65, 63.13, 58.76, 34.88, 55.53, 43.14, 54.86, 44.14, 17.46, 21.04, + 109.38, 17.67, 16.41, 12.02, 49.48, 48.74, 23.21, 28.64, 44.95, 23.77, + 20.21, 32.62, 17.84, 22.82, 29.48, 15.61, 13.25, 45.78, 26.53, 37.11, + 45.12, 26.09, 68.63, 33.71, 44.45, 23.74, 86.42, 39.71, 26.52, 33.89, + 64.30, 22.55, 31.86, 53.18, 74.48, 34.16, 31.46, 21.34, 20.83, 20.59, + 33.70, 32.90, 27.76, 30.20, 20.85, 26.25, 21.87, 23.88, 16.66) > plot(Diameter, Time) > abline(lm(Time~Diameter)$coef) > plot(lm(Time~Diameter)$fit,lm(Time~Diameter)$res) > LogTime <- log(Time) > plot(Diameter,LogTime) > plot(lm(LogTime~Diameter)$fit,lm(LogTime~Diameter)$res) > summary(lm(Time~Diameter)) Call: lm(formula = Time ~ Diameter) Residuals: Min 1Q Median 3Q Max -28.037 -8.287 -2.705 8.315 43.438 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.9547 5.4020 -0.362 0.719 Diameter 3.4567 0.4667 7.407 6.67e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.69 on 57 degrees of freedom Multiple R-squared: 0.4905, Adjusted R-squared: 0.4815 F-statistic: 54.86 on 1 and 57 DF, p-value: 6.67e-10 > summary(lm(LogTime~Diameter)) Call: lm(formula = LogTime ~ Diameter) Residuals: Min 1Q Median 3Q Max -0.71657 -0.21277 -0.02750 0.26104 0.81874 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.50695 0.13760 18.219 < 2e-16 *** Diameter 0.08719 0.01189 7.335 8.8e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.3488 on 57 degrees of freedom Multiple R-squared: 0.4856, Adjusted R-squared: 0.4765 F-statistic: 53.8 on 1 and 57 DF, p-value: 8.795e-10