This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

# Instalamos y cargamos las librerías necesarias
library(tidyverse)
library(ggplot2)
library(car)


auto_mpg <- read.csv("auto-mpg.csv")

# Examinar la estructura de los datos
str(auto_mpg)
'data.frame':   398 obs. of  9 variables:
 $ mpg         : num  18 15 18 16 17 15 14 14 14 15 ...
 $ cylinders   : int  8 8 8 8 8 8 8 8 8 8 ...
 $ displacement: num  307 350 318 304 302 429 454 440 455 390 ...
 $ horsepower  : chr  "130" "165" "150" "150" ...
 $ weight      : int  3504 3693 3436 3433 3449 4341 4354 4312 4425 3850 ...
 $ acceleration: num  12 11.5 11 12 10.5 10 9 8.5 10 8.5 ...
 $ model.year  : int  70 70 70 70 70 70 70 70 70 70 ...
 $ origin      : int  1 1 1 1 1 1 1 1 1 1 ...
 $ car.name    : chr  "chevrolet chevelle malibu" "buick skylark 320" "plymouth satellite" "amc rebel sst" ...
# Calcular estadísticas descriptivas de las variables mpg, weight y horsepower
summary(auto_mpg$mpg)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   9.00   17.50   23.00   23.51   29.00   46.60 
summary(auto_mpg$weight)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1613    2224    2804    2970    3608    5140 
summary(auto_mpg$horsepower)
   Length     Class      Mode 
      398 character character 
# Ajuste del modelo de regresión lineal simple
modelo_simple <- lm(mpg ~ weight, data = auto_mpg)

# Resumen del modelo
summary(modelo_simple)

Call:
lm(formula = mpg ~ weight, data = auto_mpg)

Residuals:
    Min      1Q  Median      3Q     Max 
-12.012  -2.801  -0.351   2.114  16.480 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) 46.3173644  0.7952452   58.24   <2e-16 ***
weight      -0.0076766  0.0002575  -29.81   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 4.345 on 396 degrees of freedom
Multiple R-squared:  0.6918,    Adjusted R-squared:  0.691 
F-statistic: 888.9 on 1 and 396 DF,  p-value: < 2.2e-16
# Gráficos de diagnóstico del modelo
par(mfrow = c(2, 2))
plot(modelo_simple)


# Gráfico Q-Q
qqPlot(modelo_simple$residuals)
[1] 323 327

# Ajuste del modelo de regresión lineal múltiple
modelo_multiple <- lm(mpg ~ weight + horsepower + acceleration, data = auto_mpg)

# Resumen del modelo
summary(modelo_multiple)

Call:
lm(formula = mpg ~ weight + horsepower + acceleration, data = auto_mpg)

Residuals:
   Min     1Q Median     3Q    Max 
-9.458 -2.023  0.000  1.407 15.062 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    4.143e+01  2.496e+00  16.601  < 2e-16 ***
weight        -3.570e-03  6.972e-04  -5.120 5.45e-07 ***
horsepower100 -6.498e+00  1.860e+00  -3.494 0.000546 ***
horsepower102 -6.109e+00  4.058e+00  -1.505 0.133287    
horsepower103 -6.899e+00  4.030e+00  -1.712 0.087938 .  
horsepower105 -4.568e+00  1.974e+00  -2.315 0.021306 *  
horsepower107 -7.971e+00  4.037e+00  -1.974 0.049258 *  
horsepower108 -7.946e+00  4.042e+00  -1.966 0.050226 .  
horsepower110 -5.724e+00  1.875e+00  -3.053 0.002466 ** 
horsepower112 -7.619e+00  2.680e+00  -2.843 0.004771 ** 
horsepower113 -4.210e+00  4.054e+00  -1.038 0.299885    
horsepower115 -3.118e+00  2.337e+00  -1.334 0.183129    
horsepower116 -2.406e+00  4.100e+00  -0.587 0.557653    
horsepower120 -6.390e+00  2.580e+00  -2.477 0.013790 *  
horsepower122 -7.905e+00  4.068e+00  -1.943 0.052943 .  
horsepower125 -5.049e+00  2.781e+00  -1.815 0.070459 .  
horsepower129 -1.053e+01  3.243e+00  -3.246 0.001302 ** 
horsepower130 -8.530e+00  2.588e+00  -3.296 0.001096 ** 
horsepower132  4.618e+00  4.137e+00   1.116 0.265172    
horsepower133 -8.955e+00  4.086e+00  -2.192 0.029177 *  
horsepower135 -5.612e+00  4.166e+00  -1.347 0.178953    
horsepower137 -9.237e+00  4.229e+00  -2.184 0.029713 *  
horsepower138 -7.385e+00  4.255e+00  -1.735 0.083692 .  
horsepower139 -7.072e+00  3.261e+00  -2.168 0.030908 *  
horsepower140 -6.951e+00  2.517e+00  -2.762 0.006100 ** 
horsepower142 -7.746e+00  4.238e+00  -1.828 0.068582 .  
horsepower145 -8.299e+00  2.532e+00  -3.277 0.001171 ** 
horsepower148 -7.301e+00  4.421e+00  -1.652 0.099656 .  
horsepower149 -6.191e+00  4.296e+00  -1.441 0.150583    
horsepower150 -8.971e+00  2.278e+00  -3.938 0.000102 ***
horsepower152 -8.561e+00  4.332e+00  -1.976 0.049060 *  
horsepower153 -9.206e+00  3.399e+00  -2.708 0.007152 ** 
horsepower155 -6.976e+00  3.443e+00  -2.026 0.043647 *  
horsepower158 -9.480e+00  4.362e+00  -2.174 0.030515 *  
horsepower160 -1.124e+01  3.502e+00  -3.211 0.001467 ** 
horsepower165 -9.391e+00  2.826e+00  -3.323 0.001001 ** 
horsepower167 -8.672e+00  4.542e+00  -1.909 0.057163 .  
horsepower170 -8.363e+00  2.922e+00  -2.862 0.004501 ** 
horsepower175 -9.298e+00  2.908e+00  -3.197 0.001535 ** 
horsepower180 -9.403e+00  2.911e+00  -3.230 0.001374 ** 
horsepower190 -9.068e+00  3.195e+00  -2.838 0.004852 ** 
horsepower193 -1.074e+01  4.272e+00  -2.513 0.012498 *  
horsepower198 -8.553e+00  3.716e+00  -2.302 0.022036 *  
horsepower200 -1.191e+01  4.288e+00  -2.778 0.005803 ** 
horsepower208 -1.104e+01  4.533e+00  -2.434 0.015495 *  
horsepower210 -1.128e+01  4.346e+00  -2.596 0.009888 ** 
horsepower215 -9.941e+00  3.325e+00  -2.990 0.003022 ** 
horsepower220 -9.551e+00  4.558e+00  -2.095 0.036981 *  
horsepower225 -1.059e+01  3.229e+00  -3.279 0.001165 ** 
horsepower230 -7.693e+00  4.508e+00  -1.706 0.088978 .  
horsepower46  -3.287e+00  3.136e+00  -1.048 0.295526    
horsepower48   1.558e+01  2.764e+00   5.638 3.96e-08 ***
horsepower49  -7.021e-01  4.067e+00  -0.173 0.863058    
horsepower52   5.098e+00  2.514e+00   2.028 0.043402 *  
horsepower53   2.509e+00  3.075e+00   0.816 0.415233    
horsepower54  -4.282e+00  4.126e+00  -1.038 0.300192    
horsepower58   7.119e+00  3.080e+00   2.311 0.021484 *  
horsepower60   2.329e+00  2.310e+00   1.008 0.314082    
horsepower61   2.654e+00  4.046e+00   0.656 0.512417    
horsepower62   3.504e+00  3.051e+00   1.149 0.251607    
horsepower63   4.608e+00  2.637e+00   1.747 0.081602 .  
horsepower64   8.522e+00  4.031e+00   2.114 0.035312 *  
horsepower65   6.059e+00  1.968e+00   3.079 0.002269 ** 
horsepower66   4.835e+00  4.034e+00   1.198 0.231716    
horsepower67   4.359e+00  1.870e+00   2.331 0.020400 *  
horsepower68   2.555e+00  2.167e+00   1.179 0.239284    
horsepower69   2.783e+00  2.648e+00   1.051 0.294116    
horsepower70   2.700e+00  1.876e+00   1.439 0.151062    
horsepower71  -1.684e-01  2.255e+00  -0.075 0.940527    
horsepower72  -5.034e+00  2.149e+00  -2.343 0.019794 *  
horsepower74   4.338e+00  2.632e+00   1.648 0.100384    
horsepower75  -2.639e-01  1.822e+00  -0.145 0.884963    
horsepower76   2.773e+00  2.399e+00   1.156 0.248619    
horsepower77   1.790e+00  4.055e+00   0.441 0.659284    
horsepower78  -1.576e+00  2.148e+00  -0.734 0.463650    
horsepower79  -1.007e+00  3.037e+00  -0.332 0.740335    
horsepower80  -1.129e-01  2.071e+00  -0.055 0.956556    
horsepower81  -3.113e+00  3.034e+00  -1.026 0.305803    
horsepower82   4.317e+00  4.019e+00   1.074 0.283708    
horsepower83  -9.528e-01  2.402e+00  -0.397 0.691908    
horsepower84   1.153e+00  2.182e+00   0.529 0.597423    
horsepower85  -3.315e+00  1.979e+00  -1.675 0.094941 .  
horsepower86  -4.565e+00  2.260e+00  -2.020 0.044283 *  
horsepower87  -3.540e+00  3.039e+00  -1.165 0.244945    
horsepower88  -2.419e+00  1.748e+00  -1.384 0.167460    
horsepower89  -1.993e+00  4.027e+00  -0.495 0.621022    
horsepower90  -2.885e+00  1.745e+00  -1.654 0.099254 .  
horsepower91  -8.578e+00  4.042e+00  -2.122 0.034655 *  
horsepower92  -6.659e-01  2.165e+00  -0.308 0.758585    
horsepower93  -2.870e+00  4.018e+00  -0.714 0.475602    
horsepower94  -6.653e+00  4.014e+00  -1.658 0.098423 .  
horsepower95  -5.133e+00  1.844e+00  -2.783 0.005720 ** 
horsepower96  -1.427e+00  2.663e+00  -0.536 0.592350    
horsepower97  -6.258e+00  1.991e+00  -3.143 0.001841 ** 
horsepower98  -5.283e+00  3.084e+00  -1.713 0.087766 .  
acceleration  -2.596e-01  1.376e-01  -1.887 0.060105 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.715 on 302 degrees of freedom
Multiple R-squared:  0.8281,    Adjusted R-squared:  0.7741 
F-statistic: 15.32 on 95 and 302 DF,  p-value: < 2.2e-16
# Gráficos de diagnóstico del modelo
par(mfrow = c(2, 2))
plot(modelo_multiple)
Warning: not plotting observations with leverage one:
  24, 27, 28, 29, 60, 68, 89, 93, 105, 111, 114, 117, 118, 120, 124, 146, 151, 160, 191, 208, 211, 233, 237, 246, 275, 278, 288, 289, 291, 298, 334, 345, 362, 398

# Verificar multicolinealidad usando VIF
vif(modelo_multiple)
                  GVIF Df GVIF^(1/(2*Df))
weight       10.026270  1        3.166429
horsepower   22.889379 93        1.016974
acceleration  4.141248  1        2.035006
# Convertir 'origin' en variables dummy
auto_mpg <- auto_mpg %>%
  mutate(origin = as.factor(origin)) %>%
  mutate(origin_1 = ifelse(origin == 1, 1, 0),
         origin_2 = ifelse(origin == 2, 1, 0),
         origin_3 = ifelse(origin == 3, 1, 0))

# Ajuste del nuevo modelo con variables dummy
modelo_dummy <- lm(mpg ~ weight + horsepower + acceleration + origin_1 + origin_2, data = auto_mpg)

# Resumen del modelo
summary(modelo_dummy)

Call:
lm(formula = mpg ~ weight + horsepower + acceleration + origin_1 + 
    origin_2, data = auto_mpg)

Residuals:
    Min      1Q  Median      3Q     Max 
-11.795  -1.935   0.000   1.327  14.908 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    4.212e+01  2.444e+00  17.237  < 2e-16 ***
weight        -2.505e-03  7.138e-04  -3.510 0.000517 ***
horsepower100 -7.221e+00  1.812e+00  -3.985 8.49e-05 ***
horsepower102 -7.607e+00  3.969e+00  -1.917 0.056216 .  
horsepower103 -8.054e+00  3.934e+00  -2.047 0.041485 *  
horsepower105 -5.114e+00  1.918e+00  -2.666 0.008091 ** 
horsepower107 -7.595e+00  3.910e+00  -1.942 0.053035 .  
horsepower108 -1.152e+01  3.980e+00  -2.895 0.004068 ** 
horsepower110 -6.509e+00  1.822e+00  -3.573 0.000412 ***
horsepower112 -8.448e+00  2.609e+00  -3.238 0.001341 ** 
horsepower113 -4.781e+00  3.945e+00  -1.212 0.226522    
horsepower115 -3.568e+00  2.262e+00  -1.577 0.115828    
horsepower116 -5.994e+00  4.035e+00  -1.486 0.138442    
horsepower120 -8.294e+00  2.525e+00  -3.284 0.001143 ** 
horsepower122 -1.138e+01  4.001e+00  -2.844 0.004760 ** 
horsepower125 -6.192e+00  2.701e+00  -2.293 0.022554 *  
horsepower129 -1.121e+01  3.142e+00  -3.567 0.000420 ***
horsepower130 -9.693e+00  2.516e+00  -3.853 0.000143 ***
horsepower132  1.001e+00  4.071e+00   0.246 0.805954    
horsepower133 -1.073e+01  4.003e+00  -2.680 0.007766 ** 
horsepower135 -6.664e+00  4.035e+00  -1.651 0.099691 .  
horsepower137 -1.052e+01  4.098e+00  -2.568 0.010710 *  
horsepower138 -8.600e+00  4.123e+00  -2.086 0.037847 *  
horsepower139 -7.701e+00  3.160e+00  -2.437 0.015373 *  
horsepower140 -8.290e+00  2.451e+00  -3.382 0.000816 ***
horsepower142 -9.050e+00  4.107e+00  -2.203 0.028336 *  
horsepower145 -9.566e+00  2.465e+00  -3.881 0.000128 ***
horsepower148 -9.259e+00  4.293e+00  -2.157 0.031836 *  
horsepower149 -7.791e+00  4.167e+00  -1.870 0.062514 .  
horsepower150 -1.028e+01  2.221e+00  -4.626 5.55e-06 ***
horsepower152 -1.006e+01  4.201e+00  -2.394 0.017259 *  
horsepower153 -1.062e+01  3.301e+00  -3.217 0.001437 ** 
horsepower155 -8.683e+00  3.349e+00  -2.593 0.009981 ** 
horsepower158 -1.113e+01  4.231e+00  -2.631 0.008953 ** 
horsepower160 -1.258e+01  3.399e+00  -3.701 0.000255 ***
horsepower165 -1.057e+01  2.746e+00  -3.849 0.000145 ***
horsepower167 -1.091e+01  4.415e+00  -2.471 0.014038 *  
horsepower170 -1.003e+01  2.847e+00  -3.524 0.000492 ***
horsepower175 -1.099e+01  2.835e+00  -3.876 0.000130 ***
horsepower180 -1.105e+01  2.836e+00  -3.898 0.000120 ***
horsepower190 -1.057e+01  3.106e+00  -3.404 0.000754 ***
horsepower193 -1.270e+01  4.151e+00  -3.059 0.002419 ** 
horsepower198 -1.054e+01  3.616e+00  -2.915 0.003830 ** 
horsepower200 -1.355e+01  4.160e+00  -3.257 0.001254 ** 
horsepower208 -1.301e+01  4.402e+00  -2.954 0.003380 ** 
horsepower210 -1.295e+01  4.216e+00  -3.071 0.002330 ** 
horsepower215 -1.182e+01  3.239e+00  -3.651 0.000309 ***
horsepower220 -1.125e+01  4.422e+00  -2.545 0.011424 *  
horsepower225 -1.206e+01  3.138e+00  -3.842 0.000149 ***
horsepower230 -9.307e+00  4.372e+00  -2.129 0.034091 *  
horsepower46  -3.371e+00  3.060e+00  -1.102 0.271520    
horsepower48   1.526e+01  2.707e+00   5.638 3.96e-08 ***
horsepower49  -7.778e-01  3.953e+00  -0.197 0.844158    
horsepower52   4.092e+00  2.440e+00   1.677 0.094572 .  
horsepower53   1.695e-01  3.021e+00   0.056 0.955289    
horsepower54  -4.709e+00  4.014e+00  -1.173 0.241602    
horsepower58   5.944e+00  2.989e+00   1.989 0.047627 *  
horsepower60   1.048e+00  2.251e+00   0.465 0.642023    
horsepower61   1.164e-01  3.952e+00   0.029 0.976533    
horsepower62   2.140e+00  2.965e+00   0.722 0.470905    
horsepower63   5.370e+00  2.567e+00   2.092 0.037322 *  
horsepower64   9.568e+00  3.912e+00   2.446 0.015038 *  
horsepower65   4.188e+00  1.954e+00   2.143 0.032933 *  
horsepower66   5.931e+00  3.917e+00   1.514 0.131049    
horsepower67   2.381e+00  1.854e+00   1.284 0.199986    
horsepower68   5.195e-01  2.148e+00   0.242 0.809031    
horsepower69   1.781e+00  2.577e+00   0.691 0.489963    
horsepower70   2.093e+00  1.819e+00   1.150 0.250915    
horsepower71  -6.764e-01  2.226e+00  -0.304 0.761447    
horsepower72  -5.427e+00  2.089e+00  -2.598 0.009827 ** 
horsepower74   3.012e+00  2.570e+00   1.172 0.242178    
horsepower75  -1.877e+00  1.794e+00  -1.046 0.296463    
horsepower76   2.014e+00  2.369e+00   0.850 0.396028    
horsepower77  -4.669e-02  3.976e+00  -0.012 0.990638    
horsepower78  -1.941e+00  2.090e+00  -0.929 0.353779    
horsepower79  -5.356e-01  2.947e+00  -0.182 0.855894    
horsepower80   2.167e-01  2.008e+00   0.108 0.914134    
horsepower81  -3.431e+00  2.937e+00  -1.168 0.243686    
horsepower82   4.509e+00  3.892e+00   1.159 0.247528    
horsepower83  -9.333e-01  2.324e+00  -0.402 0.688325    
horsepower84   1.556e+00  2.124e+00   0.733 0.464290    
horsepower85  -3.319e+00  1.924e+00  -1.725 0.085474 .  
horsepower86  -4.346e+00  2.188e+00  -1.987 0.047868 *  
horsepower87  -4.651e+00  2.987e+00  -1.557 0.120445    
horsepower88  -3.325e+00  1.703e+00  -1.953 0.051771 .  
horsepower89  -1.892e+00  3.899e+00  -0.485 0.627849    
horsepower90  -3.297e+00  1.692e+00  -1.949 0.052261 .  
horsepower91  -9.497e+00  3.941e+00  -2.410 0.016547 *  
horsepower92  -1.527e+00  2.110e+00  -0.723 0.469969    
horsepower93  -5.873e+00  3.939e+00  -1.491 0.136973    
horsepower94  -9.628e+00  3.933e+00  -2.448 0.014942 *  
horsepower95  -6.493e+00  1.807e+00  -3.593 0.000382 ***
horsepower96  -3.461e+00  2.615e+00  -1.323 0.186727    
horsepower97  -8.687e+00  1.998e+00  -4.348 1.88e-05 ***
horsepower98  -6.267e+00  2.994e+00  -2.093 0.037153 *  
acceleration  -2.747e-01  1.330e-01  -2.065 0.039823 *  
origin_1      -3.487e+00  7.273e-01  -4.794 2.58e-06 ***
origin_2      -2.309e+00  7.918e-01  -2.917 0.003807 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.591 on 300 degrees of freedom
Multiple R-squared:  0.8405,    Adjusted R-squared:  0.7889 
F-statistic: 16.29 on 97 and 300 DF,  p-value: < 2.2e-16
# Gráficos de diagnóstico del modelo
par(mfrow = c(2, 2))
plot(modelo_dummy)
Warning: not plotting observations with leverage one:
  24, 27, 28, 29, 60, 68, 89, 93, 105, 111, 114, 117, 118, 120, 124, 146, 151, 160, 191, 208, 211, 233, 237, 246, 275, 278, 288, 289, 291, 298, 334, 345, 362, 398

# Ajuste del modelo libre con una combinación de variables
modelo_libre <- lm(mpg ~ weight + horsepower + acceleration + cylinders, data = auto_mpg)

# Resumen del modelo
summary(modelo_libre)

Call:
lm(formula = mpg ~ weight + horsepower + acceleration + cylinders, 
    data = auto_mpg)

Residuals:
    Min      1Q  Median      3Q     Max 
-10.335  -2.042   0.000   1.377  15.445 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    4.306e+01  2.585e+00  16.657  < 2e-16 ***
weight        -2.687e-03  7.981e-04  -3.366  0.00086 ***
horsepower100 -6.061e+00  1.858e+00  -3.262  0.00123 ** 
horsepower102 -6.985e+00  4.051e+00  -1.724  0.08571 .  
horsepower103 -6.722e+00  4.005e+00  -1.679  0.09428 .  
horsepower105 -4.213e+00  1.967e+00  -2.141  0.03305 *  
horsepower107 -6.771e+00  4.047e+00  -1.673  0.09533 .  
horsepower108 -7.106e+00  4.034e+00  -1.762  0.07915 .  
horsepower110 -5.225e+00  1.876e+00  -2.785  0.00569 ** 
horsepower112 -7.770e+00  2.663e+00  -2.918  0.00379 ** 
horsepower113 -4.374e+00  4.028e+00  -1.086  0.27839    
horsepower115 -2.828e+00  2.325e+00  -1.216  0.22490    
horsepower116 -1.628e+00  4.088e+00  -0.398  0.69080    
horsepower120 -5.717e+00  2.581e+00  -2.215  0.02750 *  
horsepower122 -7.016e+00  4.061e+00  -1.728  0.08510 .  
horsepower125 -3.741e+00  2.825e+00  -1.324  0.18648    
horsepower129 -8.701e+00  3.325e+00  -2.617  0.00933 ** 
horsepower130 -7.074e+00  2.653e+00  -2.667  0.00807 ** 
horsepower132  5.351e+00  4.123e+00   1.298  0.19532    
horsepower133 -8.529e+00  4.064e+00  -2.099  0.03669 *  
horsepower135 -4.047e+00  4.198e+00  -0.964  0.33585    
horsepower137 -7.880e+00  4.245e+00  -1.856  0.06440 .  
horsepower138 -5.991e+00  4.274e+00  -1.402  0.16201    
horsepower139 -5.214e+00  3.346e+00  -1.558  0.12022    
horsepower140 -5.650e+00  2.568e+00  -2.200  0.02857 *  
horsepower142 -6.406e+00  4.253e+00  -1.506  0.13309    
horsepower145 -6.951e+00  2.588e+00  -2.686  0.00763 ** 
horsepower148 -6.518e+00  4.406e+00  -1.479  0.14010    
horsepower149 -5.093e+00  4.296e+00  -1.185  0.23679    
horsepower150 -7.658e+00  2.339e+00  -3.274  0.00118 ** 
horsepower152 -7.409e+00  4.335e+00  -1.709  0.08848 .  
horsepower153 -7.975e+00  3.422e+00  -2.330  0.02044 *  
horsepower155 -5.972e+00  3.451e+00  -1.731  0.08452 .  
horsepower158 -8.453e+00  4.358e+00  -1.940  0.05335 .  
horsepower160 -9.994e+00  3.525e+00  -2.835  0.00489 ** 
horsepower165 -8.365e+00  2.845e+00  -2.940  0.00354 ** 
horsepower167 -8.139e+00  4.519e+00  -1.801  0.07267 .  
horsepower170 -7.375e+00  2.936e+00  -2.512  0.01254 *  
horsepower175 -8.321e+00  2.923e+00  -2.847  0.00471 ** 
horsepower180 -8.400e+00  2.927e+00  -2.870  0.00440 ** 
horsepower190 -7.955e+00  3.214e+00  -2.475  0.01387 *  
horsepower193 -9.866e+00  4.262e+00  -2.315  0.02131 *  
horsepower198 -7.844e+00  3.705e+00  -2.117  0.03509 *  
horsepower200 -1.084e+01  4.288e+00  -2.528  0.01200 *  
horsepower208 -1.031e+01  4.516e+00  -2.283  0.02315 *  
horsepower210 -1.026e+01  4.342e+00  -2.362  0.01881 *  
horsepower215 -9.138e+00  3.323e+00  -2.750  0.00632 ** 
horsepower220 -8.638e+00  4.547e+00  -1.899  0.05845 .  
horsepower225 -9.455e+00  3.248e+00  -2.911  0.00387 ** 
horsepower230 -6.697e+00  4.501e+00  -1.488  0.13786    
horsepower46  -2.898e+00  3.121e+00  -0.929  0.35388    
horsepower48   1.580e+01  2.748e+00   5.751 2.17e-08 ***
horsepower49  -3.290e-01  4.044e+00  -0.081  0.93522    
horsepower52   5.434e+00  2.502e+00   2.172  0.03062 *  
horsepower53   2.883e+00  3.060e+00   0.942  0.34683    
horsepower54  -4.129e+00  4.100e+00  -1.007  0.31475    
horsepower58   7.506e+00  3.065e+00   2.449  0.01489 *  
horsepower60   2.638e+00  2.299e+00   1.147  0.25221    
horsepower61   2.891e+00  4.021e+00   0.719  0.47267    
horsepower62   3.709e+00  3.032e+00   1.223  0.22227    
horsepower63   4.628e+00  2.620e+00   1.766  0.07838 .  
horsepower64   8.793e+00  4.006e+00   2.195  0.02894 *  
horsepower65   6.260e+00  1.957e+00   3.198  0.00153 ** 
horsepower66   5.111e+00  4.010e+00   1.275  0.20343    
horsepower67   4.451e+00  1.858e+00   2.396  0.01720 *  
horsepower68   2.695e+00  2.154e+00   1.251  0.21176    
horsepower69   2.980e+00  2.633e+00   1.132  0.25860    
horsepower70   2.810e+00  1.864e+00   1.507  0.13275    
horsepower71  -2.084e-01  2.240e+00  -0.093  0.92595    
horsepower72  -4.932e+00  2.135e+00  -2.310  0.02157 *  
horsepower74   4.248e+00  2.615e+00   1.624  0.10538    
horsepower75  -3.489e-01  1.811e+00  -0.193  0.84733    
horsepower76   2.911e+00  2.384e+00   1.221  0.22315    
horsepower77   1.477e+00  4.031e+00   0.366  0.71433    
horsepower78  -1.570e+00  2.134e+00  -0.736  0.46249    
horsepower79  -1.181e+00  3.018e+00  -0.391  0.69578    
horsepower80  -3.011e-01  2.059e+00  -0.146  0.88384    
horsepower81  -2.705e+00  3.020e+00  -0.896  0.37109    
horsepower82   3.934e+00  3.997e+00   0.984  0.32584    
horsepower83  -1.049e+00  2.387e+00  -0.439  0.66062    
horsepower84   8.522e-01  2.172e+00   0.392  0.69506    
horsepower85  -2.887e+00  1.976e+00  -1.461  0.14502    
horsepower86  -4.801e+00  2.248e+00  -2.136  0.03352 *  
horsepower87  -4.044e+00  3.028e+00  -1.336  0.18267    
horsepower88  -2.523e+00  1.737e+00  -1.452  0.14749    
horsepower89  -2.517e+00  4.008e+00  -0.628  0.53050    
horsepower90  -2.808e+00  1.734e+00  -1.620  0.10632    
horsepower91  -9.004e+00  4.021e+00  -2.239  0.02586 *  
horsepower92  -1.031e+00  2.157e+00  -0.478  0.63290    
horsepower93  -3.082e+00  3.993e+00  -0.772  0.44088    
horsepower94  -6.824e+00  3.988e+00  -1.711  0.08813 .  
horsepower95  -4.928e+00  1.835e+00  -2.686  0.00763 ** 
horsepower96  -1.821e+00  2.652e+00  -0.687  0.49279    
horsepower97  -6.223e+00  1.978e+00  -3.145  0.00182 ** 
horsepower98  -5.438e+00  3.065e+00  -1.774  0.07707 .  
acceleration  -2.902e-01  1.374e-01  -2.112  0.03550 *  
cylinders     -7.641e-01  3.431e-01  -2.227  0.02668 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.691 on 301 degrees of freedom
Multiple R-squared:  0.8309,    Adjusted R-squared:  0.777 
F-statistic: 15.41 on 96 and 301 DF,  p-value: < 2.2e-16
# Gráficos de diagnóstico del modelo
par(mfrow = c(2, 2))
plot(modelo_libre)
Warning: not plotting observations with leverage one:
  24, 27, 28, 29, 60, 68, 89, 93, 105, 111, 114, 117, 118, 120, 124, 146, 151, 160, 191, 208, 211, 233, 237, 246, 275, 278, 288, 289, 291, 298, 334, 345, 362, 398

LS0tDQp0aXRsZTogIlIgTm90ZWJvb2siDQpvdXRwdXQ6DQogIGh0bWxfbm90ZWJvb2s6IGRlZmF1bHQNCiAgcGRmX2RvY3VtZW50OiBkZWZhdWx0DQotLS0NCg0KVGhpcyBpcyBhbiBbUiBNYXJrZG93bl0oaHR0cDovL3JtYXJrZG93bi5yc3R1ZGlvLmNvbSkgTm90ZWJvb2suIFdoZW4geW91IGV4ZWN1dGUgY29kZSB3aXRoaW4gdGhlIG5vdGVib29rLCB0aGUgcmVzdWx0cyBhcHBlYXIgYmVuZWF0aCB0aGUgY29kZS4gDQoNClRyeSBleGVjdXRpbmcgdGhpcyBjaHVuayBieSBjbGlja2luZyB0aGUgKlJ1biogYnV0dG9uIHdpdGhpbiB0aGUgY2h1bmsgb3IgYnkgcGxhY2luZyB5b3VyIGN1cnNvciBpbnNpZGUgaXQgYW5kIHByZXNzaW5nICpDdHJsK1NoaWZ0K0VudGVyKi4gDQoNCmBgYHtyfQ0KIyBJbnN0YWxhbW9zIHkgY2FyZ2Ftb3MgbGFzIGxpYnJlcsOtYXMgbmVjZXNhcmlhcw0KbGlicmFyeSh0aWR5dmVyc2UpDQpsaWJyYXJ5KGdncGxvdDIpDQpsaWJyYXJ5KGNhcikNCg0KDQphdXRvX21wZyA8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