> anova(lm(SUGARS ~ factor(SHELF) + (FAT>0))) Analysis of Variance Table Response: SUGARS Df Sum Sq Mean Sq F value Pr(>F) factor(SHELF) 2 248.41 124.204 8.0540 0.0006908 *** FAT > 0 1 127.36 127.364 8.2589 0.0053083 ** Residuals 73 1125.76 15.421 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > interaction.plot(factor(SHELF), FAT>0, SUGARS) > anova(lm(SUGARS ~ factor(SHELF) + (FAT>0) + factor(SHELF)*(FAT>0))) Analysis of Variance Table Response: SUGARS Df Sum Sq Mean Sq F value Pr(>F) factor(SHELF) 2 248.41 124.204 8.1359 0.0006587 *** FAT > 0 1 127.36 127.364 8.3428 0.0051297 ** factor(SHELF):FAT > 0 2 41.86 20.929 1.3709 0.2605117 Residuals 71 1083.90 15.266 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > lm(CALORIES ~ SUGARS) Call: lm(formula = CALORIES ~ SUGARS) Coefficients: (Intercept) SUGARS 89.820 2.465 > plot(CALORIES ~ SUGAR) Error in eval(expr, envir, enclos) : object 'SUGAR' not found > plot(CALORIES ~ SUGARS) > plot(lm(CALORIES ~ SUGAR)) Error in eval(expr, envir, enclos) : object 'SUGAR' not found > plot(lm(CALORIES ~ SUGARS)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: > cereal[c(55,56),] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 55 Puffed_Rice 50 1 0 0 0 13 0 3 56 Puffed_Wheat 50 2 0 0 1 10 0 3 > summary(lm(CALORIES ~ SUGARS)) Call: lm(formula = CALORIES ~ SUGARS) Residuals: Min 1Q Median 3Q Max -39.8201 -9.4003 0.4598 12.6449 38.1347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 89.8201 3.4366 26.137 < 2e-16 *** SUGARS 2.4650 0.4185 5.889 1.02e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.22 on 75 degrees of freedom Multiple R-squared: 0.3162, Adjusted R-squared: 0.3071 F-statistic: 34.69 on 1 and 75 DF, p-value: 1.025e-07 > plot(lm(CALORIES ~ SUGARS + FAT)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: > cereal[2,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 2 100%_Natural_Bran 120 3 5 15 2 8 8 3 > summary(lm(CALORIES ~ SUGARS + FAT)) Call: lm(formula = CALORIES ~ SUGARS + FAT) Residuals: Min 1Q Median 3Q Max -35.5623 -7.0534 0.2883 9.7544 33.6903 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 85.5623 3.2792 26.092 < 2e-16 *** SUGARS 2.0213 0.3941 5.129 2.26e-06 *** FAT 7.2349 1.7406 4.157 8.58e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 14.7 on 74 degrees of freedom Multiple R-squared: 0.4457, Adjusted R-squared: 0.4307 F-statistic: 29.75 on 2 and 74 DF, p-value: 3.31e-10 > summary(lm(CALORIES ~ SUGARS)) Call: lm(formula = CALORIES ~ SUGARS) Residuals: Min 1Q Median 3Q Max -39.8201 -9.4003 0.4598 12.6449 38.1347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 89.8201 3.4366 26.137 < 2e-16 *** SUGARS 2.4650 0.4185 5.889 1.02e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.22 on 75 degrees of freedom Multiple R-squared: 0.3162, Adjusted R-squared: 0.3071 F-statistic: 34.69 on 1 and 75 DF, p-value: 1.025e-07 > summary(lm(CALORIES ~ SUGARS + FAT)) Call: lm(formula = CALORIES ~ SUGARS + FAT) Residuals: Min 1Q Median 3Q Max -35.5623 -7.0534 0.2883 9.7544 33.6903 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 85.5623 3.2792 26.092 < 2e-16 *** SUGARS 2.0213 0.3941 5.129 2.26e-06 *** FAT 7.2349 1.7406 4.157 8.58e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 14.7 on 74 degrees of freedom Multiple R-squared: 0.4457, Adjusted R-squared: 0.4307 F-statistic: 29.75 on 2 and 74 DF, p-value: 3.31e-10 > summary(lm(CALORIES ~ SUGARS)) Call: lm(formula = CALORIES ~ SUGARS) Residuals: Min 1Q Median 3Q Max -39.8201 -9.4003 0.4598 12.6449 38.1347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 89.8201 3.4366 26.137 < 2e-16 *** SUGARS 2.4650 0.4185 5.889 1.02e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.22 on 75 degrees of freedom Multiple R-squared: 0.3162, Adjusted R-squared: 0.3071 F-statistic: 34.69 on 1 and 75 DF, p-value: 1.025e-07 > summary(lm(CALORIES ~ SUGARS + FAT)) Call: lm(formula = CALORIES ~ SUGARS + FAT) Residuals: Min 1Q Median 3Q Max -35.5623 -7.0534 0.2883 9.7544 33.6903 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 85.5623 3.2792 26.092 < 2e-16 *** SUGARS 2.0213 0.3941 5.129 2.26e-06 *** FAT 7.2349 1.7406 4.157 8.58e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 14.7 on 74 degrees of freedom Multiple R-squared: 0.4457, Adjusted R-squared: 0.4307 F-statistic: 29.75 on 2 and 74 DF, p-value: 3.31e-10 > confint(lm(CALORIES ~ SUGARS + FAT)) 2.5 % 97.5 % (Intercept) 79.028318 92.096269 SUGARS 1.236037 2.806662 FAT 3.766746 10.703102 > cereal[1,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 1 100%_Bran 70 4 1 130 10 5 6 3 > plot(lm(CALORIES ~ SUGARS + FAT + PROTEIN)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN)) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN) Residuals: Min 1Q Median 3Q Max -37.8457 -7.0108 -0.2365 8.8708 32.1679 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 79.5344 5.9680 13.327 < 2e-16 *** SUGARS 2.2343 0.4307 5.188 1.84e-06 *** FAT 6.5091 1.8364 3.544 0.00069 *** PROTEIN 2.0778 1.7211 1.207 0.23122 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 14.66 on 73 degrees of freedom Multiple R-squared: 0.4565, Adjusted R-squared: 0.4342 F-statistic: 20.44 on 3 and 73 DF, p-value: 1.021e-09 > plot(lm(CALORIES ~ SUGARS + FAT + FIBER)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: > cereal[1:4,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 1 100%_Bran 70 4 1 130 10 5 6 3 2 100%_Natural_Bran 120 3 5 15 2 8 8 3 3 All-Bran 70 4 1 260 9 7 5 3 4 All-Bran_with_Extra_Fiber 50 4 0 140 14 8 0 3 > summary(lm(CALORIES ~ SUGARS + FAT + FIBER)) Call: lm(formula = CALORIES ~ SUGARS + FAT + FIBER) Residuals: Min 1Q Median 3Q Max -40.6531 -9.8873 -0.1173 7.1988 36.0890 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 90.6531 3.5962 25.208 < 2e-16 *** SUGARS 1.8558 0.3805 4.877 6.11e-06 *** FAT 7.5106 1.6638 4.514 2.39e-05 *** FIBER -1.9630 0.6832 -2.873 0.00532 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 14.03 on 73 degrees of freedom Multiple R-squared: 0.502, Adjusted R-squared: 0.4815 F-statistic: 24.53 on 3 and 73 DF, p-value: 4.403e-11 > cereal[1:4,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 1 100%_Bran 70 4 1 130 10 5 6 3 2 100%_Natural_Bran 120 3 5 15 2 8 8 3 3 All-Bran 70 4 1 260 9 7 5 3 4 All-Bran_with_Extra_Fiber 50 4 0 140 14 8 0 3 > plot(lm(CALORIES ~ SUGARS + FAT + FIBER + PROTEIN)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: > summary(lm(CALORIES ~ SUGARS + FAT + FIBER + PROTEIN)) Call: lm(formula = CALORIES ~ SUGARS + FAT + FIBER + PROTEIN) Residuals: Min 1Q Median 3Q Max -35.3305 -8.2901 0.4364 8.3081 33.2686 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 76.7918 5.4020 14.215 < 2e-16 *** SUGARS 2.3543 0.3881 6.066 5.52e-08 *** FAT 5.6355 1.6631 3.389 0.00114 ** FIBER -3.1632 0.7381 -4.286 5.56e-05 *** PROTEIN 5.8509 1.7799 3.287 0.00157 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.17 on 72 degrees of freedom Multiple R-squared: 0.567, Adjusted R-squared: 0.5429 F-statistic: 23.57 on 4 and 72 DF, p-value: 1.76e-12 > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN+ FIBER )) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN + FIBER) Residuals: Min 1Q Median 3Q Max -35.3305 -8.2901 0.4364 8.3081 33.2686 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 76.7918 5.4020 14.215 < 2e-16 *** SUGARS 2.3543 0.3881 6.066 5.52e-08 *** FAT 5.6355 1.6631 3.389 0.00114 ** PROTEIN 5.8509 1.7799 3.287 0.00157 ** FIBER -3.1632 0.7381 -4.286 5.56e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.17 on 72 degrees of freedom Multiple R-squared: 0.567, Adjusted R-squared: 0.5429 F-statistic: 23.57 on 4 and 72 DF, p-value: 1.76e-12 > plot(CALORIES ~ PROTEIN) > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN+ FIBER )) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN + FIBER) Residuals: Min 1Q Median 3Q Max -35.3305 -8.2901 0.4364 8.3081 33.2686 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 76.7918 5.4020 14.215 < 2e-16 *** SUGARS 2.3543 0.3881 6.066 5.52e-08 *** FAT 5.6355 1.6631 3.389 0.00114 ** PROTEIN 5.8509 1.7799 3.287 0.00157 ** FIBER -3.1632 0.7381 -4.286 5.56e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.17 on 72 degrees of freedom Multiple R-squared: 0.567, Adjusted R-squared: 0.5429 F-statistic: 23.57 on 4 and 72 DF, p-value: 1.76e-12 > cereal[1:4,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 1 100%_Bran 70 4 1 130 10 5 6 3 2 100%_Natural_Bran 120 3 5 15 2 8 8 3 3 All-Bran 70 4 1 260 9 7 5 3 4 All-Bran_with_Extra_Fiber 50 4 0 140 14 8 0 3 > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN+ FIBER + SODIUM )) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN + FIBER + SODIUM) Residuals: Min 1Q Median 3Q Max -26.8788 -7.6598 -0.3427 7.0683 34.2768 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 68.40442 5.66573 12.073 < 2e-16 *** SUGARS 2.23748 0.36559 6.120 4.60e-08 *** FAT 5.81734 1.56023 3.729 0.000384 *** PROTEIN 5.75375 1.66903 3.447 0.000955 *** FIBER -3.03308 0.69314 -4.376 4.07e-05 *** SODIUM 0.05623 0.01703 3.303 0.001501 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 12.35 on 71 degrees of freedom Multiple R-squared: 0.6246, Adjusted R-squared: 0.5982 F-statistic: 23.63 on 5 and 71 DF, p-value: 6.629e-14 > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN+ FIBER + SHELF )) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN + FIBER + SHELF) Residuals: Min 1Q Median 3Q Max -36.5804 -7.3538 0.4826 7.6918 32.8009 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 74.8914 6.5128 11.499 < 2e-16 *** SUGARS 2.3434 0.3906 5.999 7.55e-08 *** FAT 5.4108 1.7247 3.137 0.00248 ** PROTEIN 5.9068 1.7920 3.296 0.00153 ** FIBER -3.2868 0.7779 -4.225 6.98e-05 *** SHELF 1.0540 1.9952 0.528 0.59894 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.24 on 71 degrees of freedom Multiple R-squared: 0.5687, Adjusted R-squared: 0.5383 F-statistic: 18.72 on 5 and 71 DF, p-value: 8.055e-12 >