title: Tarea de gio html_document: Proyecto final
mtcars$acc <- mtcars$qsec
m1 <- lm(mpg ~ wt, data = mtcars)
summary(m1)
##
## Call:
## lm(formula = mpg ~ wt, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5432 -2.3647 -0.1252 1.4096 6.8727
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 37.2851 1.8776 19.858 < 2e-16 ***
## wt -5.3445 0.5591 -9.559 1.29e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.046 on 30 degrees of freedom
## Multiple R-squared: 0.7528, Adjusted R-squared: 0.7446
## F-statistic: 91.38 on 1 and 30 DF, p-value: 1.294e-10
m2 <- lm(mpg ~ wt + hp, data = mtcars)
summary(m2)
##
## Call:
## lm(formula = mpg ~ wt + hp, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.941 -1.600 -0.182 1.050 5.854
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 37.22727 1.59879 23.285 < 2e-16 ***
## wt -3.87783 0.63273 -6.129 1.12e-06 ***
## hp -0.03177 0.00903 -3.519 0.00145 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.593 on 29 degrees of freedom
## Multiple R-squared: 0.8268, Adjusted R-squared: 0.8148
## F-statistic: 69.21 on 2 and 29 DF, p-value: 9.109e-12
m3 <- lm(mpg ~ wt + hp + cyl, data = mtcars)
summary(m3)
##
## Call:
## lm(formula = mpg ~ wt + hp + cyl, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.9290 -1.5598 -0.5311 1.1850 5.8986
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 38.75179 1.78686 21.687 < 2e-16 ***
## wt -3.16697 0.74058 -4.276 0.000199 ***
## hp -0.01804 0.01188 -1.519 0.140015
## cyl -0.94162 0.55092 -1.709 0.098480 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.512 on 28 degrees of freedom
## Multiple R-squared: 0.8431, Adjusted R-squared: 0.8263
## F-statistic: 50.17 on 3 and 28 DF, p-value: 2.184e-11
m4 <- lm(mpg ~ wt + hp + cyl + acc, data = mtcars)
summary(m4)
##
## Call:
## lm(formula = mpg ~ wt + hp + cyl + acc, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.1532 -1.3425 -0.4944 1.0588 5.6386
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 34.28084 9.79157 3.501 0.00163 **
## wt -3.47938 1.00813 -3.451 0.00185 **
## hp -0.01378 0.01513 -0.911 0.37039
## cyl -0.80986 0.62663 -1.292 0.20717
## acc 0.22616 0.48675 0.465 0.64591
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.547 on 27 degrees of freedom
## Multiple R-squared: 0.8444, Adjusted R-squared: 0.8213
## F-statistic: 36.63 on 4 and 27 DF, p-value: 1.534e-10
Se estimaron cuatro modelos de regresión lineal para explicar el consumo de combustible (mpg): un modelo con una variable, dos modelos con variables adicionales y un modelo completo. Al comparar los resultados obtenidos, se observó que el Modelo 3 presenta el mejor desempeño, ya que obtiene el mayor R2R^2R2 ajustado y todas sus variables resultan estadísticamente significativas.
El Modelo 4 no representa una mejora con respecto al Modelo 3, debido a que la variable adicional no aporta información relevante al modelo. Por esta razón, se selecciona el Modelo 3 como el mejor modelo, al ofrecer un buen equilibrio entre simplicidad y capacidad explicativa.