Used-Car Prices: Audi A6

Group Members: Kaelyn Lemon, Zora Yezi Yang

Introduction

We compiled and analyzed data on used cars of the model Audi A6. The use of the word “car” in this project refers specifically to pre-owned Audi A6s. We chose to describe the cars in terms of the following variables:

Model -the type of Audi A6, for example 3.0T or 3.2T

Mileage -the mileage of the car

Year -the model year of the car, for example 2009

Zip.Code -the center of the search radius from which the cases were found. 02118 corresponds to Boston, 90210 corresponds to Los Angeles, 55105 corresponds to Saint Paul, and 30322 corresponds to Atlanta

Cost -the price of the car in US dollars

Color -the color of the car: Black (black and brown), Blue, White (white, beige, tan, bronze, and gold), and Gray (gray and silver)

We also added the variable Age, which is equal to Year-2013, so that the newest cars (Year 2013) are Age 0, and Age increases as a car gets older.

Reading in the Spreadsheet

dataSource = "https://docs.google.com/spreadsheet/pub?key=0AnEWI_gMkW2ndDljYWk1TUMxNWdzeUVlOTNSX3dDRWc&output=csv"
cars = fetchGoogle(dataSource)
cars=transform(cars, Age=2013-Year)

Description of Data

xyplot(Cost~Year, data=cars, ylab="Cost ($)", xlab="Year")

plot of chunk unnamed-chunk-3

As cars get older (Year is smaller), Cost decreases.

xyplot(Cost~Mileage, data=cars, ylab="Cost ($)", xlab="Mileage")

plot of chunk unnamed-chunk-4

Cost and Mileage have a very similar relationship to Cost and Year: as Mileage increases (the car gets older), Cost decreases.

bwplot(Cost~Color, data=cars)

plot of chunk unnamed-chunk-5

Color affects the Cost of a car in that the median cost of Blue and Gray cars is lower than the medium cost of Black and White cars. However, all colors are available within roughly the same ranges of cost.

bwplot(Cost~Model, data=cars)

plot of chunk unnamed-chunk-6

densityplot(~Year, groups=Model, data=cars, auto.key=TRUE)

plot of chunk unnamed-chunk-7

The Model of a car affects the Cost in that models 2.7T and 2.8T have the lowest median cost while models 3.0T and 2.0T have the highest median cost. This appears to be explained by the fact that models 2.7T and 2.8T are model types of older cars, 3.2T and 4.2T are mostly model types of cars of average age, and the greatest number of 3.0T cars are newer cars while 2.0T is a model only found in the newest cars. Thus, Model corresponds to Year.

bwplot(Cost~Zip.Code, data=cars)

plot of chunk unnamed-chunk-8

Boston (02118) and Saint Paul (55105) tend to have slightly cheaper cars than Los Angeles (90210) and Atlanta (30322).

tally(~Color|Zip.Code, data=cars)
##        Zip.Code
## Color    z02118  z30322  z55105  z90210
##   Black 0.38824 0.33333 0.24490 0.38318
##   Blue  0.16471 0.06667 0.18367 0.08411
##   Gray  0.40000 0.41333 0.34694 0.37383
##   White 0.04706 0.18667 0.22449 0.15888
##   Total 1.00000 1.00000 1.00000 1.00000

Each city has roughly the same percentage of cars that are a specific color, although Boston appears to have comparatively fewer White cars, and Atlanta and Los Angeles appear to have comparatively fewer Blue cars.

densityplot(~Year, groups=Color, data=cars, auto.key=TRUE)

plot of chunk unnamed-chunk-10

On average, the distribution of Years for a specific Color are very similar for all colors. However, Black and White are comparatively less frequent for cars of average age (around Year 2005), and Black is much more frequent for newer cars.

This is suprising because we did not expect the frequency of Color to depend on Year. We would have assumed that the preference of some colors over another would be constant and therefore lead to the same distribution by Year for each Color.

Models

Here you'll give a few models, giving the model coefficients and interpreting them using language that might make sense to a well-educated car buyer.

mod1 = lm( Cost ~ Age, data=cars)
coef(mod1)
## (Intercept)         Age 
##       44432       -3726
confint(mod1)
##             2.5 % 97.5 %
## (Intercept) 43552  45313
## Age         -3870  -3582

The average cost of a new car (Year 2013) is $44,432 , and the cost decreases by $3726 for every year older a car is.

mod2 = lm( Cost ~ Mileage, data=cars)
coef(mod2)
## (Intercept)     Mileage 
##  46324.5607     -0.3092
confint(mod2)
##                  2.5 %     97.5 %
## (Intercept) 45137.6911 47511.4302
## Mileage        -0.3245    -0.2939

The average cost of a car driven zero miles is $46324.56. The cost of a car decreases by $0.31 per mile driven.

mod3 = lm( Cost ~ Age+Mileage, data=cars)
coef(mod3)
## (Intercept)         Age     Mileage 
##  45923.9877  -2551.1783     -0.1117
confint(mod3)
##                  2.5 %     97.5 %
## (Intercept) 45057.9351  4.679e+04
## Age         -2851.9676 -2.250e+03
## Mileage        -0.1375 -8.591e-02

The average cost of a new car (Year 2013) with zero miles is $45,923.99 , and the cost decreases by $2551 for every year older the car gets and decreases by $0.11 for every mile it is driven.

mod4 = lm( Cost ~ Zip.Code, data=cars)
coef(mod4)
##    (Intercept) Zip.Codez30322 Zip.Codez55105 
##          22905           7044          -1337 
## Zip.Codez90210 
##           7330
confint(mod4)
##                2.5 % 97.5 %
## (Intercept)    19696  26114
## Zip.Codez30322  2357  11731
## Zip.Codez55105 -6644   3969
## Zip.Codez90210  3032  11629

The average cost of a car in Boston is $22905. The average cost of a car in Atlanta is $29949 ($7044 more than Boston). The average cost of a car in Saint Paul is $21568 ($1337 less than Boston). The average cost of a car in Los Angeles is $30235 ($7330 more than Boston).

mod8=lm(Cost~Mileage*Zip.Code, data=cars)
coef(mod8)
##            (Intercept)                Mileage 
##              4.630e+04             -3.307e-01 
##         Zip.Codez30322         Zip.Codez55105 
##              2.104e+03             -2.376e+03 
##         Zip.Codez90210 Mileage:Zip.Codez30322 
##             -1.528e+02              1.873e-04 
## Mileage:Zip.Codez55105 Mileage:Zip.Codez90210 
##              6.189e-02              2.799e-02
confint(mod8)
##                             2.5 %     97.5 %
## (Intercept)             4.354e+04  4.906e+04
## Mileage                -3.650e-01 -2.964e-01
## Zip.Codez30322         -1.477e+03  5.685e+03
## Zip.Codez55105         -6.720e+03  1.969e+03
## Zip.Codez90210         -3.445e+03  3.139e+03
## Mileage:Zip.Codez30322 -4.684e-02  4.721e-02
## Mileage:Zip.Codez55105  1.325e-02  1.105e-01
## Mileage:Zip.Codez90210 -1.488e-02  7.087e-02
xyplot(Cost~Mileage, groups=Zip.Code, data=cars)
modelvalues=makeFun(mod8)
plotFun(modelvalues(Zip.Code="z55105", Mileage=x)~x, add=TRUE)
plotFun(modelvalues(Zip.Code="z02118", Mileage=x)~x, add=TRUE)
plotFun(modelvalues(Zip.Code="z90210", Mileage=x)~x, add=TRUE)
plotFun(modelvalues(Zip.Code="z30322", Mileage=x)~x, add=TRUE)

plot of chunk unnamed-chunk-15

The average cost of a car with zero miles in Boston is $46,300, and the cost will decrease by $0.33 for every mile driven. The average cost of a car with zero miles in Atlanta is $48,404, and the cost will decreases by $0.33 for every mile driven. The average cost of a car with zero miles in Saint Paul is $43,924, and the cost will decrease by $0.27 for every mile driven. The average cost of a car with zero miles in Los Angeles is $46,147.20, and the cost will decrease by $0.30 f0r every mile driven.

mod5=lm(Cost~Color, data=cars)
coef(mod5)
## (Intercept)   ColorBlue   ColorGray  ColorWhite 
##       30533       -7576       -6719       -1376
confint(mod5)
##              2.5 % 97.5 %
## (Intercept)  27701  33364
## ColorBlue   -13240  -1912
## ColorGray   -10633  -2806
## ColorWhite   -6607   3856

The average cost of a black car is $30533. The average cost of a Blue car is $22957 ($7576 less than a Black car). The average cost of a Gray car is $23814 ($6719 less than a Black car). The average cost of a White car is $29157 ($1376 less than a Black car).

mod6=lm(Year~Color, data=cars)
coef(mod6)
## (Intercept)   ColorBlue   ColorGray  ColorWhite 
##   2009.1532     -1.8559     -1.4564     -0.6314
confint(mod6)
##                2.5 %    97.5 %
## (Intercept) 2008.431 2009.8755
## ColorBlue     -3.301   -0.4112
## ColorGray     -2.455   -0.4582
## ColorWhite    -1.966    0.7030

The average Year for a Black car is 2009. The average Year for a Blue car is 2007. The average Year for a Gray car is halfway between 2007 and 2008. The average Year for a White car is halfway between 2008 and 2009.

mod7=lm(Cost~Age*Color, data=cars)
coef(mod7)
##    (Intercept)            Age      ColorBlue 
##      44666.708      -3674.207       -168.834 
##      ColorGray     ColorWhite  Age:ColorBlue 
##      -1319.469       1159.200       -103.197 
##  Age:ColorGray Age:ColorWhite 
##         -9.153        -47.976
confint(mod7)
##                  2.5 %  97.5 %
## (Intercept)    43295.4 46038.0
## Age            -3932.7 -3415.8
## ColorBlue      -3370.1  3032.5
## ColorGray      -3383.9   745.0
## ColorWhite     -1367.0  3685.4
## Age:ColorBlue   -594.9   388.6
## Age:ColorGray   -359.3   341.0
## Age:ColorWhite  -476.8   380.9

The average cost of a new Black car (Year 2013) is $44,666.71 , and the cost decreases by $3674.21 for every year older the car becomes. The average cost of a new Blue car (Year 2013) is $44,497.88 , and the cost decreases by $3777.41 for every year older the car becomes. The average cost of a new Gray car (Year 2013) is $43,347.24 , and the cost decreases by $3683.36 for every year older the car becomes. The average cost of a new White car (Year 2013) is $43,507.51 , and the cost decreases by $3626.23 for every year older the car becomes.

We did not find any outliers that had a strong influence on our coefficients. When our data was grouped by Zip Code or Color, the 95% confidence intervals showed the model coefficients to be less precise. This could relate to the differing number of cases for each level of these two categories.