df = read.csv("~/Desktop/carValue.csv")
attach(df)
summary(df)## Car Size Family.Sedan Upscale.Sedan
## Length:54 Length:54 Min. :0.0000 Min. :0.0000
## Class :character Class :character 1st Qu.:0.0000 1st Qu.:0.0000
## Mode :character Mode :character Median :0.0000 Median :0.0000
## Mean :0.3704 Mean :0.3889
## 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :1.0000
## Price Cost_Mile RoadTestScore PredictedReliability
## Min. :16419 Min. :0.4400 Min. :52.00 Min. :1.000
## 1st Qu.:21922 1st Qu.:0.5700 1st Qu.:73.00 1st Qu.:3.000
## Median :28918 Median :0.6700 Median :78.00 Median :3.000
## Mean :28340 Mean :0.6567 Mean :78.07 Mean :3.407
## 3rd Qu.:34102 3rd Qu.:0.7475 3rd Qu.:84.00 3rd Qu.:4.000
## Max. :39850 Max. :0.8300 Max. :95.00 Max. :5.000
## ValueScore
## Min. :0.820
## 1st Qu.:1.173
## Median :1.335
## Mean :1.354
## 3rd Qu.:1.502
## Max. :1.990
str(df)## 'data.frame': 54 obs. of 9 variables:
## $ Car : chr "Toyota Corolla (base, manual)" "Mazda3 i Touring (manual)" "Toyota Corolla LE" "Mazda3 i Touring" ...
## $ Size : chr "Small Sedan" "Small Sedan" "Small Sedan" "Small Sedan" ...
## $ Family.Sedan : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Upscale.Sedan : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Price : int 16419 18895 18404 19745 18445 20150 19040 20280 16595 20300 ...
## $ Cost_Mile : num 0.44 0.5 0.47 0.52 0.53 0.57 0.57 0.52 0.47 0.54 ...
## $ RoadTestScore : int 70 74 71 70 80 74 71 68 61 60 ...
## $ PredictedReliability: int 4 5 4 5 3 4 3 2 2 3 ...
## $ ValueScore : num 1.99 1.94 1.89 1.82 1.64 1.51 1.32 1.3 1.25 1.24 ...
lm1 = lm(Cost_Mile~Family.Sedan+Upscale.Sedan)
summary(lm1)##
## Call:
## lm(formula = Cost_Mile ~ Family.Sedan + Upscale.Sedan)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.103333 -0.049833 0.006667 0.036667 0.098000
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.52308 0.01443 36.248 < 2e-16 ***
## Family.Sedan 0.11892 0.01854 6.416 4.56e-08 ***
## Upscale.Sedan 0.23026 0.01836 12.540 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.05203 on 51 degrees of freedom
## Multiple R-squared: 0.758, Adjusted R-squared: 0.7485
## F-statistic: 79.89 on 2 and 51 DF, p-value: < 2.2e-16
Interpritition: with a unit change in cost/mile
lm2 = lm(ValueScore ~ Cost_Mile + RoadTestScore+PredictedReliability+
Family.Sedan+Upscale.Sedan)
summary(lm2)##
## Call:
## lm(formula = ValueScore ~ Cost_Mile + RoadTestScore + PredictedReliability +
## Family.Sedan + Upscale.Sedan)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.14750 -0.04675 -0.00125 0.04603 0.17186
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.370959 0.139662 9.816 4.63e-13 ***
## Cost_Mile -2.265881 0.193841 -11.689 1.20e-15 ***
## RoadTestScore 0.011133 0.001313 8.477 4.22e-11 ***
## PredictedReliability 0.166210 0.010433 15.931 < 2e-16 ***
## Family.Sedan 0.022778 0.037989 0.600 0.552
## Upscale.Sedan 0.068111 0.053706 1.268 0.211
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.07199 on 48 degrees of freedom
## Multiple R-squared: 0.9353, Adjusted R-squared: 0.9286
## F-statistic: 138.8 on 5 and 48 DF, p-value: < 2.2e-16
lm3 = lm(ValueScore ~ Cost_Mile + RoadTestScore + PredictedReliability)
summary(lm3)##
## Call:
## lm(formula = ValueScore ~ Cost_Mile + RoadTestScore + PredictedReliability)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.146647 -0.050088 0.006191 0.043384 0.187797
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.24443 0.09273 13.420 < 2e-16 ***
## Cost_Mile -2.04325 0.10471 -19.514 < 2e-16 ***
## RoadTestScore 0.01138 0.00123 9.252 2.06e-12 ***
## PredictedReliability 0.16510 0.01016 16.257 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.07213 on 50 degrees of freedom
## Multiple R-squared: 0.9324, Adjusted R-squared: 0.9283
## F-statistic: 229.7 on 3 and 50 DF, p-value: < 2.2e-16
lm4 = lm(ValueScore~RoadTestScore)
summary(lm4)##
## Call:
## lm(formula = ValueScore ~ RoadTestScore)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.50996 -0.21083 -0.02092 0.15999 0.68317
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.902038 0.318681 2.831 0.00659 **
## RoadTestScore 0.005783 0.004055 1.426 0.15984
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2668 on 52 degrees of freedom
## Multiple R-squared: 0.03763, Adjusted R-squared: 0.01913
## F-statistic: 2.033 on 1 and 52 DF, p-value: 0.1598
lm5 = lm(ValueScore~PredictedReliability)
summary(lm5)##
## Call:
## lm(formula = ValueScore ~ PredictedReliability)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.42955 -0.13373 -0.02624 0.13209 0.53377
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.76293 0.10141 7.524 7.25e-10 ***
## PredictedReliability 0.17332 0.02858 6.065 1.52e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2081 on 52 degrees of freedom
## Multiple R-squared: 0.4143, Adjusted R-squared: 0.4031
## F-statistic: 36.79 on 1 and 52 DF, p-value: 1.518e-07