> > O58; [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [17] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [33] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [49] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE [65] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + O58)) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + O58) Residuals: Min 1Q Median 3Q Max -12.2166 -3.0019 -0.1584 2.5043 16.5380 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.04175 3.92730 0.011 0.992 SUGARS 3.94232 0.16534 23.844 < 2e-16 *** FAT 8.59671 0.63562 13.525 < 2e-16 *** PROTEIN 4.15389 0.59962 6.928 1.59e-09 *** CARBO 4.06656 0.17194 23.651 < 2e-16 *** O58TRUE 70.00425 6.07124 11.530 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 4.987 on 71 degrees of freedom Multiple R-squared: 0.9388, Adjusted R-squared: 0.9345 F-statistic: 217.8 on 5 and 71 DF, p-value: < 2.2e-16 > plot(lm(CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > cereal[30:40,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 30 Fruity_Pebbles 110 1 1 135 0.0 13.0 12 2 31 Golden_Crisp 100 2 0 45 0.0 11.0 15 1 32 Golden_Grahams 110 1 1 280 0.0 15.0 9 2 33 Grape_Nuts_Flakes 100 3 1 140 3.0 15.0 5 3 34 Grape-Nuts 110 3 0 170 3.0 17.0 3 3 35 Great_Grains_Pecan 120 3 3 75 3.0 13.0 4 3 36 Honey_Graham_Ohs 120 1 2 220 1.0 12.0 11 2 37 Honey_Nut_Cheerios 110 3 1 250 1.5 11.5 10 1 38 Honey-comb 110 1 0 180 0.0 14.0 11 1 39 Just_Right_Crunchy__Nuggets 110 2 1 170 1.0 17.0 6 3 40 Just_Right_Fruit_&_Nut 140 3 1 170 2.0 20.0 9 3 > cereal[68,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 68 Special_K 110 6 0 230 1 16 3 1 > plot(lm(CALORIES ~ SUGARS + factor(SHELF))) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: > lm(CALORIES ~ SUGARS + factor(SHELF)) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF)) Coefficients: (Intercept) SUGARS factor(SHELF)2 factor(SHELF)3 89.5592 2.6960 -5.9683 0.6197 > summary(lm(CALORIES ~ SUGARS + factor(SHELF))) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF)) Residuals: Min 1Q Median 3Q Max -40.1789 -7.9228 0.4408 11.7331 34.7732 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 89.5592 4.2393 21.126 < 2e-16 *** SUGARS 2.6960 0.4579 5.887 1.11e-07 *** factor(SHELF)2 -5.9683 5.5249 -1.080 0.284 factor(SHELF)3 0.6197 4.5898 0.135 0.893 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.21 on 73 degrees of freedom Multiple R-squared: 0.3351, Adjusted R-squared: 0.3078 F-statistic: 12.26 on 3 and 73 DF, p-value: 1.389e-06 > summary(lm(CALORIES ~ SUGARS + factor(SHELF) + O58)) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF) + O58) Residuals: Min 1Q Median 3Q Max -39.749 -8.415 0.918 11.965 34.347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 88.5316 4.4198 20.031 < 2e-16 *** SUGARS 2.7619 0.4655 5.933 9.52e-08 *** factor(SHELF)2 -5.5742 5.5557 -1.003 0.319 factor(SHELF)3 1.2174 4.6535 0.262 0.794 O58TRUE 14.2303 16.9061 0.842 0.403 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.24 on 72 degrees of freedom Multiple R-squared: 0.3416, Adjusted R-squared: 0.305 F-statistic: 9.337 on 4 and 72 DF, p-value: 3.894e-06 > summary(lm(CALORIES ~ SUGARS + factor(SHELF) + O58)) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF) + O58) Residuals: Min 1Q Median 3Q Max -39.749 -8.415 0.918 11.965 34.347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 88.5316 4.4198 20.031 < 2e-16 *** SUGARS 2.7619 0.4655 5.933 9.52e-08 *** factor(SHELF)2 -5.5742 5.5557 -1.003 0.319 factor(SHELF)3 1.2174 4.6535 0.262 0.794 O58TRUE 14.2303 16.9061 0.842 0.403 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.24 on 72 degrees of freedom Multiple R-squared: 0.3416, Adjusted R-squared: 0.305 F-statistic: 9.337 on 4 and 72 DF, p-value: 3.894e-06 > summary(lm(CALORIES ~ SUGARS + factor(SHELF)*SUGARS + O58)) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -35.01861 -5.93020 -0.01600 9.14169 29.75349 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 98.3314 4.9146 20.008 < 2e-16 *** SUGARS 0.8423 0.7318 1.151 0.253626 factor(SHELF)2 0.8613 9.2711 0.093 0.926243 factor(SHELF)3 -24.6802 6.7502 -3.656 0.000491 *** O58TRUE 2.5109 14.9629 0.168 0.867217 SUGARS:factor(SHELF)2 0.2317 1.0506 0.221 0.826073 SUGARS:factor(SHELF)3 4.3856 0.9548 4.593 1.88e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.92 on 70 degrees of freedom Multiple R-squared: 0.53, Adjusted R-squared: 0.4897 F-statistic: 13.15 on 6 and 70 DF, p-value: 6.572e-10 > summary(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58)) Call: lm(formula = CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -35.0186 -5.7355 -0.2465 8.8490 29.7535 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 98.1539 4.0495 24.238 < 2e-16 *** SUGARS 1.0831 0.4570 2.370 0.020466 * SHELF == 3TRUE -24.5027 6.1082 -4.011 0.000146 *** O58TRUE 2.9292 14.4543 0.203 0.839981 SUGARS:SHELF == 3TRUE 4.1448 0.7591 5.460 6.43e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.75 on 72 degrees of freedom Multiple R-squared: 0.5279, Adjusted R-squared: 0.5016 F-statistic: 20.12 on 4 and 72 DF, p-value: 3.696e-11 > plot(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > cereal[53,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 53 Post_Nat._Raisin_Bran 120 3 1 200 6 11 14 3 > plot(lm(CALORIES ~ SUGARS + FAT + (SHELF==3)*SUGARS + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > summary(lm(CALORIES ~ SUGARS + FAT + (SHELF==3)*SUGARS + O58)) Call: lm(formula = CALORIES ~ SUGARS + FAT + (SHELF == 3) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -34.07000 -5.64836 0.03962 8.64092 26.08366 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 95.6484 3.8885 24.598 < 2e-16 *** SUGARS 0.8626 0.4353 1.981 0.05143 . FAT 5.3600 1.6660 3.217 0.00195 ** SHELF == 3TRUE -23.8562 5.7499 -4.149 9.14e-05 *** O58TRUE -5.5059 13.8486 -0.398 0.69213 SUGARS:SHELF == 3TRUE 3.6237 0.7323 4.949 4.85e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 12.94 on 71 degrees of freedom Multiple R-squared: 0.5879, Adjusted R-squared: 0.5589 F-statistic: 20.26 on 5 and 71 DF, p-value: 1.667e-12 > summary(lm(CALORIES ~ SUGARS + CARBO + (SHELF==3)*SUGARS + O58)) Call: lm(formula = CALORIES ~ SUGARS + CARBO + (SHELF == 3) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -17.963 -4.297 -1.578 4.399 30.536 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 38.2898 7.4631 5.131 2.41e-06 *** SUGARS 3.0037 0.3897 7.709 5.80e-11 *** CARBO 3.0187 0.3480 8.675 9.39e-13 *** SHELF == 3TRUE -9.8832 4.6052 -2.146 0.0353 * O58TRUE 67.7327 12.5963 5.377 9.19e-07 *** SUGARS:SHELF == 3TRUE 2.4498 0.5673 4.318 5.01e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 9.651 on 71 degrees of freedom Multiple R-squared: 0.7708, Adjusted R-squared: 0.7546 F-statistic: 47.75 on 5 and 71 DF, p-value: < 2.2e-16 > plot(lm(CALORIES ~ SUGARS + CARBO + (SHELF==3)*SUGARS + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > cereal[35,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 35 Great_Grains_Pecan 120 3 3 75 3 13 4 3 > O35 Error: object 'O35' not found > O35=(NAME==NAME[35]) > plot(lm(CALORIES ~ SUGARS + CARBO + (SHELF==3)*SUGARS + O58 + O35)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 35, 58 2: Not plotting observations with leverage one: 35, 58 > summar(lm(CALORIES ~ SUGARS + CARBO + (SHELF==3)*SUGARS + O58 + O35)) Error: could not find function "summar" > summary(lm(CALORIES ~ SUGARS + CARBO + (SHELF==3)*SUGARS + O58 + O35)) Call: lm(formula = CALORIES ~ SUGARS + CARBO + (SHELF == 3) * SUGARS + O58 + O35) Residuals: Min 1Q Median 3Q Max -18.041 -3.999 -0.910 4.534 24.920 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 36.8990 6.9515 5.308 1.24e-06 *** SUGARS 3.0484 0.3626 8.408 3.24e-12 *** CARBO 3.0889 0.3242 9.527 2.88e-14 *** SHELF == 3TRUE -11.4541 4.3061 -2.660 0.009682 ** O58TRUE 69.2383 11.7213 5.907 1.14e-07 *** O35TRUE 31.9376 9.1783 3.480 0.000868 *** SUGARS:SHELF == 3TRUE 2.5672 0.5286 4.856 7.03e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 8.975 on 70 degrees of freedom Multiple R-squared: 0.8046, Adjusted R-squared: 0.7878 F-statistic: 48.04 on 6 and 70 DF, p-value: < 2.2e-16 > cereal[35,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 35 Great_Grains_Pecan 120 3 3 75 3 13 4 3 > plot(lm(CALORIES ~ SUGARS + CARBO + (SHELF==3)*SUGARS + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + O58)) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + O58) Residuals: Min 1Q Median 3Q Max -12.2166 -3.0019 -0.1584 2.5043 16.5380 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.04175 3.92730 0.011 0.992 SUGARS 3.94232 0.16534 23.844 < 2e-16 *** FAT 8.59671 0.63562 13.525 < 2e-16 *** PROTEIN 4.15389 0.59962 6.928 1.59e-09 *** CARBO 4.06656 0.17194 23.651 < 2e-16 *** O58TRUE 70.00425 6.07124 11.530 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 4.987 on 71 degrees of freedom Multiple R-squared: 0.9388, Adjusted R-squared: 0.9345 F-statistic: 217.8 on 5 and 71 DF, p-value: < 2.2e-16 > plot(lm(CALORIES ~ (SHELF==3) + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > summary(lm(CALORIES ~ (SHELF==3) + O58)) Call: lm(formula = CALORIES ~ (SHELF == 3) + O58) Residuals: Min 1Q Median 3Q Max -57.778 -7.778 3.750 3.750 52.222 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 106.250 3.117 34.087 <2e-16 *** SHELF == 3TRUE 1.528 4.529 0.337 0.737 O58TRUE -6.250 19.959 -0.313 0.755 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 19.71 on 74 degrees of freedom Multiple R-squared: 0.003197, Adjusted R-squared: -0.02374 F-statistic: 0.1187 on 2 and 74 DF, p-value: 0.8883 > cor(CALORIES, cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 1 0.01906607 0.4986098 0.3006492 -0.2934128 0.2506809 0.5623403 0.09723437 Warning message: In cor(CALORIES, cereal) : NAs introduced by coercion > cor(residuals(lm(CALORIES ~ (SHELF==3) + O58))), cereal) Error: unexpected ',' in "cor(residuals(lm(CALORIES ~ (SHELF==3) + O58)))," > cor(residuals(lm(CALORIES ~ (SHELF==3) + O58)))), cereal) Error: unexpected ')' in "cor(residuals(lm(CALORIES ~ (SHELF==3) + O58))))" > cor(residuals(lm(CALORIES ~ (SHELF==3) + O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.9984005 0.01784847 0.4947938 0.2935511 -0.3083158 0.2365196 0.5590068 0.05585689 Warning message: In cor(residuals(lm(CALORIES ~ (SHELF == 3) + O58)), cereal) : NAs introduced by coercion > cor(residuals(lm(CALORIES ~ SUGARS + (SHELF==3) + O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.8170976 0.1977709 0.3741946 0.3208757 -0.3091423 0.5960541 3.820425e-17 -0.04730387 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS + (SHELF == 3) + O58)), cereal) : NAs introduced by coercion > cor(residuals(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.6871275 0.01075755 0.3157862 0.3449438 -0.4405689 0.5332898 5.334131e-18 0.02359141 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + : NAs introduced by coercion > summary(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58)) Call: lm(formula = CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -35.0186 -5.7355 -0.2465 8.8490 29.7535 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 98.1539 4.0495 24.238 < 2e-16 *** SUGARS 1.0831 0.4570 2.370 0.020466 * SHELF == 3TRUE -24.5027 6.1082 -4.011 0.000146 *** O58TRUE 2.9292 14.4543 0.203 0.839981 SUGARS:SHELF == 3TRUE 4.1448 0.7591 5.460 6.43e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.75 on 72 degrees of freedom Multiple R-squared: 0.5279, Adjusted R-squared: 0.5016 F-statistic: 20.12 on 4 and 72 DF, p-value: 3.696e-11 > cor(residuals(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.6871275 0.01075755 0.3157862 0.3449438 -0.4405689 0.5332898 5.334131e-18 0.02359141 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + : NAs introduced by coercion > cor(residuals(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + CARBO+ O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.4787633 0.3012435 0.6828687 0.1225120 -0.09037323 4.41713e-17 5.945216e-17 0.04371924 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + : NAs introduced by coercion > summary(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + CARBO + O58)) Call: lm(formula = CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + CARBO + O58) Residuals: Min 1Q Median 3Q Max -17.963 -4.297 -1.578 4.399 30.536 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 38.2898 7.4631 5.131 2.41e-06 *** SUGARS 3.0037 0.3897 7.709 5.80e-11 *** SHELF == 3TRUE -9.8832 4.6052 -2.146 0.0353 * CARBO 3.0187 0.3480 8.675 9.39e-13 *** O58TRUE 67.7327 12.5963 5.377 9.19e-07 *** SUGARS:SHELF == 3TRUE 2.4498 0.5673 4.318 5.01e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 9.651 on 71 degrees of freedom Multiple R-squared: 0.7708, Adjusted R-squared: 0.7546 F-statistic: 47.75 on 5 and 71 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + CARBO + (SHELF==3)*CARBO + O58)) Call: lm(formula = CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + CARBO + (SHELF == 3) * CARBO + O58) Residuals: Min 1Q Median 3Q Max -16.9788 -4.1657 -0.2656 4.2266 31.1059 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 65.8016 15.5283 4.238 6.77e-05 *** SUGARS 2.1211 0.5821 3.644 0.000512 *** SHELF == 3TRUE -42.4545 16.8356 -2.522 0.013957 * CARBO 1.6314 0.7704 2.118 0.037752 * O58TRUE 37.9509 19.2907 1.967 0.053111 . SUGARS:SHELF == 3TRUE 3.3578 0.7163 4.688 1.32e-05 *** SHELF == 3TRUE:CARBO 1.7249 0.8590 2.008 0.048498 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 9.451 on 70 degrees of freedom Multiple R-squared: 0.7833, Adjusted R-squared: 0.7647 F-statistic: 42.16 on 6 and 70 DF, p-value: < 2.2e-16 > plot(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + CARBO + (SHELF==3)*CARBO + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > summary(lm(CALORIES ~ SUGARS + factor(SHELF) + O58)) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF) + O58) Residuals: Min 1Q Median 3Q Max -39.749 -8.415 0.918 11.965 34.347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 88.5316 4.4198 20.031 < 2e-16 *** SUGARS 2.7619 0.4655 5.933 9.52e-08 *** factor(SHELF)2 -5.5742 5.5557 -1.003 0.319 factor(SHELF)3 1.2174 4.6535 0.262 0.794 O58TRUE 14.2303 16.9061 0.842 0.403 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.24 on 72 degrees of freedom Multiple R-squared: 0.3416, Adjusted R-squared: 0.305 F-statistic: 9.337 on 4 and 72 DF, p-value: 3.894e-06 > summary(lm(CALORIES ~ SUGARS + factor(SHELF) + O58)) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF) + O58) Residuals: Min 1Q Median 3Q Max -39.749 -8.415 0.918 11.965 34.347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 88.5316 4.4198 20.031 < 2e-16 *** SUGARS 2.7619 0.4655 5.933 9.52e-08 *** factor(SHELF)2 -5.5742 5.5557 -1.003 0.319 factor(SHELF)3 1.2174 4.6535 0.262 0.794 O58TRUE 14.2303 16.9061 0.842 0.403 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.24 on 72 degrees of freedom Multiple R-squared: 0.3416, Adjusted R-squared: 0.305 F-statistic: 9.337 on 4 and 72 DF, p-value: 3.894e-06 > cor(CALORIES, ceral) Error in inherits(x, "data.frame") : object 'ceral' not found > cor(CALORIES, cereaal) Error in inherits(x, "data.frame") : object 'cereaal' not found > cor(CALORIES, cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 1 0.01906607 0.4986098 0.3006492 -0.2934128 0.2506809 0.5623403 0.09723437 Warning message: In cor(CALORIES, cereal) : NAs introduced by coercion > summary(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58)) Call: lm(formula = CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -35.0186 -5.7355 -0.2465 8.8490 29.7535 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 98.1539 4.0495 24.238 < 2e-16 *** SUGARS 1.0831 0.4570 2.370 0.020466 * SHELF == 3TRUE -24.5027 6.1082 -4.011 0.000146 *** O58TRUE 2.9292 14.4543 0.203 0.839981 SUGARS:SHELF == 3TRUE 4.1448 0.7591 5.460 6.43e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.75 on 72 degrees of freedom Multiple R-squared: 0.5279, Adjusted R-squared: 0.5016 F-statistic: 20.12 on 4 and 72 DF, p-value: 3.696e-11 > cereal[58,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 58 Quaker_Oatmeal 100 5 2 0 2.7 -1 -1 1 > summary(lm(CALORIES ~ CARBO + (SHELF==3)*SUGARS + O58)) Call: lm(formula = CALORIES ~ CARBO + (SHELF == 3) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -17.963 -4.297 -1.578 4.399 30.536 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 38.2898 7.4631 5.131 2.41e-06 *** CARBO 3.0187 0.3480 8.675 9.39e-13 *** SHELF == 3TRUE -9.8832 4.6052 -2.146 0.0353 * SUGARS 3.0037 0.3897 7.709 5.80e-11 *** O58TRUE 67.7327 12.5963 5.377 9.19e-07 *** SHELF == 3TRUE:SUGARS 2.4498 0.5673 4.318 5.01e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 9.651 on 71 degrees of freedom Multiple R-squared: 0.7708, Adjusted R-squared: 0.7546 F-statistic: 47.75 on 5 and 71 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ CARBO + (SHELF==3)*CARBO + O58)) Call: lm(formula = CALORIES ~ CARBO + (SHELF == 3) * CARBO + O58) Residuals: Min 1Q Median 3Q Max -53.252 -9.234 1.498 9.553 44.680 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 117.2880 12.1328 9.667 1.21e-14 *** CARBO -0.7322 0.7829 -0.935 0.35277 SHELF == 3TRUE -53.2551 16.2252 -3.282 0.00159 ** O58TRUE -18.0202 21.9845 -0.820 0.41511 CARBO:SHELF == 3TRUE 3.7491 1.0597 3.538 0.00071 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 17.81 on 72 degrees of freedom Multiple R-squared: 0.2089, Adjusted R-squared: 0.1649 F-statistic: 4.752 on 4 and 72 DF, p-value: 0.001851 > summary(lm(CALORIES ~ SUGAR + CARBO + (SHELF==3)*CARBO + O58)) Error in eval(expr, envir, enclos) : object 'SUGAR' not found > summary(lm(CALORIES ~ SUGARS + CARBO + (SHELF==3)*CARBO + O58)) Call: lm(formula = CALORIES ~ SUGARS + CARBO + (SHELF == 3) * CARBO + O58) Residuals: Min 1Q Median 3Q Max -24.529 -7.133 -2.558 5.372 28.117 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 11.9786 11.8983 1.007 0.3175 SUGARS 4.3384 0.3861 11.236 < 2e-16 *** CARBO 4.1023 0.6394 6.416 1.36e-08 *** SHELF == 3TRUE 19.8373 11.7647 1.686 0.0962 . O58TRUE 96.4621 16.7399 5.762 1.98e-07 *** CARBO:SHELF == 3TRUE -0.8166 0.7583 -1.077 0.2852 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 10.76 on 71 degrees of freedom Multiple R-squared: 0.7152, Adjusted R-squared: 0.6952 F-statistic: 35.67 on 5 and 71 DF, p-value: < 2.2e-16 > plot(CALORIES ~ SUGARS) > points(CALORIES[SHELF==1] ~ SUGARS[SHELF==1]) > points(CALORIES[SHELF==1] ~ SUGARS[SHELF==1], col='red') > plot(CALORIES ~ SUGARS) > points(CALORIES[SHELF==1] ~ SUGARS[SHELF==1], col='red') > points(CALORIES[SHELF==2] ~ SUGARS[SHELF==2], col='blue') > summary(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58)) Call: lm(formula = CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -35.0186 -5.7355 -0.2465 8.8490 29.7535 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 98.1539 4.0495 24.238 < 2e-16 *** SUGARS 1.0831 0.4570 2.370 0.020466 * SHELF == 3TRUE -24.5027 6.1082 -4.011 0.000146 *** O58TRUE 2.9292 14.4543 0.203 0.839981 SUGARS:SHELF == 3TRUE 4.1448 0.7591 5.460 6.43e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.75 on 72 degrees of freedom Multiple R-squared: 0.5279, Adjusted R-squared: 0.5016 F-statistic: 20.12 on 4 and 72 DF, p-value: 3.696e-11 > abline(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58)) Warning message: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58)) : only using the first two of 5regression coefficients > abline(lm(CALORIES[SHELF==3] ~ SUGARS[SHELF==3] + O58)) Error in model.frame.default(formula = CALORIES[SHELF == 3] ~ SUGARS[SHELF == : variable lengths differ (found for 'O58') > abline(lm(CALORIES[SHELF==3] ~ SUGARS[SHELF==3] + O58[SHELF==3])) Warning message: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > abline(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58), col='purple') Warning message: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients > plot(CALORIES ~ SUGARS) > points(CALORIES[58] ~ SUGARS[58]) > ?points > points(CALORIES[58] ~ SUGARS[58], pch=22, col='green') > points(CALORIES[58] ~ SUGARS[58], col='green', pch=22) > points(CALORIES[58] ~ SUGARS[58], col='green', pch=18) > points(CALORIES[58] ~ SUGARS[58], col='green', pch=25) > points(CALORIES[58] ~ SUGARS[58], col='black', pch=25) > points(CALORIES[58] ~ SUGARS[58], col='black', pch=25, bg='black') > draw_picture=edit() Error in edit(name, file, title, editor) : unable to open file to read > draw_picture=edit(draw_picture) Error in edit(draw_picture) : object 'draw_picture' not found > draw_picture=function + ; Error: unexpected ';' in: "draw_picture=function ;" > draw_picture=function() + {} > draw_picture=edit(draw_picture) > draw_picture function() { plot(CALORIES ~ SUGARS) points(CALORIES[58] ~ SUGARS[58], col='black', bg='black', pch=25) } > > draw_picture=edit(draw_picture) > > draw_picture=edit(draw_picture) > draw_picture function() { # Draw all points, set up plotting field plot(CALORIES ~ SUGARS) # draw the outlier (Quaker oats)with a different symbol points(CALORIES[58] ~ SUGARS[58], col='black', bg='black', pch=25) # draw the shelf 1 and shelf 2 cereals with a different color points(CALORIES[SHELF==1] ~ SUGARS[SHELF==1], col='red') points(CALORIES[SHELF==2] ~ SUGARS[SHELF==2], col='blue') # draw the regression line for the two interesting subpops abline(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58), col='purple') abline(lm(CALORIES[SHELF==3] ~ SUGARS[SHELF==3] + O58[SHELF==3])) } > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > ?key No documentation for 'key' in specified packages and libraries: you could try '??key' > ?plot > ?legend > draw_picture=edit(draw_picture) > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients 3: In legend(-1, 1.9, c("sin", "cos", "tan"), col = c("red", "blue", : 'merge = TRUE' has no effect when no line segments are drawn > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > draw_picture=edit(draw_picture) Error in edit(name, file, title, editor) : unexpected ',' occurred on line 15 use a command like x <- edit() to recover > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > ?pch > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > ?legend > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > draw_picture=edit(draw_picture) > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > draw_picture function() { # Draw all points, set up plotting field plot(CALORIES ~ SUGARS) # draw the outlier (Quaker oats)with a different symbol points(CALORIES[58] ~ SUGARS[58], col='black', bg='black', pch=25) # draw the shelf 1 and shelf 2 cereals with a different color points(CALORIES[SHELF==1] ~ SUGARS[SHELF==1], col='red') points(CALORIES[SHELF==2] ~ SUGARS[SHELF==2], col='blue') # draw the regression line for the two interesting subpops abline(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58), col='purple') abline(lm(CALORIES[SHELF==3] ~ SUGARS[SHELF==3] + O58[SHELF==3])) # Add a key legend(0, 160, c("Shelf 1", "Shelf 2", "Shelf 3"), col = c('red','blue','black'), pch=c(21,21,21), title='Key:') } > > > > > > > > > > > > > > > > > > > > > > > > > > > > plot(lm(CALORIES ~ SUGARS + FAT + FIBER + PROTEIN + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > cereal[1,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 1 100%_Bran 70 4 1 130 10 5 6 3 > summary(lm(CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + factor(SHELF))) Call: lm(formula = CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + factor(SHELF)) Residuals: Min 1Q Median 3Q Max -15.459 -3.777 -1.011 2.886 40.640 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 23.517108 6.492319 3.622 0.000558 *** PROTEIN 5.562041 1.133009 4.909 6.02e-06 *** FAT 8.520430 1.132547 7.523 1.61e-10 *** SODIUM 0.001287 0.012950 0.099 0.921116 FIBER -1.061850 0.554075 -1.916 0.059513 . CARBO 2.837985 0.308606 9.196 1.50e-13 *** SUGARS 3.302795 0.279079 11.835 < 2e-16 *** factor(SHELF)2 -2.755322 2.928959 -0.941 0.350180 factor(SHELF)3 -1.885309 2.565114 -0.735 0.464879 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 8.298 on 68 degrees of freedom Multiple R-squared: 0.8377, Adjusted R-squared: 0.8186 F-statistic: 43.88 on 8 and 68 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + factor(SHELF))) Call: lm(formula = CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + factor(SHELF)) Residuals: Min 1Q Median 3Q Max -15.625 -3.935 -1.003 2.755 40.660 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 23.4785 6.4340 3.649 0.000507 *** PROTEIN 5.5610 1.1248 4.944 5.16e-06 *** FAT 8.5323 1.1181 7.631 9.45e-11 *** FIBER -1.0541 0.5446 -1.936 0.057023 . CARBO 2.8513 0.2761 10.327 1.22e-15 *** SUGARS 3.3107 0.2655 12.470 < 2e-16 *** factor(SHELF)2 -2.8034 2.8680 -0.977 0.331756 factor(SHELF)3 -1.9232 2.5183 -0.764 0.447662 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 8.238 on 69 degrees of freedom Multiple R-squared: 0.8377, Adjusted R-squared: 0.8212 F-statistic: 50.88 on 7 and 69 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS )) Call: lm(formula = CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS) Residuals: Min 1Q Median 3Q Max -14.844 -3.592 -1.051 2.923 41.773 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 21.9038 6.1090 3.586 0.000614 *** PROTEIN 5.7180 1.1057 5.172 2.06e-06 *** FAT 8.3883 1.0643 7.881 2.77e-11 *** FIBER -1.0867 0.4975 -2.184 0.032234 * CARBO 2.8633 0.2663 10.752 < 2e-16 *** SUGARS 3.2461 0.2550 12.732 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 8.183 on 71 degrees of freedom Multiple R-squared: 0.8352, Adjusted R-squared: 0.8236 F-statistic: 71.98 on 5 and 71 DF, p-value: < 2.2e-16 > plot(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS )) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: > plot(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + O58)) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: Warning messages: 1: Not plotting observations with leverage one: 58 2: Not plotting observations with leverage one: 58 > summary(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + O58)) Call: lm(formula = CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + O58) Residuals: Min 1Q Median 3Q Max -12.1891 -2.9905 -0.9437 2.5162 16.4884 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.2589 4.2917 -0.293 0.770 PROTEIN 3.8860 0.6963 5.581 4.23e-07 *** FAT 8.6983 0.6512 13.356 < 2e-16 *** FIBER 0.2501 0.3277 0.763 0.448 CARBO 4.1446 0.2005 20.675 < 2e-16 *** SUGARS 3.9681 0.1692 23.449 < 2e-16 *** O58TRUE 71.8695 6.5612 10.954 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 5.002 on 70 degrees of freedom Multiple R-squared: 0.9393, Adjusted R-squared: 0.9341 F-statistic: 180.5 on 6 and 70 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + factor(SHELF) + O58)) Call: lm(formula = CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + factor(SHELF) + O58) Residuals: Min 1Q Median 3Q Max -11.7207 -3.2005 -0.7102 2.4930 16.1621 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.338819 4.627467 -0.289 0.773 PROTEIN 3.880558 0.714465 5.431 8.38e-07 *** FAT 8.616332 0.696483 12.371 < 2e-16 *** SODIUM -0.001528 0.007968 -0.192 0.849 FIBER 0.204418 0.360963 0.566 0.573 CARBO 4.151360 0.226493 18.329 < 2e-16 *** SUGARS 3.980146 0.183075 21.741 < 2e-16 *** factor(SHELF)2 0.069617 1.820600 0.038 0.970 factor(SHELF)3 0.667894 1.595545 0.419 0.677 O58TRUE 72.282944 6.804783 10.622 5.25e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 5.102 on 67 degrees of freedom Multiple R-squared: 0.9395, Adjusted R-squared: 0.9314 F-statistic: 115.7 on 9 and 67 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + SHELF==3 + O58)) Call: lm(formula = CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + SHELF == 3 + O58) Residuals: Min 1Q Median 3Q Max -56.883 -6.883 3.117 3.117 53.117 Coefficients: (1 not defined because of singularities) Estimate Std. Error t value (Intercept) 106.88 2.22 48.14 PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + SHELF == 3 + O58TRUE NA NA NA Pr(>|t|) (Intercept) <2e-16 *** PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + SHELF == 3 + O58TRUE NA --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 19.48 on 76 degrees of freedom > summary(lm(CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + ()SHELF==3) + O58)) Error: unexpected ')' in "summary(lm(CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + ()" > summary(lm(CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + (SHELF==3) + O58)) Call: lm(formula = CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + (SHELF == 3) + O58) Residuals: Min 1Q Median 3Q Max -11.7788 -3.2365 -0.6895 2.4926 16.1724 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.285751 4.381918 -0.293 0.770 PROTEIN 3.877669 0.705224 5.498 6.24e-07 *** FAT 8.617857 0.690215 12.486 < 2e-16 *** SODIUM -0.001576 0.007809 -0.202 0.841 FIBER 0.203293 0.357111 0.569 0.571 CARBO 4.150476 0.223651 18.558 < 2e-16 *** SUGARS 3.981661 0.177423 22.442 < 2e-16 *** SHELF == 3TRUE 0.635291 1.338694 0.475 0.637 O58TRUE 72.244935 6.682184 10.812 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 5.065 on 68 degrees of freedom Multiple R-squared: 0.9395, Adjusted R-squared: 0.9324 F-statistic: 132.1 on 8 and 68 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + (SHELF==3) + O58)) Call: lm(formula = CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + (SHELF == 3) + O58) Residuals: Min 1Q Median 3Q Max -11.7685 -3.2703 -0.7307 2.5755 16.1492 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.1769 4.3183 -0.273 0.786 PROTEIN 3.8777 0.7003 5.537 5.19e-07 *** FAT 8.6042 0.6821 12.615 < 2e-16 *** FIBER 0.1918 0.3501 0.548 0.586 CARBO 4.1322 0.2031 20.345 < 2e-16 *** SUGARS 3.9726 0.1704 23.315 < 2e-16 *** SHELF == 3TRUE 0.6538 1.3262 0.493 0.624 O58TRUE 72.1671 6.6245 10.894 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 5.029 on 69 degrees of freedom Multiple R-squared: 0.9395, Adjusted R-squared: 0.9334 F-statistic: 153.1 on 7 and 69 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + O58)) Call: lm(formula = CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + O58) Residuals: Min 1Q Median 3Q Max -12.1891 -2.9905 -0.9437 2.5162 16.4884 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.2589 4.2917 -0.293 0.770 PROTEIN 3.8860 0.6963 5.581 4.23e-07 *** FAT 8.6983 0.6512 13.356 < 2e-16 *** FIBER 0.2501 0.3277 0.763 0.448 CARBO 4.1446 0.2005 20.675 < 2e-16 *** SUGARS 3.9681 0.1692 23.449 < 2e-16 *** O58TRUE 71.8695 6.5612 10.954 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 5.002 on 70 degrees of freedom Multiple R-squared: 0.9393, Adjusted R-squared: 0.9341 F-statistic: 180.5 on 6 and 70 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + CARBO + SUGARS + O58)) Call: lm(formula = CALORIES ~ PROTEIN + FAT + CARBO + SUGARS + O58) Residuals: Min 1Q Median 3Q Max -12.2166 -3.0019 -0.1584 2.5043 16.5380 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.04175 3.92730 0.011 0.992 PROTEIN 4.15389 0.59962 6.928 1.59e-09 *** FAT 8.59671 0.63562 13.525 < 2e-16 *** CARBO 4.06656 0.17194 23.651 < 2e-16 *** SUGARS 3.94232 0.16534 23.844 < 2e-16 *** O58TRUE 70.00425 6.07124 11.530 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 4.987 on 71 degrees of freedom Multiple R-squared: 0.9388, Adjusted R-squared: 0.9345 F-statistic: 217.8 on 5 and 71 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ SUGARS + O58)) Call: lm(formula = CALORIES ~ SUGARS + O58) Residuals: Min 1Q Median 3Q Max -39.1578 -9.5849 0.4151 10.8422 37.8795 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 89.1578 3.5429 25.165 < 2e-16 *** SUGARS 2.5356 0.4287 5.914 9.58e-08 *** O58TRUE 13.3778 16.7222 0.800 0.426 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.26 on 74 degrees of freedom Multiple R-squared: 0.3221, Adjusted R-squared: 0.3038 F-statistic: 17.58 on 2 and 74 DF, p-value: 5.667e-07 > cor(residuals(lm(CALORIES ~ SUGARS + O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.8233531 0.2297927 0.4045617 0.3147774 -0.2596833 0.5774692 6.393162e-17 0.06345195 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS + O58)), cereal) : NAs introduced by coercion > cor(residuals(lm(CALORIES ~ SUGARS + CARBO + O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.5699005 0.5175758 0.7694434 0.07948173 0.1515787 8.590074e-18 5.176803e-17 0.2786484 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS + CARBO + O58)), cereal) : NAs introduced by coercion > cor(residuals(lm(CALORIES ~ SUGARS + CARBO + FAT+ O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.3202921 0.5534573 2.276893e-17 0.0368857 0.3238235 -4.434146e-17 -7.297588e-18 0.1309996 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS + CARBO + FAT + O58)), cereal) : NAs introduced by coercion > cor(residuals(lm(CALORIES ~ SUGARS + CARBO + FAT + PROTEIN+ O58)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS [1,] NA 0.2474111 -4.040225e-17 8.821112e-18 -0.01334798 0.06674655 -3.444116e-17 1.862463e-17 SHELF [1,] 0.07296655 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS + CARBO + FAT + PROTEIN + : NAs introduced by coercion Fri Apr 30 11:01:34 slick.local R[1801] : kCGErrorIllegalArgument: CGSShapeWindow > > > > > > > > > > > > > > > > > > > > > > > > > > > > summary(lm(CALORIES ~ SUGAR + FAT + PROTEIN + CARBO + FIBER + O58)) Error in eval(expr, envir, enclos) : object 'SUGAR' not found > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + FIBER + O58)) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + FIBER + O58) Residuals: Min 1Q Median 3Q Max -12.1891 -2.9905 -0.9437 2.5162 16.4884 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.2589 4.2917 -0.293 0.770 SUGARS 3.9681 0.1692 23.449 < 2e-16 *** FAT 8.6983 0.6512 13.356 < 2e-16 *** PROTEIN 3.8860 0.6963 5.581 4.23e-07 *** CARBO 4.1446 0.2005 20.675 < 2e-16 *** FIBER 0.2501 0.3277 0.763 0.448 O58TRUE 71.8695 6.5612 10.954 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 5.002 on 70 degrees of freedom Multiple R-squared: 0.9393, Adjusted R-squared: 0.9341 F-statistic: 180.5 on 6 and 70 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + O58)) Call: lm(formula = CALORIES ~ SUGARS + FAT + PROTEIN + CARBO + O58) Residuals: Min 1Q Median 3Q Max -12.2166 -3.0019 -0.1584 2.5043 16.5380 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.04175 3.92730 0.011 0.992 SUGARS 3.94232 0.16534 23.844 < 2e-16 *** FAT 8.59671 0.63562 13.525 < 2e-16 *** PROTEIN 4.15389 0.59962 6.928 1.59e-09 *** CARBO 4.06656 0.17194 23.651 < 2e-16 *** O58TRUE 70.00425 6.07124 11.530 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 4.987 on 71 degrees of freedom Multiple R-squared: 0.9388, Adjusted R-squared: 0.9345 F-statistic: 217.8 on 5 and 71 DF, p-value: < 2.2e-16 > > cereal[58,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 58 Quaker_Oatmeal 100 5 2 0 2.7 -1 -1 1 > summary(lm(CALORIES ~ SUGARS + factor(SHELF) + O58)) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF) + O58) Residuals: Min 1Q Median 3Q Max -39.749 -8.415 0.918 11.965 34.347 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 88.5316 4.4198 20.031 < 2e-16 *** SUGARS 2.7619 0.4655 5.933 9.52e-08 *** factor(SHELF)2 -5.5742 5.5557 -1.003 0.319 factor(SHELF)3 1.2174 4.6535 0.262 0.794 O58TRUE 14.2303 16.9061 0.842 0.403 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 16.24 on 72 degrees of freedom Multiple R-squared: 0.3416, Adjusted R-squared: 0.305 F-statistic: 9.337 on 4 and 72 DF, p-value: 3.894e-06 > summary(lm(CALORIES ~ SUGARS + factor(SHELF) + factor(SHELF)*SUGARS+ O58)) Call: lm(formula = CALORIES ~ SUGARS + factor(SHELF) + factor(SHELF) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -35.01861 -5.93020 -0.01600 9.14169 29.75349 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 98.3314 4.9146 20.008 < 2e-16 *** SUGARS 0.8423 0.7318 1.151 0.253626 factor(SHELF)2 0.8613 9.2711 0.093 0.926243 factor(SHELF)3 -24.6802 6.7502 -3.656 0.000491 *** O58TRUE 2.5109 14.9629 0.168 0.867217 SUGARS:factor(SHELF)2 0.2317 1.0506 0.221 0.826073 SUGARS:factor(SHELF)3 4.3856 0.9548 4.593 1.88e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.92 on 70 degrees of freedom Multiple R-squared: 0.53, Adjusted R-squared: 0.4897 F-statistic: 13.15 on 6 and 70 DF, p-value: 6.572e-10 > summary(lm(CALORIES ~ SUGARS + (SHELF==3) + (SHELF==3)*SUGARS+ O58)) Call: lm(formula = CALORIES ~ SUGARS + (SHELF == 3) + (SHELF == 3) * SUGARS + O58) Residuals: Min 1Q Median 3Q Max -35.0186 -5.7355 -0.2465 8.8490 29.7535 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 98.1539 4.0495 24.238 < 2e-16 *** SUGARS 1.0831 0.4570 2.370 0.020466 * SHELF == 3TRUE -24.5027 6.1082 -4.011 0.000146 *** O58TRUE 2.9292 14.4543 0.203 0.839981 SUGARS:SHELF == 3TRUE 4.1448 0.7591 5.460 6.43e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.75 on 72 degrees of freedom Multiple R-squared: 0.5279, Adjusted R-squared: 0.5016 F-statistic: 20.12 on 4 and 72 DF, p-value: 3.696e-11 > draw_picture() Warning messages: 1: In abline(lm(CALORIES ~ SUGARS + (SHELF == 3) * SUGARS + O58), col = "purple") : only using the first two of 5regression coefficients 2: In abline(lm(CALORIES[SHELF == 3] ~ SUGARS[SHELF == 3] + O58[SHELF == : only using the first two of 3regression coefficients > draw_picture function() { # Draw all points, set up plotting field plot(CALORIES ~ SUGARS) # draw the outlier (Quaker oats)with a different symbol points(CALORIES[58] ~ SUGARS[58], col='black', bg='black', pch=25) # draw the shelf 1 and shelf 2 cereals with a different color points(CALORIES[SHELF==1] ~ SUGARS[SHELF==1], col='red') points(CALORIES[SHELF==2] ~ SUGARS[SHELF==2], col='blue') # draw the regression line for the two interesting subpops abline(lm(CALORIES ~ SUGARS + (SHELF==3)*SUGARS + O58), col='purple') abline(lm(CALORIES[SHELF==3] ~ SUGARS[SHELF==3] + O58[SHELF==3])) # Add a key legend(0, 160, c("Shelf 1", "Shelf 2", "Shelf 3"), col = c('red','blue','black'), pch=c(21,21,21), title='Key:') } > cor(CALORIES , cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 1 0.01906607 0.4986098 0.3006492 -0.2934128 0.2506809 0.5623403 0.09723437 Warning message: In cor(CALORIES, cereal) : NAs introduced by coercion > 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 > cor(residuals(lm(CALORIES ~ SUGARS)), cereal) NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF [1,] NA 0.826906 0.2468911 0.418811 0.294591 -0.2588049 0.5287055 4.920474e-17 0.04928505 Warning message: In cor(residuals(lm(CALORIES ~ SUGARS)), cereal) : NAs introduced by coercion > summary(lm(CALORIES ~ SUGARS + CARBO)) Call: lm(formula = CALORIES ~ SUGARS + CARBO) Residuals: Min 1Q Median 3Q Max -31.304 -8.511 -1.145 5.610 53.191 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 52.2253 7.0655 7.392 1.82e-10 *** SUGARS 3.1792 0.3699 8.594 9.72e-13 *** CARBO 2.2368 0.3843 5.821 1.41e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 13.52 on 74 degrees of freedom Multiple R-squared: 0.531, Adjusted R-squared: 0.5183 F-statistic: 41.89 on 2 and 74 DF, p-value: 6.822e-13 > > cereal[1,] NAME CALORIES PROTEIN FAT SODIUM FIBER CARBO SUGARS SHELF 1 100%_Bran 70 4 1 130 10 5 6 3 > summary(lm(CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + factor(SHELF))) Call: lm(formula = CALORIES ~ PROTEIN + FAT + SODIUM + FIBER + CARBO + SUGARS + factor(SHELF)) Residuals: Min 1Q Median 3Q Max -15.459 -3.777 -1.011 2.886 40.640 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 23.517108 6.492319 3.622 0.000558 *** PROTEIN 5.562041 1.133009 4.909 6.02e-06 *** FAT 8.520430 1.132547 7.523 1.61e-10 *** SODIUM 0.001287 0.012950 0.099 0.921116 FIBER -1.061850 0.554075 -1.916 0.059513 . CARBO 2.837985 0.308606 9.196 1.50e-13 *** SUGARS 3.302795 0.279079 11.835 < 2e-16 *** factor(SHELF)2 -2.755322 2.928959 -0.941 0.350180 factor(SHELF)3 -1.885309 2.565114 -0.735 0.464879 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 8.298 on 68 degrees of freedom Multiple R-squared: 0.8377, Adjusted R-squared: 0.8186 F-statistic: 43.88 on 8 and 68 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + factor(SHELF))) Call: lm(formula = CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS + factor(SHELF)) Residuals: Min 1Q Median 3Q Max -15.625 -3.935 -1.003 2.755 40.660 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 23.4785 6.4340 3.649 0.000507 *** PROTEIN 5.5610 1.1248 4.944 5.16e-06 *** FAT 8.5323 1.1181 7.631 9.45e-11 *** FIBER -1.0541 0.5446 -1.936 0.057023 . CARBO 2.8513 0.2761 10.327 1.22e-15 *** SUGARS 3.3107 0.2655 12.470 < 2e-16 *** factor(SHELF)2 -2.8034 2.8680 -0.977 0.331756 factor(SHELF)3 -1.9232 2.5183 -0.764 0.447662 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 8.238 on 69 degrees of freedom Multiple R-squared: 0.8377, Adjusted R-squared: 0.8212 F-statistic: 50.88 on 7 and 69 DF, p-value: < 2.2e-16 > summary(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS )) Call: lm(formula = CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS) Residuals: Min 1Q Median 3Q Max -14.844 -3.592 -1.051 2.923 41.773 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 21.9038 6.1090 3.586 0.000614 *** PROTEIN 5.7180 1.1057 5.172 2.06e-06 *** FAT 8.3883 1.0643 7.881 2.77e-11 *** FIBER -1.0867 0.4975 -2.184 0.032234 * CARBO 2.8633 0.2663 10.752 < 2e-16 *** SUGARS 3.2461 0.2550 12.732 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 8.183 on 71 degrees of freedom Multiple R-squared: 0.8352, Adjusted R-squared: 0.8236 F-statistic: 71.98 on 5 and 71 DF, p-value: < 2.2e-16 > plot(lm(CALORIES ~ PROTEIN + FAT + FIBER + CARBO + SUGARS )) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plot: >