An Introduction to Statistical Learning:

3.7 Exercises

library(ISLR)

Exercise 8

attach(Auto)

qualitative_columns <- c(2, 8, 9)

fit1 <- lm(mpg ~ horsepower, data = Auto)

plot(mpg ~ horsepower, Auto)
abline(fit1, col = "red")

plot(fit1)

Exercise 9

qualitative_columns <- c(2, 8, 9)

pairs(Auto)  # almost too complicated to work with

fit <- lm(mpg ~ ., data = Auto)
summary(fit)
## 
## Call:
## lm(formula = mpg ~ ., data = Auto)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.646  0.000  0.000  0.000  5.646 
## 
## Coefficients: (1 not defined because of singularities)
##                                            Estimate Std. Error t value
## (Intercept)                                0.187305  12.773943   0.015
## cylinders                                 -0.918096   0.616653  -1.489
## displacement                               0.003041   0.015621   0.195
## horsepower                                -0.042342   0.029070  -1.457
## weight                                    -0.004193   0.001209  -3.467
## acceleration                              -0.481449   0.171537  -2.807
## year                                       0.636498   0.112195   5.673
## origin                                     1.324264   4.243221   0.312
## nameamc ambassador dpl                     3.371358   3.245610   1.039
## nameamc ambassador sst                     3.364264   3.270924   1.029
## nameamc concord                           -0.122500   3.275058  -0.037
## nameamc concord d/l                       -1.686548   3.422955  -0.493
## nameamc concord dl 6                      -0.529687   3.514452  -0.151
## nameamc gremlin                           -0.426606   2.958293  -0.144
## nameamc hornet                             0.269026   2.902972   0.093
## nameamc hornet sportabout (sw)            -0.403111   3.527112  -0.114
## nameamc matador                            0.462233   2.667735   0.173
## nameamc matador (sw)                       3.118929   2.894160   1.078
## nameamc pacer                              0.012163   3.519402   0.003
## nameamc pacer d/l                         -1.682001   3.517154  -0.478
## nameamc rebel sst                          2.875941   3.284138   0.876
## nameamc spirit dl                          0.713000   4.063462   0.175
## nameaudi 100 ls                            0.936254   3.449074   0.271
## nameaudi 100ls                            -3.133448   2.984726  -1.050
## nameaudi 4000                              4.004843   3.244193   1.234
## nameaudi 5000                             -4.109082   3.450859  -1.191
## nameaudi 5000s (diesel)                   11.652927   3.494256   3.335
## nameaudi fox                               3.199486   3.328970   0.961
## namebmw 2002                               2.082893   3.429803   0.607
## namebmw 320i                              -5.320674   3.378167  -1.575
## namebuick century                          2.213275   3.073805   0.720
## namebuick century 350                      2.163058   3.250910   0.665
## namebuick century limited                  1.154506   3.653147   0.316
## namebuick century luxus (sw)               3.701574   3.397404   1.090
## namebuick century special                  0.471663   3.468124   0.136
## namebuick electra 225 custom               5.565899   3.481596   1.599
## namebuick estate wagon (sw)                2.288361   2.883255   0.794
## namebuick lesabre custom                   3.878880   3.350669   1.158
## namebuick opel isuzu deluxe                2.360903   4.090583   0.577
## namebuick regal sport coupe (turbo)       -0.770758   3.673221  -0.210
## namebuick skyhawk                          1.178015   3.453774   0.341
## namebuick skylark                          0.485925   3.292621   0.148
## namebuick skylark 320                      3.220548   3.239745   0.994
## namebuick skylark limited                  2.526638   3.945353   0.640
## namecadillac eldorado                      7.506805   3.434596   2.186
## namecadillac seville                       4.705913   3.307504   1.423
## namecapri ii                               0.213795   3.974233   0.054
## namechevroelt chevelle malibu              1.190886   3.501889   0.340
## namechevrolet bel air                      3.526745   3.332996   1.058
## namechevrolet camaro                       1.016970   3.965053   0.256
## namechevrolet caprice classic              1.486191   2.705678   0.549
## namechevrolet cavalier                     1.711757   4.062490   0.421
## namechevrolet cavalier 2-door              6.060983   4.085007   1.484
## namechevrolet cavalier wagon               0.377051   4.065117   0.093
## namechevrolet chevelle concours (sw)       1.497987   3.363217   0.445
## namechevrolet chevelle malibu              2.508523   3.012061   0.833
## namechevrolet chevelle malibu classic      2.148872   2.973671   0.723
## namechevrolet chevette                     2.796588   3.583400   0.780
## namechevrolet citation                     0.835024   3.277093   0.255
## namechevrolet concours                    -0.962069   3.436400  -0.280
## namechevrolet impala                       3.901975   2.655000   1.470
## namechevrolet malibu                       0.338930   2.908792   0.117
## namechevrolet malibu classic (sw)          1.566909   3.369001   0.465
## namechevrolet monte carlo                  1.755561   3.510683   0.500
## namechevrolet monte carlo landau           1.360482   2.830125   0.481
## namechevrolet monte carlo s                2.817323   3.294556   0.855
## namechevrolet monza 2+2                    1.960822   3.418832   0.574
## namechevrolet nova                         0.013367   2.932203   0.005
## namechevrolet nova custom                 -0.583803   3.483183  -0.168
## namechevrolet vega                        -0.123809   3.451390  -0.036
## namechevrolet vega (sw)                    0.835785   3.957409   0.211
## namechevrolet vega 2300                    5.309133   3.978383   1.334
## namechevrolet woody                        0.242401   4.035002   0.060
## namechevy c10                             -1.686820   3.292205  -0.512
## namechevy c20                              4.381943   3.755983   1.167
## namechevy s-10                             4.822281   4.016031   1.201
## namechrysler cordoba                       3.158331   3.288955   0.960
## namechrysler lebaron medallion            -2.791925   4.039754  -0.691
## namechrysler lebaron salon                -4.524894   3.582800  -1.263
## namechrysler lebaron town @ country (sw)   2.084281   3.302393   0.631
## namechrysler new yorker brougham           5.282481   3.390324   1.558
## namechrysler newport royal                 4.391942   3.291715   1.334
## namedatsun 1200                            7.452422   6.449055   1.156
## namedatsun 200-sx                         -5.232326   6.424023  -0.814
## namedatsun 200sx                           2.817519   6.441163   0.437
## namedatsun 210                             5.606103   6.195917   0.905
## namedatsun 210 mpg                         5.070308   6.390048   0.793
## namedatsun 280-zx                          5.896050   6.830585   0.863
## namedatsun 310                             4.643895   6.277737   0.740
## namedatsun 310 gx                          4.043465   6.266014   0.645
## namedatsun 510                            -2.468844   6.400190  -0.386
## namedatsun 510 (sw)                        3.062356   6.557580   0.467
## namedatsun 510 hatchback                   6.552699   6.395446   1.025
## namedatsun 610                            -3.382103   6.545652  -0.517
## namedatsun 710                             1.331250   6.306882   0.211
## namedatsun 810                            -3.215340   6.816828  -0.472
## namedatsun 810 maxima                     -2.442319   6.860787  -0.356
## namedatsun b-210                           2.371920   6.357360   0.373
## namedatsun b210                            3.331328   6.462449   0.515
## namedatsun b210 gx                         9.604655   6.404554   1.500
## namedatsun f-10 hatchback                  2.950464   6.329051   0.466
## namedatsun pl510                           0.981674   6.254240   0.157
## namedodge aries se                         0.403815   4.041675   0.100
## namedodge aries wagon (sw)                -2.256829   4.019898  -0.561
## namedodge aspen                           -0.206883   3.088343  -0.067
## namedodge aspen 6                          0.366429   3.465245   0.106
## namedodge aspen se                         3.002155   3.493627   0.859
## namedodge challenger se                    2.064684   3.290611   0.627
## namedodge charger 2.2                      5.309608   4.166685   1.274
## namedodge colt                             1.482396   3.584355   0.414
## namedodge colt (sw)                        3.716950   4.113570   0.904
## namedodge colt hardtop                     1.522048   4.067987   0.374
## namedodge colt hatchback custom            5.628627   4.197231   1.341
## namedodge colt m/m                         6.221646   4.105872   1.515
## namedodge coronet brougham                 2.669663   3.290052   0.811
## namedodge coronet custom                   1.606868   3.247032   0.495
## namedodge coronet custom (sw)              3.302820   3.364562   0.982
## namedodge d100                            -1.672691   3.254823  -0.514
## namedodge d200                             5.074896   3.746461   1.355
## namedodge dart custom                     -0.700127   3.265096  -0.214
## namedodge diplomat                         2.561880   3.282848   0.780
## namedodge magnum xe                        2.349068   3.293521   0.713
## namedodge monaco (sw)                      5.409949   3.475789   1.556
## namedodge monaco brougham                  1.448836   3.286662   0.441
## namedodge omni                             2.600955   4.128988   0.630
## namedodge rampage                          0.321131   4.244538   0.076
## namedodge st. regis                        1.874870   3.310142   0.566
## namefiat 124 sport coupe                   0.843793   3.356728   0.251
## namefiat 124 tc                           -1.284412   3.299112  -0.389
## namefiat 124b                              4.234430   3.350724   1.264
## namefiat 128                              -0.302820   2.911282  -0.104
## namefiat 131                               1.571897   3.313206   0.474
## namefiat strada custom                     6.505740   3.221602   2.019
## namefiat x1.9                              3.420877   3.286517   1.041
## nameford country                           3.810815   3.447980   1.105
## nameford country squire (sw)               2.588023   2.891203   0.895
## nameford escort 2h                         2.903207   4.052921   0.716
## nameford escort 4w                         3.832150   4.172436   0.918
## nameford f108                             -1.507274   3.300893  -0.457
## nameford f250                              5.376492   3.649336   1.473
## nameford fairmont                          1.688480   3.942005   0.428
## nameford fairmont (auto)                  -2.420856   3.577091  -0.677
## nameford fairmont (man)                   -0.267333   3.979340  -0.067
## nameford fairmont 4                       -2.076328   3.945762  -0.526
## nameford fairmont futura                  -2.654573   4.013149  -0.661
## nameford fiesta                            5.590179   4.227911   1.322
## nameford futura                           -1.916806   3.362257  -0.570
## nameford galaxie 500                       4.442480   2.696732   1.647
## nameford gran torino                       2.395149   2.717190   0.881
## nameford gran torino (sw)                  4.305909   3.032697   1.420
## nameford granada                           0.802555   3.476415   0.231
## nameford granada ghia                      1.260545   3.617154   0.348
## nameford granada gl                       -3.179138   3.572976  -0.890
## nameford granada l                        -3.195561   3.585987  -0.891
## nameford ltd                               2.931338   2.921112   1.004
## nameford ltd landau                       -0.237362   3.326697  -0.071
## nameford maverick                          0.203527   3.006394   0.068
## nameford mustang                          -0.086763   3.673287  -0.024
## nameford mustang gl                       -0.608234   4.034452  -0.151
## nameford mustang ii                       -5.296511   3.364527  -1.574
## nameford mustang ii 2+2                    1.150829   3.960070   0.291
## nameford pinto                            -0.775120   3.301082  -0.235
## nameford pinto (sw)                       -0.652033   4.001814  -0.163
## nameford pinto runabout                   -2.119866   3.996017  -0.530
## nameford ranger                            0.908753   4.018900   0.226
## nameford thunderbird                       3.220573   3.297455   0.977
## nameford torino                            2.803510   3.333644   0.841
## nameford torino 500                        2.078087   3.646390   0.570
## namehi 1200d                               6.272325   3.984511   1.574
## namehonda accord                           1.948521   6.116848   0.319
## namehonda accord cvcc                      2.063973   6.429582   0.321
## namehonda accord lx                       -1.109939   6.347929  -0.175
## namehonda civic                            1.053256   6.055926   0.174
## namehonda civic (auto)                    -2.323039   6.246699  -0.372
## namehonda civic 1300                       0.480561   6.224808   0.077
## namehonda civic 1500 gl                   10.153049   6.196347   1.639
## namehonda civic cvcc                       3.182648   6.123490   0.520
## namehonda prelude                          0.704854   6.280545   0.112
## namemaxda glc deluxe                       1.418177   6.244770   0.227
## namemaxda rx3                            -10.867477   6.267079  -1.734
## namemazda 626                              1.984386   6.282271   0.316
## namemazda glc                             15.147599   6.344260   2.388
## namemazda glc 4                            0.684088   6.266174   0.109
## namemazda glc custom                      -2.344981   6.320355  -0.371
## namemazda glc custom l                     4.174484   6.349602   0.657
## namemazda glc deluxe                       2.292567   6.386457   0.359
## namemazda rx-4                            -6.598216   6.446482  -1.024
## namemazda rx-7 gs                         -8.439964   6.251072  -1.350
## namemazda rx2 coupe                       -8.070898   6.367885  -1.267
## namemercedes-benz 240d                     6.431350   3.628762   1.772
## namemercedes-benz 280s                    -0.574813   3.970931  -0.145
## namemercedes benz 300d                     4.052324   3.714017   1.091
## namemercury capri 2000                    -0.712146   4.074233  -0.175
## namemercury capri v6                      -0.303572   3.691241  -0.082
## namemercury cougar brougham                1.589959   3.361893   0.473
## namemercury grand marquis                 -0.237277   3.337834  -0.071
## namemercury lynx l                         5.872369   4.147537   1.416
## namemercury marquis                        3.228385   3.350958   0.963
## namemercury marquis brougham               4.746644   3.423970   1.386
## namemercury monarch                       -1.952366   3.676929  -0.531
## namemercury monarch ghia                   2.483829   3.298276   0.753
## namemercury zephyr                        -0.947324   3.554276  -0.267
## namemercury zephyr 6                      -2.197060   3.553076  -0.618
## namenissan stanza xe                       2.717783   6.321214   0.430
## nameoldsmobile cutlass ciera (diesel)     13.431975   3.705632   3.625
## nameoldsmobile cutlass ls                  9.023570   3.661744   2.464
## nameoldsmobile cutlass salon brougham      4.510530   3.094646   1.458
## nameoldsmobile cutlass supreme             3.859509   3.468811   1.113
## nameoldsmobile delta 88 royale             2.897729   3.327483   0.871
## nameoldsmobile omega                      -2.416124   3.226729  -0.749
## nameoldsmobile omega brougham              2.387769   3.687973   0.647
## nameoldsmobile starfire sx                -0.102617   3.905251  -0.026
## nameoldsmobile vista cruiser               2.806911   3.342458   0.840
## nameopel 1900                              0.364179   2.888955   0.126
## nameopel manta                            -1.463586   2.886584  -0.507
## namepeugeot 304                            6.452724   3.479899   1.854
## namepeugeot 504                            2.256143   3.020582   0.747
## namepeugeot 504 (sw)                       1.205706   3.655813   0.330
## namepeugeot 505s turbo diesel              3.702626   3.568596   1.038
## namepeugeot 604sl                         -3.734443   3.870878  -0.965
## nameplymouth 'cuda 340                     0.001994   3.312175   0.001
## nameplymouth arrow gs                     -0.550125   4.028316  -0.137
## nameplymouth champ                         7.809841   4.225532   1.848
## nameplymouth cricket                       3.723019   4.089471   0.910
## nameplymouth custom suburb                 4.243663   3.356462   1.264
## nameplymouth duster                        3.100163   3.013252   1.029
## nameplymouth fury                          2.614640   3.537123   0.739
## nameplymouth fury gran sedan               3.498384   3.316570   1.055
## nameplymouth fury iii                      4.299562   2.679985   1.604
## nameplymouth grand fury                    5.319669   3.369828   1.579
## nameplymouth horizon                       4.301083   4.214230   1.021
## nameplymouth horizon 4                     4.113045   4.189513   0.982
## nameplymouth horizon miser                 6.302919   4.228303   1.491
## nameplymouth horizon tc3                   5.209914   4.143729   1.257
## nameplymouth reliant                      -0.545007   3.754920  -0.145
## nameplymouth sapporo                      -0.765473   3.911418  -0.196
## nameplymouth satellite                     4.364495   3.282401   1.330
## nameplymouth satellite custom              0.448326   3.526696   0.127
## nameplymouth satellite custom (sw)         3.223333   3.292706   0.979
## nameplymouth satellite sebring             1.749802   3.497976   0.500
## nameplymouth valiant                       1.232906   3.073459   0.401
## nameplymouth valiant custom               -0.014077   3.503255  -0.004
## nameplymouth volare                        1.061859   3.474219   0.306
## nameplymouth volare custom                 1.277611   3.488038   0.366
## nameplymouth volare premier v8            -1.282210   3.255780  -0.394
## namepontiac astro                          0.074570   3.909875   0.019
## namepontiac catalina                       5.445037   2.738420   1.988
## namepontiac catalina brougham              5.087948   3.326698   1.529
## namepontiac firebird                       2.261616   3.549778   0.637
## namepontiac grand prix                     6.401045   3.428059   1.867
## namepontiac grand prix lj                  2.265087   3.274738   0.692
## namepontiac j2000 se hatchback             2.822025   4.099435   0.688
## namepontiac lemans v6                      0.400000   3.461834   0.116
## namepontiac phoenix                        3.126592   3.641875   0.859
## namepontiac phoenix lj                     1.358450   3.465997   0.392
## namepontiac safari (sw)                    7.162903   3.555491   2.015
## namepontiac sunbird coupe                  0.108434   3.930485   0.028
## namepontiac ventura sj                     1.102220   3.450690   0.319
## namerenault 12 (sw)                        1.482167   3.395489   0.437
## namerenault 12tl                          -0.731646   3.266427  -0.224
## namerenault 5 gtl                          6.648358   3.298178   2.016
## namesaab 99e                               3.370839   3.531246   0.955
## namesaab 99gle                            -3.431693   3.516847  -0.976
## namesaab 99le                              0.426670   3.063299   0.139
## namesubaru                                -0.233280   6.193441  -0.038
## namesubaru dl                              0.927894   6.146221   0.151
## nametoyota carina                         -4.818346   6.613451  -0.729
## nametoyota celica gt                       0.811953   6.436095   0.126
## nametoyota celica gt liftback             -7.749581   6.454951  -1.201
## nametoyota corolla                         0.502682   6.023789   0.083
## nametoyota corolla 1200                    4.597137   6.314043   0.728
## nametoyota corolla 1600 (sw)               0.864045   6.491090   0.133
## nametoyota corolla liftback               -2.358642   6.455302  -0.365
## nametoyota corolla tercel                  6.264712   6.367373   0.984
## nametoyota corona                         -1.217090   6.101896  -0.199
## nametoyota corona hardtop                 -1.623374   6.517263  -0.249
## nametoyota corona liftback                 0.624486   6.480690   0.096
## nametoyota corona mark ii                 -0.196994   6.567408  -0.030
## nametoyota cressida                       -2.182111   6.794927  -0.321
## nametoyota mark ii                        -3.168040   6.744488  -0.470
## nametoyota starlet                         4.766154   6.246630   0.763
## nametoyota tercel                          4.934523   6.305873   0.783
## nametoyouta corona mark ii (sw)           -2.085503   6.540427  -0.319
## nametriumph tr7 coupe                      6.023330   3.279325   1.837
## namevokswagen rabbit                      -2.827106   3.226492  -0.876
## namevolkswagen 1131 deluxe sedan           1.497675   3.578202   0.419
## namevolkswagen 411 (sw)                   -0.947433   3.453190  -0.274
## namevolkswagen dasher                     -0.858245   2.683260  -0.320
## namevolkswagen jetta                       1.112715   3.228297   0.345
## namevolkswagen model 111                   1.727602   3.449948   0.501
## namevolkswagen rabbit                     -1.074894   2.814449  -0.382
## namevolkswagen rabbit custom              -1.051324   3.224945  -0.326
## namevolkswagen rabbit custom diesel       14.722011   3.409156   4.318
## namevolkswagen rabbit l                    3.125355   3.244626   0.963
## namevolkswagen scirocco                    0.942324   3.219495   0.293
## namevolkswagen super beetle                0.311060   3.498963   0.089
## namevolkswagen type 3                      0.764483   3.649570   0.209
## namevolvo 144ea                           -2.766457   3.580135  -0.773
## namevolvo 145e (sw)                       -3.338886   3.609192  -0.925
## namevolvo 244dl                           -1.790859   3.478340  -0.515
## namevolvo 245                             -2.848126   3.553844  -0.801
## namevolvo 264gl                           -5.464384   3.628736  -1.506
## namevolvo diesel                           7.278640   3.656834   1.990
## namevw dasher (diesel)                    16.275630   3.503824   4.645
## namevw pickup                             15.324526   3.586036   4.273
## namevw rabbit                              4.756880   2.789326   1.705
## namevw rabbit c (diesel)                  15.164570   3.399743   4.461
## namevw rabbit custom                             NA         NA      NA
##                                          Pr(>|t|)    
## (Intercept)                              0.988335    
## cylinders                                0.140231    
## displacement                             0.846109    
## horsepower                               0.148919    
## weight                                   0.000829 ***
## acceleration                             0.006206 ** 
## year                                     1.89e-07 ***
## origin                                   0.755737    
## nameamc ambassador dpl                   0.301870    
## nameamc ambassador sst                   0.306616    
## nameamc concord                          0.970251    
## nameamc concord d/l                      0.623483    
## nameamc concord dl 6                     0.880556    
## nameamc gremlin                          0.885679    
## nameamc hornet                           0.926382    
## nameamc hornet sportabout (sw)           0.909278    
## nameamc matador                          0.862853    
## nameamc matador (sw)                     0.284233    
## nameamc pacer                            0.997251    
## nameamc pacer d/l                        0.633716    
## nameamc rebel sst                        0.383658    
## nameamc spirit dl                        0.861131    
## nameaudi 100 ls                          0.786702    
## nameaudi 100ls                           0.296773    
## nameaudi 4000                            0.220431    
## nameaudi 5000                            0.237070    
## nameaudi 5000s (diesel)                  0.001266 ** 
## nameaudi fox                             0.339226    
## namebmw 2002                             0.545276    
## namebmw 320i                             0.118967    
## namebuick century                        0.473473    
## namebuick century 350                    0.507615    
## namebuick century limited                0.752754    
## namebuick century luxus (sw)             0.278999    
## namebuick century special                0.892143    
## namebuick electra 225 custom             0.113606    
## namebuick estate wagon (sw)              0.429596    
## namebuick lesabre custom                 0.250252    
## namebuick opel isuzu deluxe              0.565360    
## namebuick regal sport coupe (turbo)      0.834301    
## namebuick skyhawk                        0.733885    
## namebuick skylark                        0.883024    
## namebuick skylark 320                    0.323008    
## namebuick skylark limited                0.523630    
## namecadillac eldorado                    0.031592 *  
## namecadillac seville                     0.158454    
## namecapri ii                             0.957225    
## namechevroelt chevelle malibu            0.734643    
## namechevrolet bel air                    0.292994    
## namechevrolet camaro                     0.798197    
## namechevrolet caprice classic            0.584249    
## namechevrolet cavalier                   0.674558    
## namechevrolet cavalier 2-door            0.141584    
## namechevrolet cavalier wagon             0.926318    
## namechevrolet chevelle concours (sw)     0.657161    
## namechevrolet chevelle malibu            0.407277    
## namechevrolet chevelle malibu classic    0.471889    
## namechevrolet chevette                   0.437307    
## namechevrolet citation                   0.799488    
## namechevrolet concours                   0.780185    
## namechevrolet impala                     0.145343    
## namechevrolet malibu                     0.907516    
## namechevrolet malibu classic (sw)        0.643052    
## namechevrolet monte carlo                0.618323    
## namechevrolet monte carlo landau         0.631955    
## namechevrolet monte carlo s              0.394875    
## namechevrolet monza 2+2                  0.567797    
## namechevrolet nova                       0.996373    
## namechevrolet nova custom                0.867291    
## namechevrolet vega                       0.971468    
## namechevrolet vega (sw)                  0.833241    
## namechevrolet vega 2300                  0.185606    
## namechevrolet woody                      0.952237    
## namechevy c10                            0.609722    
## namechevy c20                            0.246612    
## namechevy s-10                           0.233181    
## namechrysler cordoba                     0.339636    
## namechrysler lebaron medallion           0.491378    
## namechrysler lebaron salon               0.210061    
## namechrysler lebaron town @ country (sw) 0.529641    
## namechrysler new yorker brougham         0.122924    
## namechrysler newport royal               0.185688    
## namedatsun 1200                          0.251090    
## namedatsun 200-sx                        0.417638    
## namedatsun 200sx                         0.662913    
## namedatsun 210                           0.368126    
## namedatsun 210 mpg                       0.429714    
## namedatsun 280-zx                        0.390466    
## namedatsun 310                           0.461496    
## namedatsun 310 gx                        0.520470    
## namedatsun 510                           0.700649    
## namedatsun 510 (sw)                      0.641698    
## namedatsun 510 hatchback                 0.308465    
## namedatsun 610                           0.606711    
## namedatsun 710                           0.833331    
## namedatsun 810                           0.638366    
## namedatsun 810 maxima                    0.722736    
## namedatsun b-210                         0.710004    
## namedatsun b210                          0.607549    
## namedatsun b210 gx                       0.137408    
## namedatsun f-10 hatchback                0.642281    
## namedatsun pl510                         0.875648    
## namedodge aries se                       0.920649    
## namedodge aries wagon (sw)               0.575992    
## namedodge aspen                          0.946748    
## namedodge aspen 6                        0.916035    
## namedodge aspen se                       0.392579    
## namedodge challenger se                  0.532048    
## namedodge charger 2.2                    0.206030    
## namedodge colt                           0.680228    
## namedodge colt (sw)                      0.368771    
## namedodge colt hardtop                   0.709223    
## namedodge colt hatchback custom          0.183482    
## namedodge colt m/m                       0.133405    
## namedodge coronet brougham               0.419382    
## namedodge coronet custom                 0.621967    
## namedodge coronet custom (sw)            0.329059    
## namedodge d100                           0.608647    
## namedodge d200                           0.179140    
## namedodge dart custom                    0.830727    
## namedodge diplomat                       0.437333    
## namedodge magnum xe                      0.477652    
## namedodge monaco (sw)                    0.123313    
## namedodge monaco brougham                0.660460    
## namedodge omni                           0.530433    
## namedodge rampage                        0.939869    
## namedodge st. regis                      0.572613    
## namefiat 124 sport coupe                 0.802132    
## namefiat 124 tc                          0.698013    
## namefiat 124b                            0.209780    
## namefiat 128                             0.917402    
## namefiat 131                             0.636407    
## namefiat strada custom                   0.046595 *  
## namefiat x1.9                            0.300882    
## nameford country                         0.272178    
## nameford country squire (sw)             0.373242    
## nameford escort 2h                       0.475754    
## nameford escort 4w                       0.360985    
## nameford f108                            0.649105    
## nameford f250                            0.144369    
## nameford fairmont                        0.669494    
## nameford fairmont (auto)                 0.500392    
## nameford fairmont (man)                  0.946596    
## nameford fairmont 4                      0.600108    
## nameford fairmont futura                 0.510101    
## nameford fiesta                          0.189646    
## nameford futura                          0.570117    
## nameford galaxie 500                     0.103177    
## nameford gran torino                     0.380544    
## nameford gran torino (sw)                0.159315    
## nameford granada                         0.817981    
## nameford granada ghia                    0.728333    
## nameford granada gl                      0.376099    
## nameford granada l                       0.375378    
## nameford ltd                             0.318467    
## nameford ltd landau                      0.943286    
## nameford maverick                        0.946185    
## nameford mustang                         0.981211    
## nameford mustang gl                      0.880522    
## nameford mustang ii                      0.119151    
## nameford mustang ii 2+2                  0.772059    
## nameford pinto                           0.814923    
## nameford pinto (sw)                      0.870957    
## nameford pinto runabout                  0.597152    
## nameford ranger                          0.821651    
## nameford thunderbird                     0.331497    
## nameford torino                          0.402722    
## nameford torino 500                      0.570247    
## namehi 1200d                             0.119162    
## namehonda accord                         0.750849    
## namehonda accord cvcc                    0.748989    
## namehonda accord lx                      0.861613    
## namehonda civic                          0.862341    
## namehonda civic (auto)                   0.710906    
## namehonda civic 1300                     0.938645    
## namehonda civic 1500 gl                  0.105003    
## namehonda civic cvcc                     0.604593    
## namehonda prelude                        0.910907    
## namemaxda glc deluxe                     0.820893    
## namemaxda rx3                            0.086533 .  
## namemazda 626                            0.752875    
## namemazda glc                            0.019175 *  
## namemazda glc 4                          0.913324    
## namemazda glc custom                     0.711545    
## namemazda glc custom l                   0.512674    
## namemazda glc deluxe                     0.720505    
## namemazda rx-4                           0.308958    
## namemazda rx-7 gs                        0.180548    
## namemazda rx2 coupe                      0.208460    
## namemercedes-benz 240d                   0.079923 .  
## namemercedes-benz 280s                   0.885247    
## namemercedes benz 300d                   0.278317    
## namemercury capri 2000                   0.861658    
## namemercury capri v6                     0.934648    
## namemercury cougar brougham              0.637471    
## namemercury grand marquis                0.943496    
## namemercury lynx l                       0.160468    
## namemercury marquis                      0.338069    
## namemercury marquis brougham             0.169282    
## namemercury monarch                      0.596819    
## namemercury monarch ghia                 0.453489    
## namemercury zephyr                       0.790476    
## namemercury zephyr 6                     0.537995    
## namenissan stanza xe                     0.668323    
## nameoldsmobile cutlass ciera (diesel)    0.000492 ***
## nameoldsmobile cutlass ls                0.015743 *  
## nameoldsmobile cutlass salon brougham    0.148656    
## nameoldsmobile cutlass supreme           0.269004    
## nameoldsmobile delta 88 royale           0.386290    
## nameoldsmobile omega                     0.456054    
## nameoldsmobile omega brougham            0.519087    
## nameoldsmobile starfire sx               0.979098    
## nameoldsmobile vista cruiser             0.403391    
## nameopel 1900                            0.899983    
## nameopel manta                           0.613446    
## namepeugeot 304                          0.067166 .  
## namepeugeot 504                          0.457171    
## namepeugeot 504 (sw)                     0.742359    
## namepeugeot 505s turbo diesel            0.302418    
## namepeugeot 604sl                        0.337405    
## nameplymouth 'cuda 340                   0.999521    
## nameplymouth arrow gs                    0.891698    
## nameplymouth champ                       0.068044 .  
## nameplymouth cricket                     0.365191    
## nameplymouth custom suburb               0.209569    
## nameplymouth duster                      0.306472    
## nameplymouth fury                        0.461822    
## nameplymouth fury gran sedan             0.294497    
## nameplymouth fury iii                    0.112352    
## nameplymouth grand fury                  0.118138    
## nameplymouth horizon                     0.310336    
## nameplymouth horizon 4                   0.329010    
## nameplymouth horizon miser               0.139755    
## nameplymouth horizon tc3                 0.212088    
## nameplymouth reliant                     0.884940    
## nameplymouth sapporo                     0.845310    
## nameplymouth satellite                   0.187186    
## nameplymouth satellite custom            0.899143    
## nameplymouth satellite custom (sw)       0.330392    
## nameplymouth satellite sebring           0.618204    
## nameplymouth valiant                     0.689319    
## nameplymouth valiant custom              0.996803    
## nameplymouth volare                      0.760626    
## nameplymouth volare custom               0.715064    
## nameplymouth volare premier v8           0.694696    
## namepontiac astro                        0.984828    
## namepontiac catalina                     0.049987 *  
## namepontiac catalina brougham            0.129871    
## namepontiac firebird                     0.525762    
## namepontiac grand prix                   0.065314 .  
## namepontiac grand prix lj                0.491020    
## namepontiac j2000 se hatchback           0.493079    
## namepontiac lemans v6                    0.908285    
## namepontiac phoenix                      0.393024    
## namepontiac phoenix lj                   0.696086    
## namepontiac safari (sw)                  0.047108 *  
## namepontiac sunbird coupe                0.978055    
## namepontiac ventura sj                   0.750192    
## namerenault 12 (sw)                      0.663573    
## namerenault 12tl                         0.823303    
## namerenault 5 gtl                        0.046983 *  
## namesaab 99e                             0.342500    
## namesaab 99gle                           0.331939    
## namesaab 99le                            0.889555    
## namesubaru                               0.970043    
## namesubaru dl                            0.880357    
## nametoyota carina                        0.468269    
## nametoyota celica gt                     0.899906    
## nametoyota celica gt liftback            0.233256    
## nametoyota corolla                       0.933690    
## nametoyota corolla 1200                  0.468565    
## nametoyota corolla 1600 (sw)             0.894419    
## nametoyota corolla liftback              0.715735    
## nametoyota corolla tercel                0.327968    
## nametoyota corona                        0.842379    
## nametoyota corona hardtop                0.803893    
## nametoyota corona liftback               0.923461    
## nametoyota corona mark ii                0.976141    
## nametoyota cressida                      0.748894    
## nametoyota mark ii                       0.639756    
## nametoyota starlet                       0.447578    
## nametoyota tercel                        0.436079    
## nametoyouta corona mark ii (sw)          0.750612    
## nametriumph tr7 coupe                    0.069741 .  
## namevokswagen rabbit                     0.383382    
## namevolkswagen 1131 deluxe sedan         0.676597    
## namevolkswagen 411 (sw)                  0.784470    
## namevolkswagen dasher                    0.749866    
## namevolkswagen jetta                     0.731190    
## namevolkswagen model 111                 0.617833    
## namevolkswagen rabbit                    0.703474    
## namevolkswagen rabbit custom             0.745228    
## namevolkswagen rabbit custom diesel      4.24e-05 ***
## namevolkswagen rabbit l                  0.338159    
## namevolkswagen scirocco                  0.770470    
## namevolkswagen super beetle              0.929370    
## namevolkswagen type 3                    0.834581    
## namevolvo 144ea                          0.441829    
## namevolvo 145e (sw)                      0.357530    
## namevolvo 244dl                          0.607987    
## namevolvo 245                            0.425122    
## namevolvo 264gl                          0.135809    
## namevolvo diesel                         0.049758 *  
## namevw dasher (diesel)                   1.23e-05 ***
## namevw pickup                            5.00e-05 ***
## namevw rabbit                            0.091774 .  
## namevw rabbit c (diesel)                 2.49e-05 ***
## namevw rabbit custom                           NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.272 on 85 degrees of freedom
## Multiple R-squared:  0.9816, Adjusted R-squared:  0.9153 
## F-statistic:  14.8 on 306 and 85 DF,  p-value: < 2.2e-16
plot(fit)
## Warning: not plotting observations with leverage one:
##   2, 3, 4, 5, 10, 11, 12, 13, 15, 20, 23, 24, 26, 27, 28, 29, 31, 34, 36, 39, 42, 44, 45, 46, 47, 48, 49, 51, 52, 54, 55, 56, 58, 59, 61, 67, 68, 69, 70, 71, 73, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 89, 90, 93, 94, 95, 96, 98, 102, 104, 105, 110, 111, 113, 114, 115, 116, 120, 121, 124, 128, 134, 136, 137, 140, 147, 150, 151, 153, 156, 157, 160, 162, 163, 164, 165, 169, 175, 178, 181, 183, 185, 187, 195, 198, 199, 200, 201, 203, 206, 207, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 221, 222, 223, 224, 226, 227, 228, 230, 231, 232, 233, 234, 235, 237, 240, 241, 242, 243, 244, 245, 246, 249, 250, 251, 253, 254, 255, 257, 258, 260, 262, 263, 264, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 286, 287, 290, 291, 292, 293, 294, 295, 296, 297, 300, 301, 303, 304, 306, 309, 311, 313, 316, 317, 319, 321, 324, 325, 326, 327, 328, 330, 331, 332, 333, 337, 340, 341, 342, 344, 345, 346, 347, 348, 349, 350, 351, 353, 356, 357, 358, 360, 361, 362, 363, 364, 365, 366, 367, 369, 371, 372, 373, 374, 375, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392

## Warning: not plotting observations with leverage one:
##   2, 3, 4, 5, 10, 11, 12, 13, 15, 20, 23, 24, 26, 27, 28, 29, 31, 34, 36, 39, 42, 44, 45, 46, 47, 48, 49, 51, 52, 54, 55, 56, 58, 59, 61, 67, 68, 69, 70, 71, 73, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 89, 90, 93, 94, 95, 96, 98, 102, 104, 105, 110, 111, 113, 114, 115, 116, 120, 121, 124, 128, 134, 136, 137, 140, 147, 150, 151, 153, 156, 157, 160, 162, 163, 164, 165, 169, 175, 178, 181, 183, 185, 187, 195, 198, 199, 200, 201, 203, 206, 207, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 221, 222, 223, 224, 226, 227, 228, 230, 231, 232, 233, 234, 235, 237, 240, 241, 242, 243, 244, 245, 246, 249, 250, 251, 253, 254, 255, 257, 258, 260, 262, 263, 264, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 286, 287, 290, 291, 292, 293, 294, 295, 296, 297, 300, 301, 303, 304, 306, 309, 311, 313, 316, 317, 319, 321, 324, 325, 326, 327, 328, 330, 331, 332, 333, 337, 340, 341, 342, 344, 345, 346, 347, 348, 349, 350, 351, 353, 356, 357, 358, 360, 361, 362, 363, 364, 365, 366, 367, 369, 371, 372, 373, 374, 375, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

# Use update to add some interaction terms:
summary(update(fit, . ~ . + horsepower:weight))
## 
## Call:
## lm(formula = mpg ~ cylinders + displacement + horsepower + weight + 
##     acceleration + year + origin + name + horsepower:weight, 
##     data = Auto)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.842  0.000  0.000  0.000  5.842 
## 
## Coefficients: (1 not defined because of singularities)
##                                            Estimate Std. Error t value
## (Intercept)                               1.216e+01  1.258e+01   0.966
## cylinders                                -7.575e-01  5.845e-01  -1.296
## displacement                             -1.222e-02  1.544e-02  -0.791
## horsepower                               -1.649e-01  4.570e-02  -3.608
## weight                                   -8.303e-03  1.675e-03  -4.956
## acceleration                             -4.750e-01  1.621e-01  -2.931
## year                                      6.758e-01  1.066e-01   6.338
## origin                                   -4.836e-01  4.044e+00  -0.120
## nameamc ambassador dpl                    3.266e+00  3.066e+00   1.065
## nameamc ambassador sst                    3.850e+00  3.093e+00   1.245
## nameamc concord                           5.893e-01  3.101e+00   0.190
## nameamc concord d/l                      -6.110e-01  3.249e+00  -0.188
## nameamc concord dl 6                      6.912e-01  3.340e+00   0.207
## nameamc gremlin                           8.350e-01  2.820e+00   0.296
## nameamc hornet                            1.503e+00  2.767e+00   0.543
## nameamc hornet sportabout (sw)            1.414e+00  3.376e+00   0.419
## nameamc matador                           1.538e+00  2.540e+00   0.605
## nameamc matador (sw)                      2.653e+00  2.737e+00   0.969
## nameamc pacer                             1.381e+00  3.349e+00   0.412
## nameamc pacer d/l                        -2.779e-02  3.359e+00  -0.008
## nameamc rebel sst                         3.970e+00  3.119e+00   1.273
## nameamc spirit dl                         3.017e-01  3.840e+00   0.079
## nameaudi 100 ls                           2.500e+00  3.291e+00   0.760
## nameaudi 100ls                           -1.520e+00  2.860e+00  -0.531
## nameaudi 4000                             4.579e+00  3.069e+00   1.492
## nameaudi 5000                            -2.502e+00  3.295e+00  -0.759
## nameaudi 5000s (diesel)                   1.305e+01  3.327e+00   3.922
## nameaudi fox                              4.189e+00  3.158e+00   1.326
## namebmw 2002                              4.460e+00  3.316e+00   1.345
## namebmw 320i                             -3.502e+00  3.237e+00  -1.082
## namebuick century                         2.936e+00  2.912e+00   1.008
## namebuick century 350                     1.081e+00  3.088e+00   0.350
## namebuick century limited                 1.355e+00  3.451e+00   0.392
## namebuick century luxus (sw)              2.504e+00  3.229e+00   0.775
## namebuick century special                 1.463e+00  3.289e+00   0.445
## namebuick electra 225 custom             -1.027e+00  3.831e+00  -0.268
## namebuick estate wagon (sw)               3.611e+00  2.752e+00   1.312
## namebuick lesabre custom                  2.867e+00  3.179e+00   0.902
## namebuick opel isuzu deluxe               1.501e+00  3.873e+00   0.388
## namebuick regal sport coupe (turbo)      -1.165e+00  3.472e+00  -0.336
## namebuick skyhawk                         2.375e+00  3.282e+00   0.724
## namebuick skylark                         9.796e-01  3.114e+00   0.315
## namebuick skylark 320                     3.938e+00  3.068e+00   1.284
## namebuick skylark limited                 2.664e+00  3.727e+00   0.715
## namecadillac eldorado                     8.929e+00  3.272e+00   2.729
## namecadillac seville                      2.280e+00  3.207e+00   0.711
## namecapri ii                              3.060e-01  3.754e+00   0.082
## namechevroelt chevelle malibu             2.405e+00  3.328e+00   0.723
## namechevrolet bel air                     3.195e+00  3.150e+00   1.014
## namechevrolet camaro                      1.114e+00  3.746e+00   0.297
## namechevrolet caprice classic             1.755e+00  2.557e+00   0.686
## namechevrolet cavalier                    1.068e+00  3.842e+00   0.278
## namechevrolet cavalier 2-door             5.345e+00  3.865e+00   1.383
## namechevrolet cavalier wagon             -2.467e-01  3.845e+00  -0.064
## namechevrolet chevelle concours (sw)      2.077e+00  3.182e+00   0.653
## namechevrolet chevelle malibu             4.087e+00  2.884e+00   1.417
## namechevrolet chevelle malibu classic     2.732e+00  2.814e+00   0.971
## namechevrolet chevette                    1.007e+00  3.427e+00   0.294
## namechevrolet citation                    1.115e+00  3.097e+00   0.360
## namechevrolet concours                    1.786e-01  3.264e+00   0.055
## namechevrolet impala                      2.444e+00  2.545e+00   0.960
## namechevrolet malibu                      1.013e+00  2.755e+00   0.368
## namechevrolet malibu classic (sw)         2.084e+00  3.186e+00   0.654
## namechevrolet monte carlo                 3.600e+00  3.362e+00   1.071
## namechevrolet monte carlo landau          1.231e+00  2.674e+00   0.460
## namechevrolet monte carlo s               3.292e+00  3.115e+00   1.057
## namechevrolet monza 2+2                   3.221e+00  3.251e+00   0.991
## namechevrolet nova                        1.443e+00  2.802e+00   0.515
## namechevrolet nova custom                 9.935e-01  3.324e+00   0.299
## namechevrolet vega                       -2.054e-01  3.260e+00  -0.063
## namechevrolet vega (sw)                   6.456e-01  3.739e+00   0.173
## namechevrolet vega 2300                   5.472e+00  3.758e+00   1.456
## namechevrolet woody                      -1.439e+00  3.844e+00  -0.374
## namechevy c10                            -1.269e+00  3.112e+00  -0.408
## namechevy c20                             2.843e-01  3.752e+00   0.076
## namechevy s-10                            4.286e+00  3.797e+00   1.129
## namechrysler cordoba                      1.046e+00  3.170e+00   0.330
## namechrysler lebaron medallion           -2.686e+00  3.816e+00  -0.704
## namechrysler lebaron salon               -3.298e+00  3.404e+00  -0.969
## namechrysler lebaron town @ country (sw)  2.543e+00  3.123e+00   0.814
## namechrysler new yorker brougham          4.014e-01  3.518e+00   0.114
## namechrysler newport royal                2.094e+00  3.184e+00   0.658
## namedatsun 1200                           8.835e+00  6.106e+00   1.447
## namedatsun 200-sx                        -1.856e+00  6.151e+00  -0.302
## namedatsun 200sx                          6.115e+00  6.163e+00   0.992
## namedatsun 210                            7.243e+00  5.873e+00   1.233
## namedatsun 210 mpg                        6.525e+00  6.052e+00   1.078
## namedatsun 280-zx                         9.634e+00  6.548e+00   1.471
## namedatsun 310                            6.232e+00  5.949e+00   1.048
## namedatsun 310 gx                         5.674e+00  5.939e+00   0.955
## namedatsun 510                            9.075e-01  6.129e+00   0.148
## namedatsun 510 (sw)                       6.195e+00  6.264e+00   0.989
## namedatsun 510 hatchback                  9.752e+00  6.116e+00   1.594
## namedatsun 610                           -5.370e-02  6.262e+00  -0.009
## namedatsun 710                            3.867e+00  6.005e+00   0.644
## namedatsun 810                            2.984e-01  6.524e+00   0.046
## namedatsun 810 maxima                     8.912e-01  6.557e+00   0.136
## namedatsun b-210                          4.251e+00  6.031e+00   0.705
## namedatsun b210                           5.018e+00  6.125e+00   0.819
## namedatsun b210 gx                        1.149e+01  6.076e+00   1.891
## namedatsun f-10 hatchback                 4.740e+00  6.002e+00   0.790
## namedatsun pl510                          4.024e+00  5.977e+00   0.673
## namedodge aries se                        3.927e-02  3.819e+00   0.010
## namedodge aries wagon (sw)               -2.103e+00  3.798e+00  -0.554
## namedodge aspen                           6.723e-01  2.929e+00   0.230
## namedodge aspen 6                         1.132e+00  3.281e+00   0.345
## namedodge aspen se                        4.039e+00  3.315e+00   1.219
## namedodge challenger se                   3.527e+00  3.139e+00   1.124
## namedodge charger 2.2                     4.877e+00  3.938e+00   1.239
## namedodge colt                            8.325e-01  3.391e+00   0.245
## namedodge colt (sw)                       2.861e+00  3.894e+00   0.735
## namedodge colt hardtop                    6.174e-01  3.852e+00   0.160
## namedodge colt hatchback custom           4.319e+00  3.984e+00   1.084
## namedodge colt m/m                        5.202e+00  3.890e+00   1.337
## namedodge coronet brougham                2.048e+00  3.113e+00   0.658
## namedodge coronet custom                  2.027e+00  3.070e+00   0.660
## namedodge coronet custom (sw)             2.162e+00  3.196e+00   0.676
## namedodge d100                           -1.331e+00  3.076e+00  -0.433
## namedodge d200                            5.028e-01  3.792e+00   0.133
## namedodge dart custom                     5.714e-01  3.108e+00   0.184
## namedodge diplomat                        3.227e+00  3.107e+00   1.038
## namedodge magnum xe                       2.388e+00  3.111e+00   0.768
## namedodge monaco (sw)                     1.679e+00  3.467e+00   0.484
## namedodge monaco brougham                 1.157e+00  3.106e+00   0.372
## namedodge omni                            1.525e+00  3.914e+00   0.390
## namedodge rampage                        -1.441e-01  4.012e+00  -0.036
## namedodge st. regis                       2.512e+00  3.133e+00   0.802
## namefiat 124 sport coupe                  2.095e+00  3.193e+00   0.656
## namefiat 124 tc                          -2.088e-01  3.133e+00  -0.067
## namefiat 124b                             4.863e+00  3.171e+00   1.534
## namefiat 128                             -6.056e-01  2.752e+00  -0.220
## namefiat 131                              2.830e+00  3.152e+00   0.898
## namefiat strada custom                    6.694e+00  3.044e+00   2.199
## namefiat x1.9                             3.383e+00  3.105e+00   1.090
## nameford country                          1.527e+00  3.327e+00   0.459
## nameford country squire (sw)              1.830e+00  2.740e+00   0.668
## nameford escort 2h                        1.484e+00  3.852e+00   0.385
## nameford escort 4w                        1.985e+00  3.980e+00   0.499
## nameford f108                            -8.535e-01  3.124e+00  -0.273
## nameford f250                            -2.986e-02  3.805e+00  -0.008
## nameford fairmont                         1.664e+00  3.724e+00   0.447
## nameford fairmont (auto)                 -1.712e+00  3.386e+00  -0.506
## nameford fairmont (man)                  -2.545e-01  3.759e+00  -0.068
## nameford fairmont 4                      -2.048e+00  3.727e+00  -0.550
## nameford fairmont futura                 -2.743e+00  3.791e+00  -0.723
## nameford fiesta                           3.585e+00  4.038e+00   0.888
## nameford futura                          -5.137e-01  3.204e+00  -0.160
## nameford galaxie 500                      3.805e+00  2.555e+00   1.489
## nameford gran torino                      2.314e+00  2.567e+00   0.901
## nameford gran torino (sw)                 3.586e+00  2.873e+00   1.248
## nameford granada                          2.240e+00  3.312e+00   0.676
## nameford granada ghia                     3.293e+00  3.470e+00   0.949
## nameford granada gl                      -2.568e+00  3.380e+00  -0.760
## nameford granada l                       -2.142e+00  3.402e+00  -0.630
## nameford ltd                              2.005e+00  2.773e+00   0.723
## nameford ltd landau                       5.440e-01  3.151e+00   0.173
## nameford maverick                         1.486e+00  2.866e+00   0.519
## nameford mustang                          1.729e+00  3.512e+00   0.492
## nameford mustang gl                      -7.359e-01  3.811e+00  -0.193
## nameford mustang ii                      -3.604e+00  3.218e+00  -1.120
## nameford mustang ii 2+2                   1.220e+00  3.741e+00   0.326
## nameford pinto                           -8.712e-01  3.118e+00  -0.279
## nameford pinto (sw)                      -8.519e-01  3.781e+00  -0.225
## nameford pinto runabout                  -2.403e+00  3.776e+00  -0.637
## nameford ranger                           2.965e-01  3.801e+00   0.078
## nameford thunderbird                      2.791e+00  3.118e+00   0.895
## nameford torino                           4.073e+00  3.172e+00   1.284
## nameford torino 500                       3.951e+00  3.489e+00   1.132
## namehi 1200d                              1.103e+00  4.067e+00   0.271
## namehonda accord                          4.371e+00  5.823e+00   0.751
## namehonda accord cvcc                     4.084e+00  6.103e+00   0.669
## namehonda accord lx                       9.940e-01  6.029e+00   0.165
## namehonda civic                           3.086e+00  5.753e+00   0.536
## namehonda civic (auto)                   -7.272e-01  5.920e+00  -0.123
## namehonda civic 1300                      1.361e+00  5.886e+00   0.231
## namehonda civic 1500 gl                   1.169e+01  5.871e+00   1.992
## namehonda civic cvcc                      4.283e+00  5.794e+00   0.739
## namehonda prelude                         3.139e+00  5.977e+00   0.525
## namemaxda glc deluxe                      2.993e+00  5.918e+00   0.506
## namemaxda rx3                            -8.105e+00  5.977e+00  -1.356
## namemazda 626                             4.965e+00  6.001e+00   0.827
## namemazda glc                             1.685e+01  6.014e+00   2.802
## namemazda glc 4                           2.382e+00  5.941e+00   0.401
## namemazda glc custom                     -7.157e-01  5.990e+00  -0.119
## namemazda glc custom l                    5.868e+00  6.019e+00   0.975
## namemazda glc deluxe                      3.269e+00  6.040e+00   0.541
## namemazda rx-4                           -3.505e+00  6.159e+00  -0.569
## namemazda rx-7 gs                        -5.653e+00  5.963e+00  -0.948
## namemazda rx2 coupe                      -5.038e+00  6.083e+00  -0.828
## namemercedes-benz 240d                    8.742e+00  3.496e+00   2.500
## namemercedes-benz 280s                    6.101e-01  3.768e+00   0.162
## namemercedes benz 300d                    6.909e+00  3.610e+00   1.914
## namemercury capri 2000                   -9.431e-01  3.849e+00  -0.245
## namemercury capri v6                      6.925e-02  3.489e+00   0.020
## namemercury cougar brougham               1.617e+00  3.176e+00   0.509
## namemercury grand marquis                 5.838e-01  3.163e+00   0.185
## namemercury lynx l                        4.252e+00  3.948e+00   1.077
## namemercury marquis                      -7.615e-01  3.381e+00  -0.225
## namemercury marquis brougham              8.871e-02  3.520e+00   0.025
## namemercury monarch                       1.381e-01  3.529e+00   0.039
## namemercury monarch ghia                  3.233e+00  3.124e+00   1.035
## namemercury zephyr                       -1.899e-01  3.365e+00  -0.056
## namemercury zephyr 6                     -1.530e+00  3.362e+00  -0.455
## namenissan stanza xe                      5.670e+00  6.036e+00   0.939
## nameoldsmobile cutlass ciera (diesel)     1.495e+01  3.529e+00   4.235
## nameoldsmobile cutlass ls                 1.126e+01  3.523e+00   3.196
## nameoldsmobile cutlass salon brougham     5.696e+00  2.945e+00   1.934
## nameoldsmobile cutlass supreme            4.524e+00  3.283e+00   1.378
## nameoldsmobile delta 88 royale            1.669e+00  3.165e+00   0.527
## nameoldsmobile omega                     -2.214e+00  3.049e+00  -0.726
## nameoldsmobile omega brougham             2.780e+00  3.486e+00   0.798
## nameoldsmobile starfire sx                1.110e-01  3.690e+00   0.030
## nameoldsmobile vista cruiser              8.055e-02  3.260e+00   0.025
## nameopel 1900                             1.713e+00  2.758e+00   0.621
## nameopel manta                           -4.976e-01  2.742e+00  -0.181
## namepeugeot 304                           6.710e+00  3.288e+00   2.041
## namepeugeot 504                           4.068e+00  2.904e+00   1.401
## namepeugeot 504 (sw)                      3.036e+00  3.496e+00   0.868
## namepeugeot 505s turbo diesel             5.700e+00  3.423e+00   1.665
## namepeugeot 604sl                        -2.585e+00  3.673e+00  -0.704
## nameplymouth 'cuda 340                    9.794e-01  3.142e+00   0.312
## nameplymouth arrow gs                    -7.350e-01  3.806e+00  -0.193
## nameplymouth champ                        5.503e+00  4.050e+00   1.359
## nameplymouth cricket                      2.212e+00  3.889e+00   0.569
## nameplymouth custom suburb                1.866e+00  3.249e+00   0.574
## nameplymouth duster                       3.971e+00  2.858e+00   1.389
## nameplymouth fury                         3.854e+00  3.362e+00   1.146
## nameplymouth fury gran sedan              2.881e+00  3.138e+00   0.918
## nameplymouth fury iii                     3.232e+00  2.552e+00   1.267
## nameplymouth grand fury                   4.042e+00  3.206e+00   1.261
## nameplymouth horizon                      3.018e+00  3.999e+00   0.755
## nameplymouth horizon 4                    2.555e+00  3.985e+00   0.641
## nameplymouth horizon miser                4.577e+00  4.027e+00   1.136
## nameplymouth horizon tc3                  3.858e+00  3.935e+00   0.981
## nameplymouth reliant                     -9.083e-01  3.549e+00  -0.256
## nameplymouth sapporo                     -3.955e-01  3.696e+00  -0.107
## nameplymouth satellite                    5.672e+00  3.125e+00   1.815
## nameplymouth satellite custom             1.607e+00  3.349e+00   0.480
## nameplymouth satellite custom (sw)        3.005e+00  3.111e+00   0.966
## nameplymouth satellite sebring            2.727e+00  3.317e+00   0.822
## nameplymouth valiant                      2.371e+00  2.923e+00   0.811
## nameplymouth valiant custom               1.194e+00  3.329e+00   0.359
## nameplymouth volare                       2.049e+00  3.295e+00   0.622
## nameplymouth volare custom                2.278e+00  3.308e+00   0.688
## nameplymouth volare premier v8           -1.348e+00  3.076e+00  -0.438
## namepontiac astro                         4.933e-03  3.693e+00   0.001
## namepontiac catalina                      3.206e+00  2.672e+00   1.200
## namepontiac catalina brougham             3.662e+00  3.171e+00   1.155
## namepontiac firebird                      3.936e+00  3.390e+00   1.161
## namepontiac grand prix                    2.319e+00  3.459e+00   0.670
## namepontiac grand prix lj                 1.128e+00  3.112e+00   0.363
## namepontiac j2000 se hatchback            2.147e+00  3.878e+00   0.554
## namepontiac lemans v6                     1.254e+00  3.280e+00   0.382
## namepontiac phoenix                       3.200e+00  3.440e+00   0.930
## namepontiac phoenix lj                    2.278e+00  3.286e+00   0.693
## namepontiac safari (sw)                   3.514e+00  3.530e+00   0.995
## namepontiac sunbird coupe                 3.324e-01  3.713e+00   0.090
## namepontiac ventura sj                    2.216e+00  3.276e+00   0.676
## namerenault 12 (sw)                       2.072e+00  3.212e+00   0.645
## namerenault 12tl                          2.227e-01  3.099e+00   0.072
## namerenault 5 gtl                         5.843e+00  3.125e+00   1.870
## namesaab 99e                              4.963e+00  3.369e+00   1.473
## namesaab 99gle                           -1.753e+00  3.360e+00  -0.522
## namesaab 99le                             2.347e+00  2.950e+00   0.796
## namesubaru                                2.325e+00  5.900e+00   0.394
## namesubaru dl                             2.871e+00  5.835e+00   0.492
## nametoyota carina                        -1.845e+00  6.310e+00  -0.292
## nametoyota celica gt                      4.412e+00  6.174e+00   0.715
## nametoyota celica gt liftback            -4.175e+00  6.190e+00  -0.674
## nametoyota corolla                        2.958e+00  5.737e+00   0.516
## nametoyota corolla 1200                   5.936e+00  5.978e+00   0.993
## nametoyota corolla 1600 (sw)              3.822e+00  6.195e+00   0.617
## nametoyota corolla liftback               1.078e-01  6.142e+00   0.018
## nametoyota corolla tercel                 7.617e+00  6.028e+00   1.263
## nametoyota corona                         1.607e+00  5.825e+00   0.276
## nametoyota corona hardtop                 1.839e+00  6.242e+00   0.295
## nametoyota corona liftback                4.095e+00  6.209e+00   0.660
## nametoyota corona mark ii                 3.357e+00  6.294e+00   0.533
## nametoyota cressida                       1.524e+00  6.513e+00   0.234
## nametoyota mark ii                        6.397e-01  6.471e+00   0.099
## nametoyota starlet                        5.506e+00  5.905e+00   0.932
## nametoyota tercel                         6.458e+00  5.974e+00   1.081
## nametoyouta corona mark ii (sw)           1.546e+00  6.272e+00   0.246
## nametriumph tr7 coupe                     7.406e+00  3.125e+00   2.370
## namevokswagen rabbit                     -3.365e+00  3.052e+00  -1.103
## namevolkswagen 1131 deluxe sedan          7.066e-01  3.388e+00   0.209
## namevolkswagen 411 (sw)                   5.232e-01  3.291e+00   0.159
## namevolkswagen dasher                    -4.883e-01  2.537e+00  -0.192
## namevolkswagen jetta                      1.661e+00  3.054e+00   0.544
## namevolkswagen model 111                  1.535e+00  3.259e+00   0.471
## namevolkswagen rabbit                    -9.320e-01  2.659e+00  -0.351
## namevolkswagen rabbit custom             -5.531e-01  3.050e+00  -0.181
## namevolkswagen rabbit custom diesel       1.391e+01  3.230e+00   4.306
## namevolkswagen rabbit l                   3.421e+00  3.066e+00   1.116
## namevolkswagen scirocco                   1.048e+00  3.041e+00   0.345
## namevolkswagen super beetle              -3.521e-01  3.311e+00  -0.106
## namevolkswagen type 3                     1.002e+00  3.448e+00   0.290
## namevolvo 144ea                          -9.488e-01  3.425e+00  -0.277
## namevolvo 145e (sw)                      -1.516e+00  3.452e+00  -0.439
## namevolvo 244dl                          -6.691e-02  3.326e+00  -0.020
## namevolvo 245                            -1.082e+00  3.398e+00  -0.319
## namevolvo 264gl                          -3.812e+00  3.463e+00  -1.101
## namevolvo diesel                          9.013e+00  3.493e+00   2.581
## namevw dasher (diesel)                    1.609e+01  3.310e+00   4.862
## namevw pickup                             1.487e+01  3.390e+00   4.386
## namevw rabbit                             5.057e+00  2.636e+00   1.918
## namevw rabbit c (diesel)                  1.448e+01  3.218e+00   4.498
## namevw rabbit custom                             NA         NA      NA
## horsepower:weight                         4.225e-05  1.259e-05   3.355
##                                          Pr(>|t|)    
## (Intercept)                              0.336678    
## cylinders                                0.198530    
## displacement                             0.431022    
## horsepower                               0.000523 ***
## weight                                   3.68e-06 ***
## acceleration                             0.004349 ** 
## year                                     1.11e-08 ***
## origin                                   0.905098    
## nameamc ambassador dpl                   0.289804    
## nameamc ambassador sst                   0.216699    
## nameamc concord                          0.849727    
## nameamc concord d/l                      0.851302    
## nameamc concord dl 6                     0.836548    
## nameamc gremlin                          0.767847    
## nameamc hornet                           0.588420    
## nameamc hornet sportabout (sw)           0.676319    
## nameamc matador                          0.546599    
## nameamc matador (sw)                     0.335288    
## nameamc pacer                            0.681065    
## nameamc pacer d/l                        0.993418    
## nameamc rebel sst                        0.206680    
## nameamc spirit dl                        0.937575    
## nameaudi 100 ls                          0.449637    
## nameaudi 100ls                           0.596484    
## nameaudi 4000                            0.139512    
## nameaudi 5000                            0.449787    
## nameaudi 5000s (diesel)                  0.000178 ***
## nameaudi fox                             0.188317    
## namebmw 2002                             0.182271    
## namebmw 320i                             0.282441    
## namebuick century                        0.316172    
## namebuick century 350                    0.727051    
## namebuick century limited                0.695685    
## namebuick century luxus (sw)             0.440301    
## namebuick century special                0.657533    
## namebuick electra 225 custom             0.789297    
## namebuick estate wagon (sw)              0.193051    
## namebuick lesabre custom                 0.369849    
## namebuick opel isuzu deluxe              0.699296    
## namebuick regal sport coupe (turbo)      0.737982    
## namebuick skyhawk                        0.471303    
## namebuick skylark                        0.753835    
## namebuick skylark 320                    0.202804    
## namebuick skylark limited                0.476742    
## namecadillac eldorado                    0.007737 ** 
## namecadillac seville                     0.479072    
## namecapri ii                             0.935235    
## namechevroelt chevelle malibu            0.471947    
## namechevrolet bel air                    0.313366    
## namechevrolet camaro                     0.766878    
## namechevrolet caprice classic            0.494427    
## namechevrolet cavalier                   0.781761    
## namechevrolet cavalier 2-door            0.170318    
## namechevrolet cavalier wagon             0.948989    
## namechevrolet chevelle concours (sw)     0.515748    
## namechevrolet chevelle malibu            0.160104    
## namechevrolet chevelle malibu classic    0.334446    
## namechevrolet chevette                   0.769531    
## namechevrolet citation                   0.719784    
## namechevrolet concours                   0.956502    
## namechevrolet impala                     0.339794    
## namechevrolet malibu                     0.713923    
## namechevrolet malibu classic (sw)        0.514889    
## namechevrolet monte carlo                0.287313    
## namechevrolet monte carlo landau         0.646515    
## namechevrolet monte carlo s              0.293610    
## namechevrolet monza 2+2                  0.324632    
## namechevrolet nova                       0.608045    
## namechevrolet nova custom                0.765758    
## namechevrolet vega                       0.949924    
## namechevrolet vega (sw)                  0.863327    
## namechevrolet vega 2300                  0.149164    
## namechevrolet woody                      0.709061    
## namechevy c10                            0.684566    
## namechevy c20                            0.939784    
## namechevy s-10                           0.262226    
## namechrysler cordoba                     0.742301    
## namechrysler lebaron medallion           0.483464    
## namechrysler lebaron salon               0.335350    
## namechrysler lebaron town @ country (sw) 0.417768    
## namechrysler new yorker brougham         0.909430    
## namechrysler newport royal               0.512530    
## namedatsun 1200                          0.151647    
## namedatsun 200-sx                        0.763602    
## namedatsun 200sx                         0.323966    
## namedatsun 210                           0.220900    
## namedatsun 210 mpg                       0.284061    
## namedatsun 280-zx                        0.144925    
## namedatsun 310                           0.297831    
## namedatsun 310 gx                        0.342092    
## namedatsun 510                           0.882643    
## namedatsun 510 (sw)                      0.325571    
## namedatsun 510 hatchback                 0.114603    
## namedatsun 610                           0.993179    
## namedatsun 710                           0.521429    
## namedatsun 810                           0.963623    
## namedatsun 810 maxima                    0.892205    
## namedatsun b-210                         0.482865    
## namedatsun b210                          0.414958    
## namedatsun b210 gx                       0.062126 .  
## namedatsun f-10 hatchback                0.431954    
## namedatsun pl510                         0.502681    
## namedodge aries se                       0.991820    
## namedodge aries wagon (sw)               0.581168    
## namedodge aspen                          0.819016    
## namedodge aspen 6                        0.731054    
## namedodge aspen se                       0.226434    
## namedodge challenger se                  0.264319    
## namedodge charger 2.2                    0.218968    
## namedodge colt                           0.806699    
## namedodge colt (sw)                      0.464637    
## namedodge colt hardtop                   0.873042    
## namedodge colt hatchback custom          0.281421    
## namedodge colt m/m                       0.184747    
## namedodge coronet brougham               0.512395    
## namedodge coronet custom                 0.510924    
## namedodge coronet custom (sw)            0.500617    
## namedodge d100                           0.666250    
## namedodge d200                           0.894848    
## namedodge dart custom                    0.854554    
## namedodge diplomat                       0.302062    
## namedodge magnum xe                      0.444909    
## namedodge monaco (sw)                    0.629503    
## namedodge monaco brougham                0.710469    
## namedodge omni                           0.697721    
## namedodge rampage                        0.971439    
## namedodge st. regis                      0.424809    
## namefiat 124 sport coupe                 0.513506    
## namefiat 124 tc                          0.947026    
## namefiat 124b                            0.128896    
## namefiat 128                             0.826340    
## namefiat 131                             0.371879    
## namefiat strada custom                   0.030601 *  
## namefiat x1.9                            0.278947    
## nameford country                         0.647588    
## nameford country squire (sw)             0.506138    
## nameford escort 2h                       0.701006    
## nameford escort 4w                       0.619213    
## nameford f108                            0.785374    
## nameford f250                            0.993758    
## nameford fairmont                        0.656118    
## nameford fairmont (auto)                 0.614397    
## nameford fairmont (man)                  0.946181    
## nameford fairmont 4                      0.584066    
## nameford fairmont futura                 0.471401    
## nameford fiesta                          0.377192    
## nameford futura                          0.872993    
## nameford galaxie 500                     0.140130    
## nameford gran torino                     0.369919    
## nameford gran torino (sw)                0.215435    
## nameford granada                         0.500583    
## nameford granada ghia                    0.345433    
## nameford granada gl                      0.449585    
## nameford granada l                       0.530723    
## nameford ltd                             0.471721    
## nameford ltd landau                      0.863347    
## nameford maverick                        0.605400    
## nameford mustang                         0.623831    
## nameford mustang gl                      0.847356    
## nameford mustang ii                      0.265987    
## nameford mustang ii 2+2                  0.745084    
## nameford pinto                           0.780646    
## nameford pinto (sw)                      0.822280    
## nameford pinto runabout                  0.526147    
## nameford ranger                          0.938009    
## nameford thunderbird                     0.373131    
## nameford torino                          0.202666    
## nameford torino 500                      0.260743    
## namehi 1200d                             0.786899    
## namehonda accord                         0.454987    
## namehonda accord cvcc                    0.505275    
## namehonda accord lx                      0.869446    
## namehonda civic                          0.593032    
## namehonda civic (auto)                   0.902522    
## namehonda civic 1300                     0.817701    
## namehonda civic 1500 gl                  0.049673 *  
## namehonda civic cvcc                     0.461839    
## namehonda prelude                        0.600810    
## namemaxda glc deluxe                     0.614282    
## namemaxda rx3                            0.178701    
## namemazda 626                            0.410348    
## namemazda glc                            0.006310 ** 
## namemazda glc 4                          0.689528    
## namemazda glc custom                     0.905176    
## namemazda glc custom l                   0.332429    
## namemazda glc deluxe                     0.589786    
## namemazda rx-4                           0.570784    
## namemazda rx-7 gs                        0.345863    
## namemazda rx2 coupe                      0.409932    
## namemercedes-benz 240d                   0.014355 *  
## namemercedes-benz 280s                   0.871755    
## namemercedes benz 300d                   0.059058 .  
## namemercury capri 2000                   0.807042    
## namemercury capri v6                     0.984211    
## namemercury cougar brougham              0.611867    
## namemercury grand marquis                0.853983    
## namemercury lynx l                       0.284530    
## namemercury marquis                      0.822368    
## namemercury marquis brougham             0.979952    
## namemercury monarch                      0.968883    
## namemercury monarch ghia                 0.303601    
## namemercury zephyr                       0.955133    
## namemercury zephyr 6                     0.650216    
## namenissan stanza xe                     0.350198    
## nameoldsmobile cutlass ciera (diesel)    5.82e-05 ***
## nameoldsmobile cutlass ls                0.001963 ** 
## nameoldsmobile cutlass salon brougham    0.056439 .  
## nameoldsmobile cutlass supreme           0.171784    
## nameoldsmobile delta 88 royale           0.599291    
## nameoldsmobile omega                     0.469627    
## nameoldsmobile omega brougham            0.427317    
## nameoldsmobile starfire sx               0.976062    
## nameoldsmobile vista cruiser             0.980347    
## nameopel 1900                            0.536377    
## nameopel manta                           0.856415    
## namepeugeot 304                          0.044428 *  
## namepeugeot 504                          0.164937    
## namepeugeot 504 (sw)                     0.387720    
## namepeugeot 505s turbo diesel            0.099630 .  
## namepeugeot 604sl                        0.483459    
## nameplymouth 'cuda 340                   0.756058    
## nameplymouth arrow gs                    0.847325    
## nameplymouth champ                       0.177875    
## nameplymouth cricket                     0.571087    
## nameplymouth custom suburb               0.567295    
## nameplymouth duster                      0.168415    
## nameplymouth fury                        0.254873    
## nameplymouth fury gran sedan             0.361299    
## nameplymouth fury iii                    0.208785    
## nameplymouth grand fury                  0.210886    
## nameplymouth horizon                     0.452539    
## nameplymouth horizon 4                   0.523114    
## nameplymouth horizon miser               0.259008    
## nameplymouth horizon tc3                 0.329627    
## nameplymouth reliant                     0.798602    
## nameplymouth sapporo                     0.915055    
## nameplymouth satellite                   0.073110 .  
## nameplymouth satellite custom            0.632700    
## nameplymouth satellite custom (sw)       0.336930    
## nameplymouth satellite sebring           0.413372    
## nameplymouth valiant                     0.419535    
## nameplymouth valiant custom              0.720651    
## nameplymouth volare                      0.535793    
## nameplymouth volare custom               0.493091    
## nameplymouth volare premier v8           0.662311    
## namepontiac astro                        0.998937    
## namepontiac catalina                     0.233547    
## namepontiac catalina brougham            0.251407    
## namepontiac firebird                     0.248881    
## namepontiac grand prix                   0.504425    
## namepontiac grand prix lj                0.717787    
## namepontiac j2000 se hatchback           0.581262    
## namepontiac lemans v6                    0.703307    
## namepontiac phoenix                      0.354960    
## namepontiac phoenix lj                   0.490052    
## namepontiac safari (sw)                  0.322382    
## namepontiac sunbird coupe                0.928885    
## namepontiac ventura sj                   0.500634    
## namerenault 12 (sw)                      0.520771    
## namerenault 12tl                         0.942877    
## namerenault 5 gtl                        0.064980 .  
## namesaab 99e                             0.144451    
## namesaab 99gle                           0.603147    
## namesaab 99le                            0.428541    
## namesubaru                               0.694519    
## namesubaru dl                            0.623946    
## nametoyota carina                        0.770666    
## nametoyota celica gt                     0.476813    
## nametoyota celica gt liftback            0.501855    
## nametoyota corolla                       0.607535    
## nametoyota corolla 1200                  0.323576    
## nametoyota corolla 1600 (sw)             0.538880    
## nametoyota corolla liftback              0.986041    
## nametoyota corolla tercel                0.209906    
## nametoyota corona                        0.783331    
## nametoyota corona hardtop                0.768975    
## nametoyota corona liftback               0.511364    
## nametoyota corona mark ii                0.595193    
## nametoyota cressida                      0.815608    
## nametoyota mark ii                       0.921489    
## nametoyota starlet                       0.353755    
## nametoyota tercel                        0.282790    
## nametoyouta corona mark ii (sw)          0.805937    
## nametriumph tr7 coupe                    0.020079 *  
## namevokswagen rabbit                     0.273385    
## namevolkswagen 1131 deluxe sedan         0.835316    
## namevolkswagen 411 (sw)                  0.874067    
## namevolkswagen dasher                    0.847848    
## namevolkswagen jetta                     0.587921    
## namevolkswagen model 111                 0.638805    
## namevolkswagen rabbit                    0.726840    
## namevolkswagen rabbit custom             0.856528    
## namevolkswagen rabbit custom diesel      4.49e-05 ***
## namevolkswagen rabbit l                  0.267754    
## namevolkswagen scirocco                  0.731268    
## namevolkswagen super beetle              0.915566    
## namevolkswagen type 3                    0.772169    
## namevolvo 144ea                          0.782449    
## namevolvo 145e (sw)                      0.661732    
## namevolvo 244dl                          0.983997    
## namevolvo 245                            0.750882    
## namevolvo 264gl                          0.274103    
## namevolvo diesel                         0.011602 *  
## namevw dasher (diesel)                   5.35e-06 ***
## namevw pickup                            3.33e-05 ***
## namevw rabbit                            0.058472 .  
## namevw rabbit c (diesel)                 2.18e-05 ***
## namevw rabbit custom                           NA    
## horsepower:weight                        0.001193 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.146 on 84 degrees of freedom
## Multiple R-squared:  0.9838, Adjusted R-squared:  0.9244 
## F-statistic: 16.57 on 307 and 84 DF,  p-value: < 2.2e-16
# Lets see if this is indeed a better model:
anova(fit, update(fit, . ~ . + horsepower:weight))
## Analysis of Variance Table
## 
## Model 1: mpg ~ cylinders + displacement + horsepower + weight + acceleration + 
##     year + origin + name
## Model 2: mpg ~ cylinders + displacement + horsepower + weight + acceleration + 
##     year + origin + name + horsepower:weight
##   Res.Df    RSS Df Sum of Sq      F   Pr(>F)   
## 1     85 438.73                                
## 2     84 386.89  1    51.845 11.257 0.001193 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Use update to add some nonlinear terms: Note that other terms i.e. displacement, weight, and accelation should also have a
# significant non-linear term:
summary(update(fit, . ~ . + I(horsepower^2)))
## 
## Call:
## lm(formula = mpg ~ cylinders + displacement + horsepower + weight + 
##     acceleration + year + origin + name + I(horsepower^2), data = Auto)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.778  0.000  0.000  0.000  5.778 
## 
## Coefficients: (1 not defined because of singularities)
##                                            Estimate Std. Error t value
## (Intercept)                              13.4912421 12.4770550   1.081
## cylinders                                -0.3144738  0.5993266  -0.525
## displacement                             -0.0374579  0.0183214  -2.044
## horsepower                               -0.2621504  0.0659609  -3.974
## weight                                   -0.0002323  0.0015652  -0.148
## acceleration                             -0.6841611  0.1695856  -4.034
## year                                      0.6208250  0.1049124   5.918
## origin                                   -0.7823831  4.0061328  -0.195
## nameamc ambassador dpl                    2.6987097  3.0379886   0.888
## nameamc ambassador sst                    2.9788543  3.0578823   0.974
## nameamc concord                          -0.7650492  3.0649689  -0.250
## nameamc concord d/l                      -0.7791586  3.2077220  -0.243
## nameamc concord dl 6                     -0.8545857  3.2847983  -0.260
## nameamc gremlin                           0.6368018  2.7792261   0.229
## nameamc hornet                            0.9013961  2.7177902   0.332
## nameamc hornet sportabout (sw)            1.5435551  3.3381452   0.462
## nameamc matador                           0.1842309  2.4936578   0.074
## nameamc matador (sw)                      1.6619322  2.7332467   0.608
## nameamc pacer                            -0.4048234  3.2901978  -0.123
## nameamc pacer d/l                        -0.4608372  3.3030459  -0.140
## nameamc rebel sst                         3.5070654  3.0732614   1.141
## nameamc spirit dl                        -1.9881353  3.8677342  -0.514
## nameaudi 100 ls                           1.2786778  3.2238731   0.397
## nameaudi 100ls                           -3.0450648  2.7887722  -1.092
## nameaudi 4000                             4.3461495  3.0325266   1.433
## nameaudi 5000                            -3.7853253  3.2253961  -1.174
## nameaudi 5000s (diesel)                   9.0736760  3.3400504   2.717
## nameaudi fox                              3.9414134  3.1169087   1.265
## namebmw 2002                              4.5674378  3.2757441   1.394
## namebmw 320i                             -4.2226894  3.1705142  -1.332
## namebuick century                         1.4011846  2.8804685   0.486
## namebuick century 350                     1.0585550  3.0523468   0.347
## namebuick century limited                 0.8103443  3.4144782   0.237
## namebuick century luxus (sw)              1.7513193  3.2187291   0.544
## namebuick century special                 0.0330588  3.2425309   0.010
## namebuick electra 225 custom             -0.5686210  3.6599994  -0.155
## namebuick estate wagon (sw)               2.4857058  2.6944015   0.923
## namebuick lesabre custom                  2.3158908  3.1596156   0.733
## namebuick opel isuzu deluxe               1.2224702  3.8345418   0.319
## namebuick regal sport coupe (turbo)      -2.1274837  3.4519333  -0.616
## namebuick skyhawk                         2.0930220  3.2365910   0.647
## namebuick skylark                        -0.0659723  3.0800374  -0.021
## namebuick skylark 320                     3.9832516  3.0341116   1.313
## namebuick skylark limited                 2.0390088  3.6886037   0.553
## namecadillac eldorado                     9.5627855  3.2578680   2.935
## namecadillac seville                      1.9920100  3.1781118   0.627
## namecapri ii                             -0.4618423  3.7177701  -0.124
## namechevroelt chevelle malibu            -0.0254338  3.2887223  -0.008
## namechevrolet bel air                     2.6341602  3.1236119   0.843
## namechevrolet camaro                     -0.2690131  3.7212534  -0.072
## namechevrolet caprice classic             1.4282013  2.5279990   0.565
## namechevrolet cavalier                    0.5329066  3.8093007   0.140
## namechevrolet cavalier 2-door             5.3894662  3.8210889   1.410
## namechevrolet cavalier wagon             -1.1431240  3.8207726  -0.299
## namechevrolet chevelle concours (sw)      0.2767795  3.1599923   0.088
## namechevrolet chevelle malibu             2.9101426  2.8163485   1.033
## namechevrolet chevelle malibu classic     0.5164508  2.8139734   0.184
## namechevrolet chevette                    0.1336166  3.4262989   0.039
## namechevrolet citation                    0.4427099  3.0637082   0.145
## namechevrolet concours                   -0.8673676  3.2107766  -0.270
## namechevrolet impala                      2.0722869  2.5305589   0.819
## namechevrolet malibu                      0.2382224  2.7178609   0.088
## namechevrolet malibu classic (sw)         0.9432691  3.1523165   0.299
## namechevrolet monte carlo                 4.4688101  3.3629486   1.329
## namechevrolet monte carlo landau          1.3053964  2.6442644   0.494
## namechevrolet monte carlo s               3.1084862  3.0791748   1.010
## namechevrolet monza 2+2                   1.8991995  3.1943025   0.595
## namechevrolet nova                        0.2088998  2.7401158   0.076
## namechevrolet nova custom                 0.2650691  3.2626505   0.081
## namechevrolet vega                       -0.6760630  3.2282120  -0.209
## namechevrolet vega (sw)                  -0.1282314  3.7068428  -0.035
## namechevrolet vega 2300                   5.7571784  3.7190718   1.548
## namechevrolet woody                      -2.0805987  3.8231003  -0.544
## namechevy c10                            -1.4444219  3.0766631  -0.469
## namechevy c20                            -1.4364927  3.8531319  -0.373
## namechevy s-10                            2.9534452  3.7868721   0.780
## namechrysler cordoba                      1.8692515  3.0930655   0.604
## namechrysler lebaron medallion           -2.8581110  3.7744368  -0.757
## namechrysler lebaron salon               -6.5956410  3.3950140  -1.943
## namechrysler lebaron town @ country (sw)  3.3192169  3.1038937   1.069
## namechrysler new yorker brougham          0.8272003  3.3938517   0.244
## namechrysler newport royal                2.7011575  3.1100527   0.869
## namedatsun 1200                          10.5830259  6.0859481   1.739
## namedatsun 200-sx                        -1.5328724  6.0867086  -0.252
## namedatsun 200sx                          5.8839801  6.0762025   0.968
## namedatsun 210                            7.4124797  5.8099610   1.276
## namedatsun 210 mpg                        7.2971676  6.0012786   1.216
## namedatsun 280-zx                         8.7766436  6.4303345   1.365
## namedatsun 310                            6.1131881  5.8791149   1.040
## namedatsun 310 gx                         6.0229587  5.8793883   1.024
## namedatsun 510                            1.6059040  6.0827133   0.264
## namedatsun 510 (sw)                       6.3463018  6.1922945   1.025
## namedatsun 510 hatchback                  9.8693681  6.0437895   1.633
## namedatsun 610                            0.0340258  6.1866237   0.005
## namedatsun 710                            3.7834277  5.9306325   0.638
## namedatsun 810                           -1.3501601  6.3894396  -0.211
## namedatsun 810 maxima                    -0.1730593  6.4400879  -0.027
## namedatsun b-210                          4.5167638  5.9686511   0.757
## namedatsun b210                           5.4452619  6.0655581   0.898
## namedatsun b210 gx                       11.7883555  6.0135789   1.960
## namedatsun f-10 hatchback                 5.2486532  5.9466151   0.883
## namedatsun pl510                          4.0757286  5.9043551   0.690
## namedodge aries se                       -0.5682269  3.7855318  -0.150
## namedodge aries wagon (sw)               -2.4975717  3.7564186  -0.665
## namedodge aspen                          -1.0982134  2.8957547  -0.379
## namedodge aspen 6                         0.1542007  3.2381426   0.048
## namedodge aspen se                        1.3475469  3.2953515   0.409
## namedodge challenger se                   4.0920372  3.1240468   1.310
## namedodge charger 2.2                     4.3432835  3.9019448   1.113
## namedodge colt                            0.0692770  3.3711306   0.021
## namedodge colt (sw)                       1.9785659  3.8726491   0.511
## namedodge colt hardtop                    0.3193319  3.8149754   0.084
## namedodge colt hatchback custom           4.8644522  3.9270902   1.239
## namedodge colt m/m                        5.3526078  3.8435223   1.393
## namedodge coronet brougham                1.1665366  3.1012986   0.376
## namedodge coronet custom                  1.5909917  3.0337462   0.524
## namedodge coronet custom (sw)             0.8122908  3.2164860   0.253
## namedodge d100                           -1.2503521  3.0432147  -0.411
## namedodge d200                           -1.8097127  3.9745553  -0.455
## namedodge dart custom                     0.4769412  3.0675554   0.155
## namedodge diplomat                        3.1266037  3.0710915   1.018
## namedodge magnum xe                       1.6488272  3.0831309   0.535
## namedodge monaco (sw)                     1.5553188  3.4142667   0.456
## namedodge monaco brougham                 0.4189212  3.0836582   0.136
## namedodge omni                            0.4175843  3.9036970   0.107
## namedodge rampage                        -0.6319645  3.9742808  -0.159
## namedodge st. regis                       2.5195953  3.0977286   0.813
## namefiat 124 sport coupe                  1.7249141  3.1454760   0.548
## namefiat 124 tc                          -1.1430603  3.0826446  -0.371
## namefiat 124b                             4.1082264  3.1308137   1.312
## namefiat 128                             -1.4623593  2.7384678  -0.534
## namefiat 131                              1.7778849  3.0960830   0.574
## namefiat strada custom                    5.7081088  3.0178763   1.891
## namefiat x1.9                             2.6220103  3.0783957   0.852
## nameford country                          1.9362042  3.2620246   0.594
## nameford country squire (sw)              2.2393884  2.7029688   0.828
## nameford escort 2h                        0.1028438  3.8633544   0.027
## nameford escort 4w                        1.4462988  3.9525800   0.366
## nameford f108                            -1.7626125  3.0848564  -0.571
## nameford f250                            -1.2823453  3.8654079  -0.332
## nameford fairmont                         0.2586938  3.7037613   0.070
## nameford fairmont (auto)                 -3.7330905  3.3613311  -1.111
## nameford fairmont (man)                  -1.6817362  3.7380128  -0.450
## nameford fairmont 4                      -3.7631642  3.7153227  -1.013
## nameford fairmont futura                 -4.0924869  3.7700978  -1.086
## nameford fiesta                           3.8744646  3.9779568   0.974
## nameford futura                          -0.2961777  3.1725068  -0.093
## nameford galaxie 500                      3.8740969  2.5243800   1.535
## nameford gran torino                      1.3803536  2.5538275   0.541
## nameford gran torino (sw)                 1.8168642  2.9140950   0.623
## nameford granada                          0.8256505  3.2480642   0.254
## nameford granada ghia                    -0.0133316  3.3974596  -0.004
## nameford granada gl                      -4.3257371  3.3529700  -1.290
## nameford granada l                       -1.3098677  3.3898837  -0.386
## nameford ltd                              1.4057064  2.7609353   0.509
## nameford ltd landau                      -0.2019410  3.1081896  -0.065
## nameford maverick                        -0.0797784  2.8099795  -0.028
## nameford mustang                         -0.2050623  3.4321510  -0.060
## nameford mustang gl                      -2.3491935  3.7993860  -0.618
## nameford mustang ii                      -3.4056246  3.1857646  -1.069
## nameford mustang ii 2+2                  -0.2629656  3.7200882  -0.071
## nameford pinto                           -2.2985153  3.1122503  -0.739
## nameford pinto (sw)                      -1.6332786  3.7485618  -0.436
## nameford pinto runabout                  -2.3304565  3.7339728  -0.624
## nameford ranger                          -0.9665395  3.7897668  -0.255
## nameford thunderbird                      2.8262275  3.0827409   0.917
## nameford torino                           3.1802053  3.1163690   1.020
## nameford torino 500                       1.5169634  3.4103216   0.445
## namehi 1200d                              0.3625240  4.0584381   0.089
## namehonda accord                          4.1427132  5.7464610   0.721
## namehonda accord cvcc                     4.6252687  6.0479348   0.765
## namehonda accord lx                       0.7254444  5.9521495   0.122
## namehonda civic                           3.2029690  5.6885852   0.563
## namehonda civic (auto)                   -0.3260908  5.8618619  -0.056
## namehonda civic 1300                      2.1444439  5.8336879   0.368
## namehonda civic 1500 gl                  12.1889386  5.8160338   2.096
## namehonda civic cvcc                      4.7616874  5.7375259   0.830
## namehonda prelude                         2.9217292  5.8992253   0.495
## namemaxda glc deluxe                      2.8027986  5.8468409   0.479
## namemaxda rx3                            -8.2570727  5.8987640  -1.400
## namemazda 626                             3.8819592  5.8924986   0.659
## namemazda glc                            16.5605690  5.9401022   2.788
## namemazda glc 4                           2.7554231  5.8819028   0.468
## namemazda glc custom                      0.1257715  5.9437158   0.021
## namemazda glc custom l                    6.5490446  5.9679458   1.097
## namemazda glc deluxe                      2.5464127  5.9673508   0.427
## namemazda rx-4                           -4.7837634  6.0434328  -0.792
## namemazda rx-7 gs                        -6.4639722  5.8653994  -1.102
## namemazda rx2 coupe                      -5.8330791  5.9809851  -0.975
## namemercedes-benz 240d                    4.6652441  3.4246244   1.362
## namemercedes-benz 280s                   -2.5364320  3.7486709  -0.677
## namemercedes benz 300d                    2.7221631  3.4890661   0.780
## namemercury capri 2000                   -1.4214282  3.8115460  -0.373
## namemercury capri v6                     -0.5774685  3.4495857  -0.167
## namemercury cougar brougham              -0.3531267  3.1856864  -0.111
## namemercury grand marquis                 0.8273130  3.1321397   0.264
## namemercury lynx l                        3.9506085  3.9105693   1.010
## namemercury marquis                      -0.3803577  3.2826925  -0.116
## namemercury marquis brougham              1.1424153  3.3474519   0.341
## namemercury monarch                      -3.2560243  3.4538491  -0.943
## namemercury monarch ghia                  2.9832690  3.0846459   0.967
## namemercury zephyr                       -2.4929542  3.3475955  -0.745
## namemercury zephyr 6                     -3.1061213  3.3289782  -0.933
## namenissan stanza xe                      6.8047410  6.0108092   1.132
## nameoldsmobile cutlass ciera (diesel)    14.7386046  3.4806083   4.234
## nameoldsmobile cutlass ls                11.5264743  3.4890086   3.304
## nameoldsmobile cutlass salon brougham     4.2797073  2.8920554   1.480
## nameoldsmobile cutlass supreme            1.5404185  3.3024200   0.466
## nameoldsmobile delta 88 royale            1.3168078  3.1388249   0.420
## nameoldsmobile omega                     -2.5644180  3.0150465  -0.851
## nameoldsmobile omega brougham             2.1044674  3.4465906   0.611
## nameoldsmobile starfire sx               -1.3915355  3.6657104  -0.380
## nameoldsmobile vista cruiser             -0.3442072  3.2396086  -0.106
## nameopel 1900                             1.9878655  2.7354641   0.727
## nameopel manta                           -1.3043643  2.6973235  -0.484
## namepeugeot 304                           6.3436743  3.2514506   1.951
## namepeugeot 504                           1.6033833  2.8278074   0.567
## namepeugeot 504 (sw)                      0.7238651  3.4182129   0.212
## namepeugeot 505s turbo diesel             2.8263121  3.3427847   0.845
## namepeugeot 604sl                        -4.2813572  3.6197013  -1.183
## nameplymouth 'cuda 340                    0.2242362  3.0952034   0.072
## nameplymouth arrow gs                    -0.4812877  3.7637529  -0.128
## nameplymouth champ                        5.5384022  3.9965340   1.386
## nameplymouth cricket                      2.6673030  3.8317356   0.696
## nameplymouth custom suburb                1.6739527  3.2137551   0.521
## nameplymouth duster                       2.4459263  2.8209979   0.867
## nameplymouth fury                         0.3823927  3.3606842   0.114
## nameplymouth fury gran sedan              2.0661712  3.1233663   0.662
## nameplymouth fury iii                     2.3696587  2.5589577   0.926
## nameplymouth grand fury                   2.8851512  3.2180908   0.897
## nameplymouth horizon                      1.4876501  4.0118718   0.371
## nameplymouth horizon 4                    0.8454475  4.0150123   0.211
## nameplymouth horizon miser                3.3668835  4.0313212   0.835
## nameplymouth horizon tc3                  2.9391091  3.9210237   0.750
## nameplymouth reliant                     -1.5308019  3.5186112  -0.435
## nameplymouth sapporo                     -0.3369919  3.6563651  -0.092
## nameplymouth satellite                    5.3480111  3.0785598   1.737
## nameplymouth satellite custom            -0.6374563  3.3083879  -0.193
## nameplymouth satellite custom (sw)        2.3077479  3.0865888   0.748
## nameplymouth satellite sebring            0.2246499  3.2947079   0.068
## nameplymouth valiant                      1.2040298  2.8715826   0.419
## nameplymouth valiant custom              -0.7911182  3.2800255  -0.241
## nameplymouth volare                       0.2124784  3.2543064   0.065
## nameplymouth volare custom               -0.2781564  3.2865711  -0.085
## nameplymouth volare premier v8           -1.7547058  3.0446591  -0.576
## namepontiac astro                        -1.0803376  3.6666727  -0.295
## namepontiac catalina                      3.4431492  2.6164524   1.316
## namepontiac catalina brougham             4.2314124  3.1169893   1.358
## namepontiac firebird                      2.4551648  3.3170243   0.740
## namepontiac grand prix                   -0.3771782  3.7005765  -0.102
## namepontiac grand prix lj                 2.0227487  3.0603462   0.661
## namepontiac j2000 se hatchback            0.8414393  3.8682593   0.218
## namepontiac lemans v6                     0.8140282  3.2364159   0.252
## namepontiac phoenix                       2.6784156  3.4048557   0.787
## namepontiac phoenix lj                    0.9952129  3.2398481   0.307
## namepontiac safari (sw)                   3.7305267  3.4520017   1.081
## namepontiac sunbird coupe                -0.8337322  3.6813289  -0.226
## namepontiac ventura sj                    0.6456624  3.2264393   0.200
## namerenault 12 (sw)                       1.2126101  3.1733046   0.382
## namerenault 12tl                         -0.0128054  3.0581881  -0.004
## namerenault 5 gtl                         6.0663126  3.0856369   1.966
## namesaab 99e                              4.7537706  3.3208915   1.431
## namesaab 99gle                           -2.3313608  3.2995831  -0.707
## namesaab 99le                             1.4963482  2.8769887   0.520
## namesubaru                                2.4516873  5.8330061   0.420
## namesubaru dl                             3.0210152  5.7709486   0.523
## nametoyota carina                        -1.3629963  6.2508623  -0.218
## nametoyota celica gt                      4.2935574  6.0882306   0.705
## nametoyota celica gt liftback            -4.0214237  6.1165082  -0.657
## nametoyota corolla                        2.7164995  5.6605687   0.480
## nametoyota corolla 1200                   6.9206597  5.9334103   1.166
## nametoyota corolla 1600 (sw)              4.5058444  6.1459325   0.733
## nametoyota corolla liftback              -0.0569608  6.0640247  -0.009
## nametoyota corolla tercel                 7.9604848  5.9671635   1.334
## nametoyota corona                         1.4736580  5.7483672   0.256
## nametoyota corona hardtop                 2.2407693  6.1801705   0.363
## nametoyota corona liftback                3.4136102  6.1028403   0.559
## nametoyota corona mark ii                 3.1621747  6.2043932   0.510
## nametoyota cressida                       0.7531143  6.3991274   0.118
## nametoyota mark ii                       -0.3804554  6.3474013  -0.060
## nametoyota starlet                        6.2860610  5.8510860   1.074
## nametoyota tercel                         6.2555023  5.9027204   1.060
## nametoyouta corona mark ii (sw)           1.0793329  6.1717868   0.175
## nametriumph tr7 coupe                     6.8284017  3.0718138   2.223
## namevokswagen rabbit                     -3.2219993  3.0164858  -1.068
## namevolkswagen 1131 deluxe sedan          0.2721744  3.3599146   0.081
## namevolkswagen 411 (sw)                  -0.7783205  3.2266907  -0.241
## namevolkswagen dasher                    -1.3607549  2.5107671  -0.542
## namevolkswagen jetta                      1.0837055  3.0162488   0.359
## namevolkswagen model 111                  2.0708934  3.2246964   0.642
## namevolkswagen rabbit                    -1.0074413  2.6296396  -0.383
## namevolkswagen rabbit custom             -0.0383951  3.0258127  -0.013
## namevolkswagen rabbit custom diesel      13.2316034  3.2111877   4.120
## namevolkswagen rabbit l                   4.1666751  3.0448404   1.368
## namevolkswagen scirocco                   0.8516694  3.0081165   0.283
## namevolkswagen super beetle              -1.2215056  3.2958805  -0.371
## namevolkswagen type 3                    -0.3823414  3.4242307  -0.112
## namevolvo 144ea                          -2.1718341  3.3489156  -0.649
## namevolvo 145e (sw)                      -3.2200709  3.3722705  -0.955
## namevolvo 244dl                          -2.3247849  3.2531350  -0.715
## namevolvo 245                            -3.3511585  3.3232491  -1.008
## namevolvo 264gl                          -5.4439312  3.3903783  -1.606
## namevolvo diesel                          5.1076103  3.4678256   1.473
## namevw dasher (diesel)                   13.8764124  3.3387667   4.156
## namevw pickup                            14.7837501  3.3537401   4.408
## namevw rabbit                             4.7721355  2.6061055   1.831
## namevw rabbit c (diesel)                 13.3500155  3.2149484   4.152
## namevw rabbit custom                             NA         NA      NA
## I(horsepower^2)                           0.0008249  0.0002256   3.657
##                                          Pr(>|t|)    
## (Intercept)                              0.282665    
## cylinders                                0.601166    
## displacement                             0.044037 *  
## horsepower                               0.000149 ***
## weight                                   0.882372    
## acceleration                             0.000120 ***
## year                                     6.87e-08 ***
## origin                                   0.845633    
## nameamc ambassador dpl                   0.376905    
## nameamc ambassador sst                   0.332776    
## nameamc concord                          0.803498    
## nameamc concord d/l                      0.808674    
## nameamc concord dl 6                     0.795374    
## nameamc gremlin                          0.819325    
## nameamc hornet                           0.740968    
## nameamc hornet sportabout (sw)           0.644991    
## nameamc matador                          0.941282    
## nameamc matador (sw)                     0.544799    
## nameamc pacer                            0.902370    
## nameamc pacer d/l                        0.889374    
## nameamc rebel sst                        0.257049    
## nameamc spirit dl                        0.608580    
## nameaudi 100 ls                          0.692648    
## nameaudi 100ls                           0.277998    
## nameaudi 4000                            0.155519    
## nameaudi 5000                            0.243872    
## nameaudi 5000s (diesel)                  0.008007 ** 
## nameaudi fox                             0.209538    
## namebmw 2002                             0.166898    
## namebmw 320i                             0.186508    
## namebuick century                        0.627920    
## namebuick century 350                    0.729609    
## namebuick century limited                0.812982    
## namebuick century luxus (sw)             0.587812    
## namebuick century special                0.991890    
## namebuick electra 225 custom             0.876909    
## namebuick estate wagon (sw)              0.358887    
## namebuick lesabre custom                 0.465620    
## namebuick opel isuzu deluxe              0.750666    
## namebuick regal sport coupe (turbo)      0.539352    
## namebuick skyhawk                        0.519606    
## namebuick skylark                        0.982962    
## namebuick skylark 320                    0.192818    
## namebuick skylark limited                0.581878    
## namecadillac eldorado                    0.004297 ** 
## namecadillac seville                     0.532496    
## namecapri ii                             0.901433    
## namechevroelt chevelle malibu            0.993848    
## namechevrolet bel air                    0.401452    
## namechevrolet camaro                     0.942542    
## namechevrolet caprice classic            0.573611    
## namechevrolet cavalier                   0.889077    
## namechevrolet cavalier 2-door            0.162098    
## namechevrolet cavalier wagon             0.765537    
## namechevrolet chevelle concours (sw)     0.930412    
## namechevrolet chevelle malibu            0.304428    
## namechevrolet chevelle malibu classic    0.854824    
## namechevrolet chevette                   0.968985    
## namechevrolet citation                   0.885451    
## namechevrolet concours                   0.787713    
## namechevrolet impala                     0.415158    
## namechevrolet malibu                     0.930363    
## namechevrolet malibu classic (sw)        0.765503    
## namechevrolet monte carlo                0.187500    
## namechevrolet monte carlo landau         0.622827    
## namechevrolet monte carlo s              0.315625    
## namechevrolet monza 2+2                  0.553737    
## namechevrolet nova                       0.939411    
## namechevrolet nova custom                0.935442    
## namechevrolet vega                       0.834625    
## namechevrolet vega (sw)                  0.972486    
## namechevrolet vega 2300                  0.125378    
## namechevrolet woody                      0.587733    
## namechevy c10                            0.639945    
## namechevy c20                            0.710228    
## namechevy s-10                           0.437632    
## namechrysler cordoba                     0.547249    
## namechrysler lebaron medallion           0.451032    
## namechrysler lebaron salon               0.055397 .  
## namechrysler lebaron town @ country (sw) 0.287965    
## namechrysler new yorker brougham         0.808030    
## namechrysler newport royal               0.387582    
## namedatsun 1200                          0.085711 .  
## namedatsun 200-sx                        0.801780    
## namedatsun 200sx                         0.335642    
## namedatsun 210                           0.205535    
## namedatsun 210 mpg                       0.227416    
## namedatsun 280-zx                        0.175935    
## namedatsun 310                           0.301410    
## namedatsun 310 gx                        0.308578    
## namedatsun 510                           0.792418    
## namedatsun 510 (sw)                      0.308367    
## namedatsun 510 hatchback                 0.106217    
## namedatsun 610                           0.995625    
## namedatsun 710                           0.525244    
## namedatsun 810                           0.833156    
## namedatsun 810 maxima                    0.978625    
## namedatsun b-210                         0.451318    
## namedatsun b210                          0.371893    
## namedatsun b210 gx                       0.053277 .  
## namedatsun f-10 hatchback                0.379956    
## namedatsun pl510                         0.491914    
## namedodge aries se                       0.881042    
## namedodge aries wagon (sw)               0.507948    
## namedodge aspen                          0.705460    
## namedodge aspen 6                        0.962132    
## namedodge aspen se                       0.683636    
## namedodge challenger se                  0.193817    
## namedodge charger 2.2                    0.268838    
## namedodge colt                           0.983653    
## namedodge colt (sw)                      0.610756    
## namedodge colt hardtop                   0.933490    
## namedodge colt hatchback custom          0.218910    
## namedodge colt m/m                       0.167407    
## namedodge coronet brougham               0.707758    
## namedodge coronet custom                 0.601360    
## namedodge coronet custom (sw)            0.801241    
## namedodge d100                           0.682217    
## namedodge d200                           0.650051    
## namedodge dart custom                    0.876817    
## namedodge diplomat                       0.311565    
## namedodge magnum xe                      0.594208    
## namedodge monaco (sw)                    0.649900    
## namedodge monaco brougham                0.892263    
## namedodge omni                           0.915067    
## namedodge rampage                        0.874040    
## namedodge st. regis                      0.418306    
## namefiat 124 sport coupe                 0.584886    
## namefiat 124 tc                          0.711716    
## namefiat 124b                            0.193030    
## namefiat 128                             0.594748    
## namefiat 131                             0.567342    
## namefiat strada custom                   0.062013 .  
## namefiat x1.9                            0.396777    
## nameford country                         0.554402    
## nameford country squire (sw)             0.409740    
## nameford escort 2h                       0.978826    
## nameford escort 4w                       0.715350    
## nameford f108                            0.569271    
## nameford f250                            0.740905    
## nameford fairmont                        0.944482    
## nameford fairmont (auto)                 0.269910    
## nameford fairmont (man)                  0.653941    
## nameford fairmont 4                      0.314028    
## nameford fairmont futura                 0.280800    
## nameford fiesta                          0.332861    
## nameford futura                          0.925842    
## nameford galaxie 500                     0.128622    
## nameford gran torino                     0.590280    
## nameford gran torino (sw)                0.534662    
## nameford granada                         0.799964    
## nameford granada ghia                    0.996878    
## nameford granada gl                      0.200549    
## nameford granada l                       0.700174    
## nameford ltd                             0.611988    
## nameford ltd landau                      0.948352    
## nameford maverick                        0.977418    
## nameford mustang                         0.952499    
## nameford mustang gl                      0.538045    
## nameford mustang ii                      0.288126    
## nameford mustang ii 2+2                  0.943814    
## nameford pinto                           0.462246    
## nameford pinto (sw)                      0.664166    
## nameford pinto runabout                  0.534239    
## nameford ranger                          0.799316    
## nameford thunderbird                     0.361877    
## nameford torino                          0.310429    
## nameford torino 500                      0.657597    
## namehi 1200d                             0.929035    
## namehonda accord                         0.472963    
## namehonda accord cvcc                    0.446553    
## namehonda accord lx                      0.903286    
## namehonda civic                          0.574899    
## namehonda civic (auto)                   0.955769    
## namehonda civic 1300                     0.714099    
## namehonda civic 1500 gl                  0.039115 *  
## namehonda civic cvcc                     0.408936    
## namehonda prelude                        0.621700    
## namemaxda glc deluxe                     0.632921    
## namemaxda rx3                            0.165257    
## namemazda 626                            0.511828    
## namemazda glc                            0.006559 ** 
## namemazda glc 4                          0.640671    
## namemazda glc custom                     0.983168    
## namemazda glc custom l                   0.275615    
## namemazda glc deluxe                     0.670672    
## namemazda rx-4                           0.430845    
## namemazda rx-7 gs                        0.273587    
## namemazda rx2 coupe                      0.332226    
## namemercedes-benz 240d                   0.176756    
## namemercedes-benz 280s                   0.500505    
## namemercedes benz 300d                   0.437467    
## namemercury capri 2000                   0.710142    
## namemercury capri v6                     0.867456    
## namemercury cougar brougham              0.912001    
## namemercury grand marquis                0.792322    
## namemercury lynx l                       0.315282    
## namemercury marquis                      0.908034    
## namemercury marquis brougham             0.733746    
## namemercury monarch                      0.348526    
## namemercury monarch ghia                 0.336253    
## namemercury zephyr                       0.458532    
## namemercury zephyr 6                     0.353466    
## namenissan stanza xe                     0.260820    
## nameoldsmobile cutlass ciera (diesel)    5.83e-05 ***
## nameoldsmobile cutlass ls                0.001404 ** 
## nameoldsmobile cutlass salon brougham    0.142663    
## nameoldsmobile cutlass supreme           0.642100    
## nameoldsmobile delta 88 royale           0.675905    
## nameoldsmobile omega                     0.397443    
## nameoldsmobile omega brougham            0.543117    
## nameoldsmobile starfire sx               0.705194    
## nameoldsmobile vista cruiser             0.915638    
## nameopel 1900                            0.469429    
## nameopel manta                           0.629944    
## namepeugeot 304                          0.054387 .  
## namepeugeot 504                          0.572222    
## namepeugeot 504 (sw)                     0.832802    
## namepeugeot 505s turbo diesel            0.400236    
## namepeugeot 604sl                        0.240228    
## nameplymouth 'cuda 340                   0.942419    
## nameplymouth arrow gs                    0.898554    
## nameplymouth champ                       0.169476    
## nameplymouth cricket                     0.488283    
## nameplymouth custom suburb               0.603827    
## nameplymouth duster                      0.388389    
## nameplymouth fury                        0.909680    
## nameplymouth fury gran sedan             0.510089    
## nameplymouth fury iii                    0.357086    
## nameplymouth grand fury                  0.372526    
## nameplymouth horizon                     0.711711    
## nameplymouth horizon 4                   0.833732    
## nameplymouth horizon miser               0.405985    
## nameplymouth horizon tc3                 0.455604    
## nameplymouth reliant                     0.664636    
## nameplymouth sapporo                     0.926786    
## nameplymouth satellite                   0.086021 .  
## nameplymouth satellite custom            0.847676    
## nameplymouth satellite custom (sw)       0.456748    
## nameplymouth satellite sebring           0.945800    
## nameplymouth valiant                     0.676074    
## nameplymouth valiant custom              0.809994    
## nameplymouth volare                      0.948097    
## nameplymouth volare custom               0.932754    
## nameplymouth volare premier v8           0.565938    
## namepontiac astro                        0.768998    
## namepontiac catalina                     0.191767    
## namepontiac catalina brougham            0.178248    
## namepontiac firebird                     0.461260    
## namepontiac grand prix                   0.919060    
## namepontiac grand prix lj                0.510450    
## namepontiac j2000 se hatchback           0.828328    
## namepontiac lemans v6                    0.802025    
## namepontiac phoenix                      0.433703    
## namepontiac phoenix lj                   0.759467    
## namepontiac safari (sw)                  0.282930    
## namepontiac sunbird coupe                0.821382    
## namepontiac ventura sj                   0.841873    
## namerenault 12 (sw)                      0.703331    
## namerenault 12tl                         0.996669    
## namerenault 5 gtl                        0.052604 .  
## namesaab 99e                             0.156005    
## namesaab 99gle                           0.481794    
## namesaab 99le                            0.604356    
## namesubaru                               0.675330    
## namesubaru dl                            0.602014    
## nametoyota carina                        0.827920    
## nametoyota celica gt                     0.482623    
## nametoyota celica gt liftback            0.512676    
## nametoyota corolla                       0.632547    
## nametoyota corolla 1200                  0.246758    
## nametoyota corolla 1600 (sw)             0.465513    
## nametoyota corolla liftback              0.992528    
## nametoyota corolla tercel                0.185794    
## nametoyota corona                        0.798299    
## nametoyota corona hardtop                0.717834    
## nametoyota corona liftback               0.577413    
## nametoyota corona mark ii                0.611621    
## nametoyota cressida                      0.906594    
## nametoyota mark ii                       0.952347    
## nametoyota starlet                       0.285746    
## nametoyota tercel                        0.292289    
## nametoyouta corona mark ii (sw)          0.861593    
## nametriumph tr7 coupe                    0.028907 *  
## namevokswagen rabbit                     0.288522    
## namevolkswagen 1131 deluxe sedan         0.935630    
## namevolkswagen 411 (sw)                  0.809978    
## namevolkswagen dasher                    0.589275    
## namevolkswagen jetta                     0.720280    
## namevolkswagen model 111                 0.522494    
## namevolkswagen rabbit                    0.702606    
## namevolkswagen rabbit custom             0.989906    
## namevolkswagen rabbit custom diesel      8.82e-05 ***
## namevolkswagen rabbit l                  0.174824    
## namevolkswagen scirocco                  0.777779    
## namevolkswagen super beetle              0.711857    
## namevolkswagen type 3                    0.911361    
## namevolvo 144ea                          0.518419    
## namevolvo 145e (sw)                      0.342385    
## namevolvo 244dl                          0.476820    
## namevolvo 245                            0.316159    
## namevolvo 264gl                          0.112093    
## namevolvo diesel                         0.144527    
## namevw dasher (diesel)                   7.76e-05 ***
## namevw pickup                            3.06e-05 ***
## namevw rabbit                            0.070626 .  
## namevw rabbit c (diesel)                 7.86e-05 ***
## namevw rabbit custom                           NA    
## I(horsepower^2)                          0.000444 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.123 on 84 degrees of freedom
## Multiple R-squared:  0.9841, Adjusted R-squared:  0.926 
## F-statistic: 16.95 on 307 and 84 DF,  p-value: < 2.2e-16

Exercise 10

fit_1 <- lm(Sales ~ Price + Urban + US, data = Carseats)
summary(fit_1)
## 
## Call:
## lm(formula = Sales ~ Price + Urban + US, data = Carseats)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.9206 -1.6220 -0.0564  1.5786  7.0581 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 13.043469   0.651012  20.036  < 2e-16 ***
## Price       -0.054459   0.005242 -10.389  < 2e-16 ***
## UrbanYes    -0.021916   0.271650  -0.081    0.936    
## USYes        1.200573   0.259042   4.635 4.86e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.472 on 396 degrees of freedom
## Multiple R-squared:  0.2393, Adjusted R-squared:  0.2335 
## F-statistic: 41.52 on 3 and 396 DF,  p-value: < 2.2e-16
fit_2 <- update(fit, . ~ . - Urban)

confint(fit_2, level = 0.95)
##                                                  2.5 %       97.5 %
## (Intercept)                              -2.521072e+01 25.585326295
## cylinders                                -2.144167e+00  0.307974681
## displacement                             -2.801806e-02  0.034100283
## horsepower                               -1.001407e-01  0.015456257
## weight                                   -6.597404e-03 -0.001787893
## acceleration                             -8.225110e-01 -0.140386794
## year                                      4.134250e-01  0.859570558
## origin                                   -7.112396e+00  9.760923634
## nameamc ambassador dpl                   -3.081785e+00  9.824501176
## nameamc ambassador sst                   -3.139209e+00  9.867737277
## nameamc concord                          -6.634193e+00  6.389192526
## nameamc concord d/l                      -8.492300e+00  5.119203547
## nameamc concord dl 6                     -7.517358e+00  6.457985133
## nameamc gremlin                          -6.308484e+00  5.455272834
## nameamc hornet                           -5.502859e+00  6.040911506
## nameamc hornet sportabout (sw)           -7.415954e+00  6.609731801
## nameamc matador                          -4.841939e+00  5.766405532
## nameamc matador (sw)                     -2.635436e+00  8.873294610
## nameamc pacer                            -6.985350e+00  7.009676134
## nameamc pacer d/l                        -8.675046e+00  5.311043346
## nameamc rebel sst                        -3.653805e+00  9.405687083
## nameamc spirit dl                        -7.366251e+00  8.792251369
## nameaudi 100 ls                          -5.921428e+00  7.793936489
## nameaudi 100ls                           -9.067884e+00  2.800988068
## nameaudi 4000                            -2.445480e+00 10.455167332
## nameaudi 5000                            -1.097031e+01  2.752149766
## nameaudi 5000s (diesel)                   4.705410e+00 18.600443234
## nameaudi fox                             -3.419397e+00  9.818370072
## namebmw 2002                             -4.736473e+00  8.902259276
## namebmw 320i                             -1.203738e+01  1.396027789
## namebuick century                        -3.898273e+00  8.324823749
## namebuick century 350                    -4.300622e+00  8.626737400
## namebuick century limited                -6.108928e+00  8.417940240
## namebuick century luxus (sw)             -3.053375e+00 10.456523165
## namebuick century special                -6.423896e+00  7.367222542
## namebuick electra 225 custom             -1.356447e+00 12.488244600
## namebuick estate wagon (sw)              -3.444321e+00  8.021043328
## namebuick lesabre custom                 -2.783147e+00 10.540907491
## namebuick opel isuzu deluxe              -5.772272e+00 10.494078009
## namebuick regal sport coupe (turbo)      -8.074107e+00  6.532589668
## namebuick skyhawk                        -5.689012e+00  8.045042688
## namebuick skylark                        -6.060688e+00  7.032538202
## namebuick skylark 320                    -3.220933e+00  9.662027914
## namebuick skylark limited                -5.317780e+00 10.371055813
## namecadillac eldorado                     6.779078e-01 14.335702492
## namecadillac seville                     -1.870291e+00 11.282117623
## namecapri ii                             -7.688046e+00  8.115635188
## namechevroelt chevelle malibu            -5.771806e+00  8.153579019
## namechevrolet bel air                    -3.100145e+00 10.153634134
## namechevrolet camaro                     -6.866618e+00  8.900558131
## namechevrolet caprice classic            -3.893422e+00  6.865804684
## namechevrolet cavalier                   -6.365561e+00  9.789075341
## namechevrolet cavalier 2-door            -2.061106e+00 14.183072046
## namechevrolet cavalier wagon             -7.705490e+00  8.459592377
## namechevrolet chevelle concours (sw)     -5.188990e+00  8.184963317
## namechevrolet chevelle malibu            -3.480260e+00  8.497306938
## namechevrolet chevelle malibu classic    -3.763584e+00  8.061327286
## namechevrolet chevette                   -4.328171e+00  9.921347513
## namechevrolet citation                   -5.680714e+00  7.350763122
## namechevrolet concours                   -7.794554e+00  5.870415611
## namechevrolet impala                     -1.376876e+00  9.180825543
## namechevrolet malibu                     -5.444528e+00  6.122389074
## namechevrolet malibu classic (sw)        -5.131567e+00  8.265384910
## namechevrolet monte carlo                -5.224618e+00  8.735739546
## namechevrolet monte carlo landau         -4.266565e+00  6.987528811
## namechevrolet monte carlo s              -3.733137e+00  9.367783262
## namechevrolet monza 2+2                  -4.836733e+00  8.758376218
## namechevrolet nova                       -5.816638e+00  5.843371695
## namechevrolet nova custom                -7.509304e+00  6.341698321
## namechevrolet vega                       -6.986098e+00  6.738479835
## namechevrolet vega (sw)                  -7.032604e+00  8.704173542
## namechevrolet vega 2300                  -2.600958e+00 13.219223225
## namechevrolet woody                      -7.780263e+00  8.265065859
## namechevy c10                            -8.232607e+00  4.858965931
## namechevy c20                            -3.085957e+00 11.849843722
## namechevy s-10                           -3.162665e+00 12.807227137
## namechrysler cordoba                     -3.380992e+00  9.697654329
## namechrysler lebaron medallion           -1.082404e+01  5.240189288
## namechrysler lebaron salon               -1.164846e+01  2.598671500
## namechrysler lebaron town @ country (sw) -4.481761e+00  8.650322406
## namechrysler new yorker brougham         -1.458391e+00 12.023353100
## namechrysler newport royal               -2.152870e+00 10.936753071
## namedatsun 1200                          -5.370027e+00 20.274870868
## namedatsun 200-sx                        -1.800500e+01  7.540352585
## namedatsun 200sx                         -9.989239e+00 15.624276258
## namedatsun 210                           -6.713040e+00 17.925246331
## namedatsun 210 mpg                       -7.634819e+00 17.775434890
## namedatsun 280-zx                        -7.684983e+00 19.477083834
## namedatsun 310                           -7.837928e+00 17.125717684
## namedatsun 310 gx                        -8.415049e+00 16.501978508
## namedatsun 510                           -1.519414e+01 10.256448015
## namedatsun 510 (sw)                      -9.975868e+00 16.100581329
## namedatsun 510 hatchback                 -6.163162e+00 19.268559879
## namedatsun 610                           -1.639661e+01  9.632407602
## namedatsun 710                           -1.120852e+01 13.871020696
## namedatsun 810                           -1.676902e+01 10.338340875
## namedatsun 810 maxima                    -1.608340e+01 11.198763579
## namedatsun b-210                         -1.026822e+01 15.012056131
## namedatsun b210                          -9.517753e+00 16.180408420
## namedatsun b210 gx                       -3.129314e+00 22.338624545
## namedatsun f-10 hatchback                -9.633384e+00 15.534311920
## namedatsun pl510                         -1.145343e+01 13.416778538
## namedodge aries se                       -7.632117e+00  8.439747070
## namedodge aries wagon (sw)               -1.024946e+01  5.735805772
## namedodge aspen                          -6.347337e+00  5.933570330
## namedodge aspen 6                        -6.523407e+00  7.256265536
## namedodge aspen se                       -3.944112e+00  9.948420963
## namedodge challenger se                  -4.477932e+00  8.607300956
## namedodge charger 2.2                    -2.974878e+00 13.594094416
## namedodge colt                           -5.644263e+00  8.609055128
## namedodge colt (sw)                      -4.461930e+00 11.895829765
## namedodge colt hardtop                   -6.566200e+00  9.610295327
## namedodge colt hatchback custom          -2.716594e+00 13.973847481
## namedodge colt m/m                       -1.941928e+00 14.385220136
## namedodge coronet brougham               -3.871843e+00  9.211167938
## namedodge coronet custom                 -4.849102e+00  8.062837656
## namedodge coronet custom (sw)            -3.386832e+00  9.992471244
## namedodge d100                           -8.144151e+00  4.798770156
## namedodge d200                           -2.374072e+00 12.523863337
## namedodge dart custom                    -7.192013e+00  5.791759393
## namedodge diplomat                       -3.965302e+00  9.089060949
## namedodge magnum xe                      -4.199335e+00  8.897470737
## namedodge monaco (sw)                    -1.500851e+00 12.320748922
## namedodge monaco brougham                -5.085928e+00  7.983599375
## namedodge omni                           -5.608579e+00 10.810489117
## namedodge rampage                        -8.118147e+00  8.760409452
## namedodge st. regis                      -4.706579e+00  8.456318786
## namefiat 124 sport coupe                 -5.830282e+00  7.517867709
## namefiat 124 tc                          -7.843932e+00  5.275107262
## namefiat 124b                            -2.427707e+00 10.896566376
## namefiat 128                             -6.091229e+00  5.485589132
## namefiat 131                             -5.015645e+00  8.159439567
## namefiat strada custom                    1.003326e-01 12.911148312
## namefiat x1.9                            -3.113599e+00  9.955353727
## nameford country                         -3.044694e+00 10.666322951
## nameford country squire (sw)             -3.160462e+00  8.336508645
## nameford escort 2h                       -5.155085e+00 10.961500089
## nameford escort 4w                       -4.463770e+00 12.128070381
## nameford f108                            -8.070334e+00  5.055786154
## nameford f250                            -1.879365e+00 12.632349008
## nameford fairmont                        -6.149283e+00  9.526243360
## nameford fairmont (auto)                 -9.533072e+00  4.691359229
## nameford fairmont (man)                  -8.179328e+00  7.644661005
## nameford fairmont 4                      -9.921560e+00  5.768903670
## nameford fairmont futura                 -1.063379e+01  5.324642728
## nameford fiesta                          -2.816041e+00 13.996398603
## nameford futura                          -8.601874e+00  4.768261485
## nameford galaxie 500                     -9.193453e-01  9.804304622
## nameford gran torino                     -3.007353e+00  7.797650601
## nameford gran torino (sw)                -1.723904e+00 10.335722121
## nameford granada                         -6.109489e+00  7.714598477
## nameford granada ghia                    -5.931327e+00  8.452417122
## nameford granada gl                      -1.028317e+01  3.924896634
## nameford granada l                       -1.032546e+01  3.934341321
## nameford ltd                             -2.876614e+00  8.739290260
## nameford ltd landau                      -6.851726e+00  6.377002480
## nameford maverick                        -5.773989e+00  6.181042823
## nameford mustang                         -7.390243e+00  7.216715879
## nameford mustang gl                      -8.629805e+00  7.413337860
## nameford mustang ii                      -1.198609e+01  1.393068671
## nameford mustang ii 2+2                  -6.722851e+00  9.024509002
## nameford pinto                           -7.338556e+00  5.788315227
## nameford pinto (sw)                      -8.608711e+00  7.304645861
## nameford pinto runabout                  -1.006502e+01  5.825285933
## nameford ranger                          -7.081898e+00  8.899403193
## nameford thunderbird                     -3.335651e+00  9.776798162
## nameford torino                          -3.824668e+00  9.431688308
## nameford torino 500                      -5.171912e+00  9.328086520
## namehi 1200d                             -1.649951e+00 14.194600366
## namehonda accord                         -1.021341e+01 14.110453643
## namehonda accord cvcc                    -1.071976e+01 14.847704309
## namehonda accord lx                      -1.373132e+01 11.511444331
## namehonda civic                          -1.098755e+01 13.094058929
## namehonda civic (auto)                   -1.474315e+01 10.097071585
## namehonda civic 1300                     -1.189602e+01 12.857145773
## namehonda civic 1500 gl                  -2.166950e+00 22.473047434
## namehonda civic cvcc                     -8.992491e+00 15.357786002
## namehonda prelude                        -1.178255e+01 13.192260907
## namemaxda glc deluxe                     -1.099810e+01 13.834453687
## namemaxda rx3                            -2.332811e+01  1.593154361
## namemazda 626                            -1.050645e+01 14.475224163
## namemazda glc                             2.533511e+00 27.761686682
## namemazda glc 4                          -1.177474e+01 13.142920772
## namemazda glc custom                     -1.491154e+01 10.221578588
## namemazda glc custom l                   -8.450226e+00 16.799194399
## namemazda glc deluxe                     -1.040542e+01 14.990554037
## namemazda rx-4                           -1.941555e+01  6.219116353
## namemazda rx-7 gs                        -2.086877e+01  3.988841855
## namemazda rx2 coupe                      -2.073196e+01  4.590163633
## namemercedes-benz 240d                   -7.835999e-01 13.646300552
## namemercedes-benz 280s                   -8.470087e+00  7.320462044
## namemercedes benz 300d                   -3.332137e+00 11.436784991
## namemercury capri 2000                   -8.812814e+00  7.388521431
## namemercury capri v6                     -7.642747e+00  7.035603007
## namemercury cougar brougham              -5.094385e+00  8.274302566
## namemercury grand marquis                -6.873785e+00  6.399232094
## namemercury lynx l                       -2.374045e+00 14.118783727
## namemercury marquis                      -3.434218e+00  9.890988048
## namemercury marquis brougham             -2.061125e+00 11.554413990
## namemercury monarch                      -9.263086e+00  5.358353046
## namemercury monarch ghia                 -4.074028e+00  9.041684960
## namemercury zephyr                       -8.014176e+00  6.119528022
## namemercury zephyr 6                     -9.261526e+00  4.867405606
## namenissan stanza xe                     -9.850484e+00 15.286050528
## nameoldsmobile cutlass ciera (diesel)     6.064185e+00 20.799764713
## nameoldsmobile cutlass ls                 1.743041e+00 16.304098361
## nameoldsmobile cutlass salon brougham    -1.642455e+00 10.663515001
## nameoldsmobile cutlass supreme           -3.037417e+00 10.756435461
## nameoldsmobile delta 88 royale           -3.718198e+00  9.513656942
## nameoldsmobile omega                     -8.831726e+00  3.999478766
## nameoldsmobile omega brougham            -4.944909e+00  9.720448050
## nameoldsmobile starfire sx               -7.867302e+00  7.662068114
## nameoldsmobile vista cruiser             -3.838790e+00  9.452612744
## nameopel 1900                            -5.379838e+00  6.108195120
## nameopel manta                           -7.202888e+00  4.275717433
## namepeugeot 304                          -4.662480e-01 13.371696672
## namepeugeot 504                          -3.749583e+00  8.261868839
## namepeugeot 504 (sw)                     -6.063030e+00  8.474441836
## namepeugeot 505s turbo diesel            -3.392699e+00 10.797949969
## namepeugeot 604sl                        -1.143079e+01  3.961899440
## nameplymouth 'cuda 340                   -6.583497e+00  6.587485075
## nameplymouth arrow gs                    -8.559496e+00  7.459245264
## nameplymouth champ                       -5.916485e-01 16.211330240
## nameplymouth cricket                     -4.407945e+00 11.853982242
## nameplymouth custom suburb               -2.429884e+00 10.917208952
## nameplymouth duster                      -2.890989e+00  9.091314009
## nameplymouth fury                        -4.418109e+00  9.647388215
## nameplymouth fury gran sedan             -3.095845e+00 10.092612557
## nameplymouth fury iii                    -1.028966e+00  9.628090681
## nameplymouth grand fury                  -1.380452e+00 12.019790654
## nameplymouth horizon                     -4.077935e+00 12.680100850
## nameplymouth horizon 4                   -4.216829e+00 12.442917971
## nameplymouth horizon miser               -2.104081e+00 14.709918929
## nameplymouth horizon tc3                 -3.028929e+00 13.448756730
## nameplymouth reliant                     -8.010794e+00  6.920780046
## nameplymouth sapporo                     -8.542421e+00  7.011473598
## nameplymouth satellite                   -2.161798e+00 10.890787357
## nameplymouth satellite custom            -6.563692e+00  7.460342792
## nameplymouth satellite custom (sw)       -3.323449e+00  9.770115298
## nameplymouth satellite sebring           -5.205111e+00  8.704715034
## nameplymouth valiant                     -4.877955e+00  7.343766535
## nameplymouth valiant custom              -6.979486e+00  6.951332677
## nameplymouth volare                      -5.845819e+00  7.969537486
## nameplymouth volare custom               -5.657543e+00  8.212765128
## nameplymouth volare premier v8           -7.755572e+00  5.191152900
## namepontiac astro                        -7.699309e+00  7.848449794
## namepontiac catalina                      3.251251e-04 10.889749806
## namepontiac catalina brougham            -1.526419e+00 11.702315704
## namepontiac firebird                     -4.796293e+00  9.319525671
## namepontiac grand prix                   -4.148548e-01 13.216945054
## namepontiac grand prix lj                -4.245968e+00  8.776142946
## namepontiac j2000 se hatchback           -5.328750e+00 10.972800631
## namepontiac lemans v6                    -6.483052e+00  7.283053474
## namepontiac phoenix                      -4.114430e+00 10.367614263
## namepontiac phoenix lj                   -5.532882e+00  8.249781191
## namepontiac safari (sw)                   9.363397e-02 14.232172375
## namepontiac sunbird coupe                -7.706423e+00  7.923291846
## namepontiac ventura sj                   -5.758675e+00  7.963115337
## namerenault 12 (sw)                      -5.268975e+00  8.233308995
## namerenault 12tl                         -7.226178e+00  5.762885375
## namerenault 5 gtl                         9.069678e-02 13.206018498
## namesaab 99e                             -3.650224e+00 10.391902636
## namesaab 99gle                           -1.042413e+01  3.560741274
## namesaab 99le                            -5.663990e+00  6.517329411
## namesubaru                               -1.254750e+01 12.080938957
## namesubaru dl                            -1.129244e+01 13.148229252
## nametoyota carina                        -1.796766e+01  8.330965982
## nametoyota celica gt                     -1.198473e+01 13.608633282
## nametoyota celica gt liftback            -2.058375e+01  5.084590650
## nametoyota corolla                       -1.147422e+01 12.479587810
## nametoyota corolla 1200                  -7.956873e+00 17.151147347
## nametoyota corolla 1600 (sw)             -1.204198e+01 13.770070279
## nametoyota corolla liftback              -1.519351e+01 10.476227385
## nametoyota corolla tercel                -6.395331e+00 18.924756223
## nametoyota corona                        -1.334929e+01 10.915113860
## nametoyota corona hardtop                -1.458144e+01 11.334691083
## nametoyota corona liftback               -1.226086e+01 13.509834326
## nametoyota corona mark ii                -1.325476e+01 12.860772986
## nametoyota cressida                      -1.569225e+01 11.328023931
## nametoyota mark ii                       -1.657789e+01 10.241808625
## nametoyota starlet                       -7.653819e+00 17.186127380
## nametoyota tercel                        -7.603241e+00 17.472287386
## nametoyouta corona mark ii (sw)          -1.508962e+01 10.918618345
## nametriumph tr7 coupe                    -4.968459e-01 12.543505979
## namevokswagen rabbit                     -9.242237e+00  3.588024661
## namevolkswagen 1131 deluxe sedan         -5.616750e+00  8.612099062
## namevolkswagen 411 (sw)                  -7.813300e+00  5.918435048
## namevolkswagen dasher                    -6.193285e+00  4.476795091
## namevolkswagen jetta                     -5.306004e+00  7.531434077
## namevolkswagen model 111                 -5.131819e+00  8.587022609
## namevolkswagen rabbit                    -6.670773e+00  4.520983737
## namevolkswagen rabbit custom             -7.463379e+00  5.360731653
## namevolkswagen rabbit custom diesel       7.943695e+00 21.500326875
## namevolkswagen rabbit l                  -3.325831e+00  9.576541096
## namevolkswagen scirocco                  -5.458894e+00  7.343541736
## namevolkswagen super beetle              -6.645816e+00  7.267936982
## namevolkswagen type 3                    -6.491839e+00  8.020805436
## namevolvo 144ea                          -9.884725e+00  4.351811434
## namevolvo 145e (sw)                      -1.051493e+01  3.837155715
## namevolvo 244dl                          -8.706730e+00  5.125012984
## namevolvo 245                            -9.914119e+00  4.217867312
## namevolvo 264gl                          -1.267928e+01  1.750515564
## namevolvo diesel                          7.873274e-03 14.549406608
## namevw dasher (diesel)                    9.309088e+00 23.242171238
## namevw pickup                             8.194527e+00 22.454525802
## namevw rabbit                            -7.890473e-01 10.302806384
## namevw rabbit c (diesel)                  8.404969e+00 21.924170725
## namevw rabbit custom                                NA           NA

Exercise 10

fit_1 <- lm(Sales ~ Price + Urban + US, data = Carseats)
summary(fit_1)
## 
## Call:
## lm(formula = Sales ~ Price + Urban + US, data = Carseats)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.9206 -1.6220 -0.0564  1.5786  7.0581 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 13.043469   0.651012  20.036  < 2e-16 ***
## Price       -0.054459   0.005242 -10.389  < 2e-16 ***
## UrbanYes    -0.021916   0.271650  -0.081    0.936    
## USYes        1.200573   0.259042   4.635 4.86e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.472 on 396 degrees of freedom
## Multiple R-squared:  0.2393, Adjusted R-squared:  0.2335 
## F-statistic: 41.52 on 3 and 396 DF,  p-value: < 2.2e-16
fit_2 <- update(fit, . ~ . - Urban)

confint(fit_2, level = 0.95)
##                                                  2.5 %       97.5 %
## (Intercept)                              -2.521072e+01 25.585326295
## cylinders                                -2.144167e+00  0.307974681
## displacement                             -2.801806e-02  0.034100283
## horsepower                               -1.001407e-01  0.015456257
## weight                                   -6.597404e-03 -0.001787893
## acceleration                             -8.225110e-01 -0.140386794
## year                                      4.134250e-01  0.859570558
## origin                                   -7.112396e+00  9.760923634
## nameamc ambassador dpl                   -3.081785e+00  9.824501176
## nameamc ambassador sst                   -3.139209e+00  9.867737277
## nameamc concord                          -6.634193e+00  6.389192526
## nameamc concord d/l                      -8.492300e+00  5.119203547
## nameamc concord dl 6                     -7.517358e+00  6.457985133
## nameamc gremlin                          -6.308484e+00  5.455272834
## nameamc hornet                           -5.502859e+00  6.040911506
## nameamc hornet sportabout (sw)           -7.415954e+00  6.609731801
## nameamc matador                          -4.841939e+00  5.766405532
## nameamc matador (sw)                     -2.635436e+00  8.873294610
## nameamc pacer                            -6.985350e+00  7.009676134
## nameamc pacer d/l                        -8.675046e+00  5.311043346
## nameamc rebel sst                        -3.653805e+00  9.405687083
## nameamc spirit dl                        -7.366251e+00  8.792251369
## nameaudi 100 ls                          -5.921428e+00  7.793936489
## nameaudi 100ls                           -9.067884e+00  2.800988068
## nameaudi 4000                            -2.445480e+00 10.455167332
## nameaudi 5000                            -1.097031e+01  2.752149766
## nameaudi 5000s (diesel)                   4.705410e+00 18.600443234
## nameaudi fox                             -3.419397e+00  9.818370072
## namebmw 2002                             -4.736473e+00  8.902259276
## namebmw 320i                             -1.203738e+01  1.396027789
## namebuick century                        -3.898273e+00  8.324823749
## namebuick century 350                    -4.300622e+00  8.626737400
## namebuick century limited                -6.108928e+00  8.417940240
## namebuick century luxus (sw)             -3.053375e+00 10.456523165
## namebuick century special                -6.423896e+00  7.367222542
## namebuick electra 225 custom             -1.356447e+00 12.488244600
## namebuick estate wagon (sw)              -3.444321e+00  8.021043328
## namebuick lesabre custom                 -2.783147e+00 10.540907491
## namebuick opel isuzu deluxe              -5.772272e+00 10.494078009
## namebuick regal sport coupe (turbo)      -8.074107e+00  6.532589668
## namebuick skyhawk                        -5.689012e+00  8.045042688
## namebuick skylark                        -6.060688e+00  7.032538202
## namebuick skylark 320                    -3.220933e+00  9.662027914
## namebuick skylark limited                -5.317780e+00 10.371055813
## namecadillac eldorado                     6.779078e-01 14.335702492
## namecadillac seville                     -1.870291e+00 11.282117623
## namecapri ii                             -7.688046e+00  8.115635188
## namechevroelt chevelle malibu            -5.771806e+00  8.153579019
## namechevrolet bel air                    -3.100145e+00 10.153634134
## namechevrolet camaro                     -6.866618e+00  8.900558131
## namechevrolet caprice classic            -3.893422e+00  6.865804684
## namechevrolet cavalier                   -6.365561e+00  9.789075341
## namechevrolet cavalier 2-door            -2.061106e+00 14.183072046
## namechevrolet cavalier wagon             -7.705490e+00  8.459592377
## namechevrolet chevelle concours (sw)     -5.188990e+00  8.184963317
## namechevrolet chevelle malibu            -3.480260e+00  8.497306938
## namechevrolet chevelle malibu classic    -3.763584e+00  8.061327286
## namechevrolet chevette                   -4.328171e+00  9.921347513
## namechevrolet citation                   -5.680714e+00  7.350763122
## namechevrolet concours                   -7.794554e+00  5.870415611
## namechevrolet impala                     -1.376876e+00  9.180825543
## namechevrolet malibu                     -5.444528e+00  6.122389074
## namechevrolet malibu classic (sw)        -5.131567e+00  8.265384910
## namechevrolet monte carlo                -5.224618e+00  8.735739546
## namechevrolet monte carlo landau         -4.266565e+00  6.987528811
## namechevrolet monte carlo s              -3.733137e+00  9.367783262
## namechevrolet monza 2+2                  -4.836733e+00  8.758376218
## namechevrolet nova                       -5.816638e+00  5.843371695
## namechevrolet nova custom                -7.509304e+00  6.341698321
## namechevrolet vega                       -6.986098e+00  6.738479835
## namechevrolet vega (sw)                  -7.032604e+00  8.704173542
## namechevrolet vega 2300                  -2.600958e+00 13.219223225
## namechevrolet woody                      -7.780263e+00  8.265065859
## namechevy c10                            -8.232607e+00  4.858965931
## namechevy c20                            -3.085957e+00 11.849843722
## namechevy s-10                           -3.162665e+00 12.807227137
## namechrysler cordoba                     -3.380992e+00  9.697654329
## namechrysler lebaron medallion           -1.082404e+01  5.240189288
## namechrysler lebaron salon               -1.164846e+01  2.598671500
## namechrysler lebaron town @ country (sw) -4.481761e+00  8.650322406
## namechrysler new yorker brougham         -1.458391e+00 12.023353100
## namechrysler newport royal               -2.152870e+00 10.936753071
## namedatsun 1200                          -5.370027e+00 20.274870868
## namedatsun 200-sx                        -1.800500e+01  7.540352585
## namedatsun 200sx                         -9.989239e+00 15.624276258
## namedatsun 210                           -6.713040e+00 17.925246331
## namedatsun 210 mpg                       -7.634819e+00 17.775434890
## namedatsun 280-zx                        -7.684983e+00 19.477083834
## namedatsun 310                           -7.837928e+00 17.125717684
## namedatsun 310 gx                        -8.415049e+00 16.501978508
## namedatsun 510                           -1.519414e+01 10.256448015
## namedatsun 510 (sw)                      -9.975868e+00 16.100581329
## namedatsun 510 hatchback                 -6.163162e+00 19.268559879
## namedatsun 610                           -1.639661e+01  9.632407602
## namedatsun 710                           -1.120852e+01 13.871020696
## namedatsun 810                           -1.676902e+01 10.338340875
## namedatsun 810 maxima                    -1.608340e+01 11.198763579
## namedatsun b-210                         -1.026822e+01 15.012056131
## namedatsun b210                          -9.517753e+00 16.180408420
## namedatsun b210 gx                       -3.129314e+00 22.338624545
## namedatsun f-10 hatchback                -9.633384e+00 15.534311920
## namedatsun pl510                         -1.145343e+01 13.416778538
## namedodge aries se                       -7.632117e+00  8.439747070
## namedodge aries wagon (sw)               -1.024946e+01  5.735805772
## namedodge aspen                          -6.347337e+00  5.933570330
## namedodge aspen 6                        -6.523407e+00  7.256265536
## namedodge aspen se                       -3.944112e+00  9.948420963
## namedodge challenger se                  -4.477932e+00  8.607300956
## namedodge charger 2.2                    -2.974878e+00 13.594094416
## namedodge colt                           -5.644263e+00  8.609055128
## namedodge colt (sw)                      -4.461930e+00 11.895829765
## namedodge colt hardtop                   -6.566200e+00  9.610295327
## namedodge colt hatchback custom          -2.716594e+00 13.973847481
## namedodge colt m/m                       -1.941928e+00 14.385220136
## namedodge coronet brougham               -3.871843e+00  9.211167938
## namedodge coronet custom                 -4.849102e+00  8.062837656
## namedodge coronet custom (sw)            -3.386832e+00  9.992471244
## namedodge d100                           -8.144151e+00  4.798770156
## namedodge d200                           -2.374072e+00 12.523863337
## namedodge dart custom                    -7.192013e+00  5.791759393
## namedodge diplomat                       -3.965302e+00  9.089060949
## namedodge magnum xe                      -4.199335e+00  8.897470737
## namedodge monaco (sw)                    -1.500851e+00 12.320748922
## namedodge monaco brougham                -5.085928e+00  7.983599375
## namedodge omni                           -5.608579e+00 10.810489117
## namedodge rampage                        -8.118147e+00  8.760409452
## namedodge st. regis                      -4.706579e+00  8.456318786
## namefiat 124 sport coupe                 -5.830282e+00  7.517867709
## namefiat 124 tc                          -7.843932e+00  5.275107262
## namefiat 124b                            -2.427707e+00 10.896566376
## namefiat 128                             -6.091229e+00  5.485589132
## namefiat 131                             -5.015645e+00  8.159439567
## namefiat strada custom                    1.003326e-01 12.911148312
## namefiat x1.9                            -3.113599e+00  9.955353727
## nameford country                         -3.044694e+00 10.666322951
## nameford country squire (sw)             -3.160462e+00  8.336508645
## nameford escort 2h                       -5.155085e+00 10.961500089
## nameford escort 4w                       -4.463770e+00 12.128070381
## nameford f108                            -8.070334e+00  5.055786154
## nameford f250                            -1.879365e+00 12.632349008
## nameford fairmont                        -6.149283e+00  9.526243360
## nameford fairmont (auto)                 -9.533072e+00  4.691359229
## nameford fairmont (man)                  -8.179328e+00  7.644661005
## nameford fairmont 4                      -9.921560e+00  5.768903670
## nameford fairmont futura                 -1.063379e+01  5.324642728
## nameford fiesta                          -2.816041e+00 13.996398603
## nameford futura                          -8.601874e+00  4.768261485
## nameford galaxie 500                     -9.193453e-01  9.804304622
## nameford gran torino                     -3.007353e+00  7.797650601
## nameford gran torino (sw)                -1.723904e+00 10.335722121
## nameford granada                         -6.109489e+00  7.714598477
## nameford granada ghia                    -5.931327e+00  8.452417122
## nameford granada gl                      -1.028317e+01  3.924896634
## nameford granada l                       -1.032546e+01  3.934341321
## nameford ltd                             -2.876614e+00  8.739290260
## nameford ltd landau                      -6.851726e+00  6.377002480
## nameford maverick                        -5.773989e+00  6.181042823
## nameford mustang                         -7.390243e+00  7.216715879
## nameford mustang gl                      -8.629805e+00  7.413337860
## nameford mustang ii                      -1.198609e+01  1.393068671
## nameford mustang ii 2+2                  -6.722851e+00  9.024509002
## nameford pinto                           -7.338556e+00  5.788315227
## nameford pinto (sw)                      -8.608711e+00  7.304645861
## nameford pinto runabout                  -1.006502e+01  5.825285933
## nameford ranger                          -7.081898e+00  8.899403193
## nameford thunderbird                     -3.335651e+00  9.776798162
## nameford torino                          -3.824668e+00  9.431688308
## nameford torino 500                      -5.171912e+00  9.328086520
## namehi 1200d                             -1.649951e+00 14.194600366
## namehonda accord                         -1.021341e+01 14.110453643
## namehonda accord cvcc                    -1.071976e+01 14.847704309
## namehonda accord lx                      -1.373132e+01 11.511444331
## namehonda civic                          -1.098755e+01 13.094058929
## namehonda civic (auto)                   -1.474315e+01 10.097071585
## namehonda civic 1300                     -1.189602e+01 12.857145773
## namehonda civic 1500 gl                  -2.166950e+00 22.473047434
## namehonda civic cvcc                     -8.992491e+00 15.357786002
## namehonda prelude                        -1.178255e+01 13.192260907
## namemaxda glc deluxe                     -1.099810e+01 13.834453687
## namemaxda rx3                            -2.332811e+01  1.593154361
## namemazda 626                            -1.050645e+01 14.475224163
## namemazda glc                             2.533511e+00 27.761686682
## namemazda glc 4                          -1.177474e+01 13.142920772
## namemazda glc custom                     -1.491154e+01 10.221578588
## namemazda glc custom l                   -8.450226e+00 16.799194399
## namemazda glc deluxe                     -1.040542e+01 14.990554037
## namemazda rx-4                           -1.941555e+01  6.219116353
## namemazda rx-7 gs                        -2.086877e+01  3.988841855
## namemazda rx2 coupe                      -2.073196e+01  4.590163633
## namemercedes-benz 240d                   -7.835999e-01 13.646300552
## namemercedes-benz 280s                   -8.470087e+00  7.320462044
## namemercedes benz 300d                   -3.332137e+00 11.436784991
## namemercury capri 2000                   -8.812814e+00  7.388521431
## namemercury capri v6                     -7.642747e+00  7.035603007
## namemercury cougar brougham              -5.094385e+00  8.274302566
## namemercury grand marquis                -6.873785e+00  6.399232094
## namemercury lynx l                       -2.374045e+00 14.118783727
## namemercury marquis                      -3.434218e+00  9.890988048
## namemercury marquis brougham             -2.061125e+00 11.554413990
## namemercury monarch                      -9.263086e+00  5.358353046
## namemercury monarch ghia                 -4.074028e+00  9.041684960
## namemercury zephyr                       -8.014176e+00  6.119528022
## namemercury zephyr 6                     -9.261526e+00  4.867405606
## namenissan stanza xe                     -9.850484e+00 15.286050528
## nameoldsmobile cutlass ciera (diesel)     6.064185e+00 20.799764713
## nameoldsmobile cutlass ls                 1.743041e+00 16.304098361
## nameoldsmobile cutlass salon brougham    -1.642455e+00 10.663515001
## nameoldsmobile cutlass supreme           -3.037417e+00 10.756435461
## nameoldsmobile delta 88 royale           -3.718198e+00  9.513656942
## nameoldsmobile omega                     -8.831726e+00  3.999478766
## nameoldsmobile omega brougham            -4.944909e+00  9.720448050
## nameoldsmobile starfire sx               -7.867302e+00  7.662068114
## nameoldsmobile vista cruiser             -3.838790e+00  9.452612744
## nameopel 1900                            -5.379838e+00  6.108195120
## nameopel manta                           -7.202888e+00  4.275717433
## namepeugeot 304                          -4.662480e-01 13.371696672
## namepeugeot 504                          -3.749583e+00  8.261868839
## namepeugeot 504 (sw)                     -6.063030e+00  8.474441836
## namepeugeot 505s turbo diesel            -3.392699e+00 10.797949969
## namepeugeot 604sl                        -1.143079e+01  3.961899440
## nameplymouth 'cuda 340                   -6.583497e+00  6.587485075
## nameplymouth arrow gs                    -8.559496e+00  7.459245264
## nameplymouth champ                       -5.916485e-01 16.211330240
## nameplymouth cricket                     -4.407945e+00 11.853982242
## nameplymouth custom suburb               -2.429884e+00 10.917208952
## nameplymouth duster                      -2.890989e+00  9.091314009
## nameplymouth fury                        -4.418109e+00  9.647388215
## nameplymouth fury gran sedan             -3.095845e+00 10.092612557
## nameplymouth fury iii                    -1.028966e+00  9.628090681
## nameplymouth grand fury                  -1.380452e+00 12.019790654
## nameplymouth horizon                     -4.077935e+00 12.680100850
## nameplymouth horizon 4                   -4.216829e+00 12.442917971
## nameplymouth horizon miser               -2.104081e+00 14.709918929
## nameplymouth horizon tc3                 -3.028929e+00 13.448756730
## nameplymouth reliant                     -8.010794e+00  6.920780046
## nameplymouth sapporo                     -8.542421e+00  7.011473598
## nameplymouth satellite                   -2.161798e+00 10.890787357
## nameplymouth satellite custom            -6.563692e+00  7.460342792
## nameplymouth satellite custom (sw)       -3.323449e+00  9.770115298
## nameplymouth satellite sebring           -5.205111e+00  8.704715034
## nameplymouth valiant                     -4.877955e+00  7.343766535
## nameplymouth valiant custom              -6.979486e+00  6.951332677
## nameplymouth volare                      -5.845819e+00  7.969537486
## nameplymouth volare custom               -5.657543e+00  8.212765128
## nameplymouth volare premier v8           -7.755572e+00  5.191152900
## namepontiac astro                        -7.699309e+00  7.848449794
## namepontiac catalina                      3.251251e-04 10.889749806
## namepontiac catalina brougham            -1.526419e+00 11.702315704
## namepontiac firebird                     -4.796293e+00  9.319525671
## namepontiac grand prix                   -4.148548e-01 13.216945054
## namepontiac grand prix lj                -4.245968e+00  8.776142946
## namepontiac j2000 se hatchback           -5.328750e+00 10.972800631
## namepontiac lemans v6                    -6.483052e+00  7.283053474
## namepontiac phoenix                      -4.114430e+00 10.367614263
## namepontiac phoenix lj                   -5.532882e+00  8.249781191
## namepontiac safari (sw)                   9.363397e-02 14.232172375
## namepontiac sunbird coupe                -7.706423e+00  7.923291846
## namepontiac ventura sj                   -5.758675e+00  7.963115337
## namerenault 12 (sw)                      -5.268975e+00  8.233308995
## namerenault 12tl                         -7.226178e+00  5.762885375
## namerenault 5 gtl                         9.069678e-02 13.206018498
## namesaab 99e                             -3.650224e+00 10.391902636
## namesaab 99gle                           -1.042413e+01  3.560741274
## namesaab 99le                            -5.663990e+00  6.517329411
## namesubaru                               -1.254750e+01 12.080938957
## namesubaru dl                            -1.129244e+01 13.148229252
## nametoyota carina                        -1.796766e+01  8.330965982
## nametoyota celica gt                     -1.198473e+01 13.608633282
## nametoyota celica gt liftback            -2.058375e+01  5.084590650
## nametoyota corolla                       -1.147422e+01 12.479587810
## nametoyota corolla 1200                  -7.956873e+00 17.151147347
## nametoyota corolla 1600 (sw)             -1.204198e+01 13.770070279
## nametoyota corolla liftback              -1.519351e+01 10.476227385
## nametoyota corolla tercel                -6.395331e+00 18.924756223
## nametoyota corona                        -1.334929e+01 10.915113860
## nametoyota corona hardtop                -1.458144e+01 11.334691083
## nametoyota corona liftback               -1.226086e+01 13.509834326
## nametoyota corona mark ii                -1.325476e+01 12.860772986
## nametoyota cressida                      -1.569225e+01 11.328023931
## nametoyota mark ii                       -1.657789e+01 10.241808625
## nametoyota starlet                       -7.653819e+00 17.186127380
## nametoyota tercel                        -7.603241e+00 17.472287386
## nametoyouta corona mark ii (sw)          -1.508962e+01 10.918618345
## nametriumph tr7 coupe                    -4.968459e-01 12.543505979
## namevokswagen rabbit                     -9.242237e+00  3.588024661
## namevolkswagen 1131 deluxe sedan         -5.616750e+00  8.612099062
## namevolkswagen 411 (sw)                  -7.813300e+00  5.918435048
## namevolkswagen dasher                    -6.193285e+00  4.476795091
## namevolkswagen jetta                     -5.306004e+00  7.531434077
## namevolkswagen model 111                 -5.131819e+00  8.587022609
## namevolkswagen rabbit                    -6.670773e+00  4.520983737
## namevolkswagen rabbit custom             -7.463379e+00  5.360731653
## namevolkswagen rabbit custom diesel       7.943695e+00 21.500326875
## namevolkswagen rabbit l                  -3.325831e+00  9.576541096
## namevolkswagen scirocco                  -5.458894e+00  7.343541736
## namevolkswagen super beetle              -6.645816e+00  7.267936982
## namevolkswagen type 3                    -6.491839e+00  8.020805436
## namevolvo 144ea                          -9.884725e+00  4.351811434
## namevolvo 145e (sw)                      -1.051493e+01  3.837155715
## namevolvo 244dl                          -8.706730e+00  5.125012984
## namevolvo 245                            -9.914119e+00  4.217867312
## namevolvo 264gl                          -1.267928e+01  1.750515564
## namevolvo diesel                          7.873274e-03 14.549406608
## namevw dasher (diesel)                    9.309088e+00 23.242171238
## namevw pickup                             8.194527e+00 22.454525802
## namevw rabbit                            -7.890473e-01 10.302806384
## namevw rabbit c (diesel)                  8.404969e+00 21.924170725
## namevw rabbit custom                                NA           NA

Exercise 11

set.seed(1)
n <- 100
x <- rnorm(n)
y <- 2 * x + rnorm(n)

# Part (a):
fit <- lm(y ~ x + 0)
summary(fit)
## 
## Call:
## lm(formula = y ~ x + 0)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.9154 -0.6472 -0.1771  0.5056  2.3109 
## 
## Coefficients:
##   Estimate Std. Error t value Pr(>|t|)    
## x   1.9939     0.1065   18.73   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9586 on 99 degrees of freedom
## Multiple R-squared:  0.7798, Adjusted R-squared:  0.7776 
## F-statistic: 350.7 on 1 and 99 DF,  p-value: < 2.2e-16
# Part (b):
fit <- lm(x ~ y + 0)
summary(fit)
## 
## Call:
## lm(formula = x ~ y + 0)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.8699 -0.2368  0.1030  0.2858  0.8938 
## 
## Coefficients:
##   Estimate Std. Error t value Pr(>|t|)    
## y  0.39111    0.02089   18.73   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4246 on 99 degrees of freedom
## Multiple R-squared:  0.7798, Adjusted R-squared:  0.7776 
## F-statistic: 350.7 on 1 and 99 DF,  p-value: < 2.2e-16
# Part (f): verify that these two regressions give the same t-statistic
fit_x_to_y <- lm(x ~ y)
summary(fit_x_to_y)
## 
## Call:
## lm(formula = x ~ y)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.90848 -0.28101  0.06274  0.24570  0.85736 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.03880    0.04266    0.91    0.365    
## y            0.38942    0.02099   18.56   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4249 on 98 degrees of freedom
## Multiple R-squared:  0.7784, Adjusted R-squared:  0.7762 
## F-statistic: 344.3 on 1 and 98 DF,  p-value: < 2.2e-16
fit_y_to_x <- lm(y ~ x)
summary(fit_y_to_x)
## 
## Call:
## lm(formula = y ~ x)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.8768 -0.6138 -0.1395  0.5394  2.3462 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.03769    0.09699  -0.389    0.698    
## x            1.99894    0.10773  18.556   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9628 on 98 degrees of freedom
## Multiple R-squared:  0.7784, Adjusted R-squared:  0.7762 
## F-statistic: 344.3 on 1 and 98 DF,  p-value: < 2.2e-16

Exercise 12

set.seed(1)

# Different coefficient estimates in regressions y ~ x and x ~ y:
x <- rnorm(100)
y <- 2 * x + rnorm(100)

coef(lm(y ~ x))
## (Intercept)           x 
## -0.03769261  1.99893961
coef(lm(x ~ y))
## (Intercept)           y 
##  0.03880394  0.38942451
# The same coefficient estimates in regressions y ~ x and x ~ y:
x <- rnorm(100)
y <- x

coef(lm(y ~ x))
##   (Intercept)             x 
## -1.110223e-17  1.000000e+00
coef(lm(x ~ y))
##   (Intercept)             y 
## -1.110223e-17  1.000000e+00

Exercise 13

set.seed(1)

x <- rnorm(100)
eps <- rnorm(100, mean = 0, sd = sqrt(0.25))
y_pure <- -1 + 0.5 * x
y <- y_pure + eps

plot(x, y)

fit <- lm(y ~ x)
summary(fit)
## 
## Call:
## lm(formula = y ~ x)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.93842 -0.30688 -0.06975  0.26970  1.17309 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.01885    0.04849 -21.010  < 2e-16 ***
## x            0.49947    0.05386   9.273 4.58e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4814 on 98 degrees of freedom
## Multiple R-squared:  0.4674, Adjusted R-squared:  0.4619 
## F-statistic: 85.99 on 1 and 98 DF,  p-value: 4.583e-15
abline(fit)
abline(a = -1, b = 1/2, col = "green")
legend(-3, 1, c("estimated", "truth"), col = c("black", "green"), lty = c(1, 1))

# Try to fit a quadradic model:
qfit <- lm(y ~ x + I(x^2))
summary(qfit)
## 
## Call:
## lm(formula = y ~ x + I(x^2))
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.98252 -0.31270 -0.06441  0.29014  1.13500 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.97164    0.05883 -16.517  < 2e-16 ***
## x            0.50858    0.05399   9.420  2.4e-15 ***
## I(x^2)      -0.05946    0.04238  -1.403    0.164    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.479 on 97 degrees of freedom
## Multiple R-squared:  0.4779, Adjusted R-squared:  0.4672 
## F-statistic:  44.4 on 2 and 97 DF,  p-value: 2.038e-14
# Fit different amounts of noise:
confint(fit, level = 0.95)
##                  2.5 %     97.5 %
## (Intercept) -1.1150804 -0.9226122
## x            0.3925794  0.6063602
eps_less <- rnorm(100, mean = 0, sd = sqrt(0.1))
y <- y_pure + eps_less
confint(lm(y ~ x), level = 0.95)
##                  2.5 %     97.5 %
## (Intercept) -1.0570515 -0.9256389
## x            0.4337114  0.5796757
eps_more <- rnorm(100, mean = 0, sd = sqrt(0.5))
y <- y_pure + eps_more
confint(lm(y ~ x), level = 0.95)
##                  2.5 %     97.5 %
## (Intercept) -1.0999424 -0.8185064
## x            0.3043238  0.6169242

Exercise 14

set.seed(1)

x1 <- runif(100)
x2 <- 0.5 * x1 + rnorm(100)/10
y <- 2 + 2 * x1 + 0.3 * x2 + rnorm(100)

# Look at the correlation between x_1 and x_2:
cor(x1, x2)
## [1] 0.8351212
plot(x1, x2)

# dev.off()

summary(lm(y ~ x1 + x2))
## 
## Call:
## lm(formula = y ~ x1 + x2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.8311 -0.7273 -0.0537  0.6338  2.3359 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.1305     0.2319   9.188 7.61e-15 ***
## x1            1.4396     0.7212   1.996   0.0487 *  
## x2            1.0097     1.1337   0.891   0.3754    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.056 on 97 degrees of freedom
## Multiple R-squared:  0.2088, Adjusted R-squared:  0.1925 
## F-statistic:  12.8 on 2 and 97 DF,  p-value: 1.164e-05
summary(lm(y ~ x1))
## 
## Call:
## lm(formula = y ~ x1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.89495 -0.66874 -0.07785  0.59221  2.45560 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.1124     0.2307   9.155 8.27e-15 ***
## x1            1.9759     0.3963   4.986 2.66e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.055 on 98 degrees of freedom
## Multiple R-squared:  0.2024, Adjusted R-squared:  0.1942 
## F-statistic: 24.86 on 1 and 98 DF,  p-value: 2.661e-06
summary(lm(y ~ x2))
## 
## Call:
## lm(formula = y ~ x2)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.62687 -0.75156 -0.03598  0.72383  2.44890 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.3899     0.1949   12.26  < 2e-16 ***
## x2            2.8996     0.6330    4.58 1.37e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.072 on 98 degrees of freedom
## Multiple R-squared:  0.1763, Adjusted R-squared:  0.1679 
## F-statistic: 20.98 on 1 and 98 DF,  p-value: 1.366e-05
x1 <- c(x1, 0.1)
x2 <- c(x2, 0.8)
y <- c(y, 6)

# Consider what each model thinks about the mismeasured point:
plot(lm(y ~ x1 + x2))  # 101 is a high-leverage point in this model

plot(lm(y ~ x1))  # 101 is a outlier and a high-leverage point in this model

plot(lm(y ~ x2))  # 101 is a high-leverage point in this model

Exercise 15

library(MASS)

set.seed(1)

# Loop over each predictor and look for a statistically signficant simple linear regression:
crim <- Boston[, 1]
model_f_value <- c()
model_p_value <- c()
univariate_beta_value <- c()
possible_predictors <- colnames(Boston)
for (pi in 1:length(possible_predictors)) {
    if (possible_predictors[pi] == "crim") {
        next
    }
    x <- Boston[, pi]
    m <- lm(crim ~ x, data = Boston)
    s <- summary(m)
    model_f_value <- c(model_f_value, s$fstatistic[1])
    model_p_value <- c(model_p_value, anova(m)$"Pr(>F)"[1])
    univariate_beta_value <- c(univariate_beta_value, coefficients(m)["x"])
    print(sprintf("%s %10.6f", possible_predictors[pi], coefficients(m)["x"]))
}
## [1] "zn  -0.073935"
## [1] "indus   0.509776"
## [1] "chas  -1.892777"
## [1] "nox  31.248531"
## [1] "rm  -2.684051"
## [1] "age   0.107786"
## [1] "dis  -1.550902"
## [1] "rad   0.617911"
## [1] "tax   0.029742"
## [1] "ptratio   1.151983"
## [1] "black  -0.036280"
## [1] "lstat   0.548805"
## [1] "medv  -0.363160"