(A)
modInt1<-lm(mpg~cylinders*displacement, data=auto)
summary(modInt1)
##
## Call:
## lm(formula = mpg ~ cylinders * displacement, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -16.0432 -2.4308 -0.2263 2.2048 20.9051
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 48.22040 2.34712 20.545 < 2e-16 ***
## cylinders -2.41838 0.53456 -4.524 8.08e-06 ***
## displacement -0.13436 0.01615 -8.321 1.50e-15 ***
## cylinders:displacement 0.01182 0.00207 5.711 2.24e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.454 on 388 degrees of freedom
## Multiple R-squared: 0.6769, Adjusted R-squared: 0.6744
## F-statistic: 271 on 3 and 388 DF, p-value: < 2.2e-16
modInt2<-lm(mpg~cylinders:horsepower, data=auto)
summary(modInt2)
##
## Call:
## lm(formula = mpg ~ cylinders:horsepower, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.2598 -3.4728 -0.4374 2.7793 17.8564
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 32.4981341 0.4473037 72.65 <2e-16 ***
## cylinders:horsepower -0.0144406 0.0005931 -24.35 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.923 on 390 degrees of freedom
## Multiple R-squared: 0.6031, Adjusted R-squared: 0.6021
## F-statistic: 592.7 on 1 and 390 DF, p-value: < 2.2e-16
modInt3<-lm(mpg~cylinders*weight, data=auto)
summary(modInt3)
##
## Call:
## lm(formula = mpg ~ cylinders * weight, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -14.4916 -2.6225 -0.3927 1.7794 16.7087
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 65.3864559 3.7333137 17.514 < 2e-16 ***
## cylinders -4.2097950 0.7238315 -5.816 1.26e-08 ***
## weight -0.0128348 0.0013628 -9.418 < 2e-16 ***
## cylinders:weight 0.0010979 0.0002101 5.226 2.83e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.165 on 388 degrees of freedom
## Multiple R-squared: 0.7174, Adjusted R-squared: 0.7152
## F-statistic: 328.3 on 3 and 388 DF, p-value: < 2.2e-16
modInt3<-lm(mpg~cylinders:acceleration, data=auto)
summary(modInt3)
##
## Call:
## lm(formula = mpg ~ cylinders:acceleration, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -14.364 -4.090 -0.842 2.997 23.880
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 40.92789 1.24366 32.91 <2e-16 ***
## cylinders:acceleration -0.21146 0.01454 -14.54 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.293 on 390 degrees of freedom
## Multiple R-squared: 0.3515, Adjusted R-squared: 0.3499
## F-statistic: 211.4 on 1 and 390 DF, p-value: < 2.2e-16
modInt4<-lm(mpg~cylinders*year, data=auto)
summary(modInt4)
##
## Call:
## lm(formula = mpg ~ cylinders * year, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.2164 -2.5792 -0.1558 2.2569 15.2532
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -61.61775 15.10277 -4.080 5.47e-05 ***
## cylinders 5.51044 2.73705 2.013 0.04478 *
## year 1.34054 0.19909 6.733 5.99e-11 ***
## cylinders:year -0.11350 0.03647 -3.112 0.00199 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.131 on 388 degrees of freedom
## Multiple R-squared: 0.722, Adjusted R-squared: 0.7199
## F-statistic: 335.9 on 3 and 388 DF, p-value: < 2.2e-16
modInt5<-lm(mpg~displacement:horsepower, data=auto)
summary(modInt5)
##
## Call:
## lm(formula = mpg ~ displacement:horsepower, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.1917 -3.9460 -0.9919 3.0108 18.2170
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.989e+01 3.901e-01 76.62 <2e-16 ***
## displacement:horsepower -2.694e-04 1.209e-05 -22.28 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.184 on 390 degrees of freedom
## Multiple R-squared: 0.56, Adjusted R-squared: 0.5589
## F-statistic: 496.4 on 1 and 390 DF, p-value: < 2.2e-16
modInt6<-lm(mpg~displacement*weight, data=auto)
summary(modInt6)
##
## Call:
## lm(formula = mpg ~ displacement * weight, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.8664 -2.4801 -0.3355 1.8071 17.9429
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.372e+01 1.940e+00 27.697 < 2e-16 ***
## displacement -7.831e-02 1.131e-02 -6.922 1.85e-11 ***
## weight -8.931e-03 8.474e-04 -10.539 < 2e-16 ***
## displacement:weight 1.744e-05 2.789e-06 6.253 1.06e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.097 on 388 degrees of freedom
## Multiple R-squared: 0.7265, Adjusted R-squared: 0.7244
## F-statistic: 343.6 on 3 and 388 DF, p-value: < 2.2e-16
modInt7<-lm(mpg~displacement:acceleration, data=auto)
summary(modInt7)
##
## Call:
## lm(formula = mpg ~ displacement:acceleration, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -14.4845 -2.8803 -0.6247 2.2305 22.0359
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 36.9335310 0.6079798 60.75 <2e-16 ***
## displacement:acceleration -0.0047080 0.0001936 -24.31 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.927 on 390 degrees of freedom
## Multiple R-squared: 0.6025, Adjusted R-squared: 0.6015
## F-statistic: 591.2 on 1 and 390 DF, p-value: < 2.2e-16
modInt8<-lm(mpg~displacement*year, data=auto)
summary(modInt8)
##
## Call:
## lm(formula = mpg ~ displacement * year, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.8530 -2.4250 -0.2234 2.0823 16.9933
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.288e+01 8.368e+00 -8.709 < 2e-16 ***
## displacement 2.523e-01 4.059e-02 6.216 1.32e-09 ***
## year 1.408e+00 1.102e-01 12.779 < 2e-16 ***
## displacement:year -4.080e-03 5.453e-04 -7.482 4.96e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.729 on 388 degrees of freedom
## Multiple R-squared: 0.7735, Adjusted R-squared: 0.7718
## F-statistic: 441.7 on 3 and 388 DF, p-value: < 2.2e-16
modInt9<-lm(mpg~horsepower:weight, data=auto)
summary(modInt9)
##
## Call:
## lm(formula = mpg ~ horsepower:weight, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.5691 -3.3660 -0.6786 2.6173 17.5124
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.292e+01 4.471e-01 73.63 <2e-16 ***
## horsepower:weight -2.791e-05 1.106e-06 -25.25 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.815 on 390 degrees of freedom
## Multiple R-squared: 0.6204, Adjusted R-squared: 0.6194
## F-statistic: 637.3 on 1 and 390 DF, p-value: < 2.2e-16
modInt10<-lm(mpg~horsepower*acceleration, data=auto)
summary(modInt10)
##
## Call:
## lm(formula = mpg ~ horsepower * acceleration, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.3442 -2.7324 -0.4049 2.4210 15.8840
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 33.512440 3.420187 9.798 < 2e-16 ***
## horsepower 0.017590 0.027425 0.641 0.521664
## acceleration 0.800296 0.211899 3.777 0.000184 ***
## horsepower:acceleration -0.015698 0.002003 -7.838 4.45e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.426 on 388 degrees of freedom
## Multiple R-squared: 0.6809, Adjusted R-squared: 0.6784
## F-statistic: 275.9 on 3 and 388 DF, p-value: < 2.2e-16
modInt11<-lm(mpg~horsepower:year, data=auto)
summary(modInt11)
##
## Call:
## lm(formula = mpg ~ horsepower:year, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.7959 -3.5770 -0.4462 3.0817 17.3724
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.045e+01 8.016e-01 50.46 <2e-16 ***
## horsepower:year -2.158e-03 9.621e-05 -22.43 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.164 on 390 degrees of freedom
## Multiple R-squared: 0.5634, Adjusted R-squared: 0.5623
## F-statistic: 503.3 on 1 and 390 DF, p-value: < 2.2e-16
modInt12<-lm(mpg~weight*acceleration, data=auto)
summary(modInt12)
##
## Call:
## lm(formula = mpg ~ weight * acceleration, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.5823 -2.6411 -0.3517 2.2611 15.6704
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.814e+01 4.872e+00 5.776 1.57e-08 ***
## weight -3.168e-03 1.461e-03 -2.168 0.03076 *
## acceleration 1.117e+00 3.097e-01 3.608 0.00035 ***
## weight:acceleration -2.787e-04 9.694e-05 -2.875 0.00426 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.249 on 388 degrees of freedom
## Multiple R-squared: 0.706, Adjusted R-squared: 0.7037
## F-statistic: 310.5 on 3 and 388 DF, p-value: < 2.2e-16
modInt13<-lm(mpg~weight*year, data=auto)
summary(modInt13)
##
## Call:
## lm(formula = mpg ~ weight * year, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.0397 -1.9956 -0.0983 1.6525 12.9896
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.105e+02 1.295e+01 -8.531 3.30e-16 ***
## weight 2.755e-02 4.413e-03 6.242 1.14e-09 ***
## year 2.040e+00 1.718e-01 11.876 < 2e-16 ***
## weight:year -4.579e-04 5.907e-05 -7.752 8.02e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.193 on 388 degrees of freedom
## Multiple R-squared: 0.8339, Adjusted R-squared: 0.8326
## F-statistic: 649.3 on 3 and 388 DF, p-value: < 2.2e-16
modInt14<-lm(mpg~acceleration*year, data=auto)
summary(modInt14)
##
## Call:
## lm(formula = mpg ~ acceleration * year, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.9341 -4.9339 -0.6187 4.7066 18.0828
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -89.41449 34.07514 -2.624 0.00903 **
## acceleration 2.09675 2.17707 0.963 0.33609
## year 1.32728 0.45386 2.924 0.00365 **
## acceleration:year -0.01738 0.02885 -0.602 0.54727
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.026 on 388 degrees of freedom
## Multiple R-squared: 0.4085, Adjusted R-squared: 0.4039
## F-statistic: 89.31 on 3 and 388 DF, p-value: < 2.2e-16
Interactions that appear significant at the 0.0 level: cylinders with displacment, horsepower, weight, then displacment with horsepower, weight, acceleration, year, then horsepower with weight, acceleration, year, and then weight with year.
Interactions that appear significant at the 0.001 level: cylinders with year, and then weight with acceleration.
The interaction between accleration and year was not significant at the 0.05 level.
(B)
Taking some of the interactions that were significant at the 0.0 level;
modInt1<-lm(mpg~cylinders*log(displacement), data=auto)
summary(modInt1)
##
## Call:
## lm(formula = mpg ~ cylinders * log(displacement), data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -15.9898 -2.5737 -0.4187 2.1946 19.9768
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 84.8717 11.4743 7.397 8.71e-13 ***
## cylinders 0.6668 2.5000 0.267 0.790
## log(displacement) -12.1710 2.2511 -5.407 1.12e-07 ***
## cylinders:log(displacement) -0.0921 0.4337 -0.212 0.832
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.387 on 388 degrees of freedom
## Multiple R-squared: 0.6865, Adjusted R-squared: 0.6841
## F-statistic: 283.2 on 3 and 388 DF, p-value: < 2.2e-16
When taking the log of displacment in the interaction between cylinders and dispalcment, the interaction was no longer significant at any level.
modInt2<-lm(mpg~(cylinders)^2:horsepower, data=auto)
summary(modInt2)
##
## Call:
## lm(formula = mpg ~ (cylinders)^2:horsepower, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.2598 -3.4728 -0.4374 2.7793 17.8564
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 32.4981341 0.4473037 72.65 <2e-16 ***
## cylinders:horsepower -0.0144406 0.0005931 -24.35 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.923 on 390 degrees of freedom
## Multiple R-squared: 0.6031, Adjusted R-squared: 0.6021
## F-statistic: 592.7 on 1 and 390 DF, p-value: < 2.2e-16
When squaring cylinders in the interaction between cylinders and horsepower, the interaction remained significant at the 0.0 level with a p less than 2e-16
modInt3<-lm(mpg~sqrt(cylinders)*weight, data=auto)
summary(modInt3)
##
## Call:
## lm(formula = mpg ~ sqrt(cylinders) * weight, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -14.8453 -2.6167 -0.3847 1.7669 16.7109
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 86.718766 7.533994 11.510 < 2e-16 ***
## sqrt(cylinders) -19.061380 3.393991 -5.616 3.73e-08 ***
## weight -0.018523 0.002544 -7.281 1.86e-12 ***
## sqrt(cylinders):weight 0.005025 0.001018 4.935 1.19e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.176 on 388 degrees of freedom
## Multiple R-squared: 0.716, Adjusted R-squared: 0.7138
## F-statistic: 326 on 3 and 388 DF, p-value: < 2.2e-16
When squaring cylinders, the interaction between cylinders and weight is still significant but the p value was larger.
modInt5<-lm(mpg~displacement:log(horsepower), data=auto)
summary(modInt5)
##
## Call:
## lm(formula = mpg ~ displacement:log(horsepower), data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -12.1952 -3.1592 -0.4499 2.5358 17.2179
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 33.68761 0.45431 74.15 <2e-16 ***
## displacement:log(horsepower) -0.01109 0.00042 -26.40 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.681 on 390 degrees of freedom
## Multiple R-squared: 0.6412, Adjusted R-squared: 0.6403
## F-statistic: 697 on 1 and 390 DF, p-value: < 2.2e-16
When taking the log of horsepower in the interaction between displacement and horsepower, the relationship was still significant at the 0.0 level.
modInt6<-lm(mpg~cos(displacement)*weight, data=auto)
summary(modInt6)
##
## Call:
## lm(formula = mpg ~ cos(displacement) * weight, data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.3082 -2.8682 -0.3057 2.0703 16.3998
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.581e+01 8.871e-01 51.638 <2e-16 ***
## cos(displacement) -7.756e-01 1.224e+00 -0.634 0.527
## weight -7.538e-03 2.817e-04 -26.755 <2e-16 ***
## cos(displacement):weight 1.089e-06 4.088e-04 0.003 0.998
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.312 on 388 degrees of freedom
## Multiple R-squared: 0.6971, Adjusted R-squared: 0.6948
## F-statistic: 297.7 on 3 and 388 DF, p-value: < 2.2e-16
When taking the cosine of displacement in the interaction between displacement and weight, the interaction was no longer significant at any level.
modInt7<-lm(mpg~displacement:tan(acceleration), data=auto)
summary(modInt7)
##
## Call:
## lm(formula = mpg ~ displacement:tan(acceleration), data = auto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -14.613 -6.066 -0.626 5.372 22.988
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.363e+01 3.925e-01 60.192 < 2e-16 ***
## displacement:tan(acceleration) 1.147e-04 3.364e-05 3.411 0.000714 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.701 on 390 degrees of freedom
## Multiple R-squared: 0.02897, Adjusted R-squared: 0.02648
## F-statistic: 11.64 on 1 and 390 DF, p-value: 0.0007141
When taking the tan() of acceleration in the interaction between dispalcment and acceleration, the interaction was still significant at the 0.0 level, but the P value was much larger.