Used-Car Prices

Group Members: Emily Walls, Lucius Wilmerding, Jack Struble, Samantha Stein

Introduction

We decided to look at the Mazda Miata MX-5, a sports car. We considered the price, mileage, year, colour, location,

Reading in the Spreadsheet

You'll be reading in your spreadsheet from Google Docs. This example is based on the data provided as part of the mosaic package, but copied over to Google Docs just to show how to read in from a spreadsheet. Of course, you'll be setting up your own Google Doc and getting the public link to it to read in with fetchGoogle per these instructions.

Remember … you need to change the name of the data source to that for your own Google spreadsheet.

dataSource = "https://docs.google.com/spreadsheet/pub?key=0AjNaY1Hr4CxSdDNBVkthR3hRSEp4dERjSnVkSC1rSlE&single=true&gid=0&output=csv"
cars = fetchGoogle(dataSource)

Description of Data

Density plots, scatter plots, etc. Whatever you think is informative.

xyplot(Price~ModelYear, data=cars, 
       ylab="Price ($)", xlab="Age (yrs)")

plot of chunk unnamed-chunk-3

This shows the general correlation between price and age; i.e. price decreases as model year decreases. That is to say, older cars' prices tend to be lower than newers.

densityplot(~Mileage, data=cars)

plot of chunk unnamed-chunk-4

The mileage graph shows us that the mileage of the cars tends towards the 0-50000 interval. The density of the cars with mileage above 50000 becomes less and less.

densityplot(~Price, data = cars)

plot of chunk unnamed-chunk-5

The price density diagram shows a bimodal distribution. The two peaks occur around $6000 and $19000.

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( Price ~ ModelYear, data=cars)
coef(mod1)
## (Intercept)   ModelYear 
##    -2166661        1087

The intercept tells us the value of a model year 0 Mazda Miata MX-5. This value is extremely negative and not of much practical use. The second term tells us how much value each subsequent year adds to the car, specifically 1087 dollars per year. This means that a 2000 Miata will be worth $1087 more than a 1999 Miata according to our model.

mod2=lm(Price~Mileage, data = cars)
coef(mod2)
## (Intercept)     Mileage 
##  20339.6264     -0.1285

The intercept tells us the value of a brand-new (0 miles) Mazda Miata MX-5. This value is of much practical use in that it is what we would expect to pay for a new Miata. The second term tells us how much value each subsequent mile subtracts from the car, specifically 12.85 cents per mile driven. This means that a Miata with 100 miles on it will be worth $12.85 less than a Miata never driven (0 miles) according to our model.

mod3=lm(Price~Location, data = cars)
coef(mod3)
##          (Intercept)    LocationMontclair 
##              17329.0              -5559.2 
## LocationPhiladelphia LocationPoughkeepsie 
##             -10911.9                696.7 
##    LocationPrinceton     LocationSt. Paul 
##              -3330.9              -4603.4

This value tells us how cars values would be expected to vary based on the state or city you are purchasing them in. The intercept and default price is Boston, where you would expect to pay an average of $17329 for a Mazda Miata. Other locations' coefficients add or subtract from this average; Montclair subtracts $5559.20, meaning that you would expect to pay $5559.20 less in Montclair than in Boston, on average. Philadelphia subtracts a whopping $10911.90 from the average value, Poughkeepsie adds $696.70, Princeton subtracts $3330.90, and St. Paul subtracts $4603.40.

mod4=lm(Price~Location + Mileage, data = cars)
coef(mod4)
##          (Intercept)    LocationMontclair 
##           21752.8969           -4639.6789 
## LocationPhiladelphia LocationPoughkeepsie 
##           -2763.9534            -234.8621 
##    LocationPrinceton     LocationSt. Paul 
##            -334.4072           -3583.6245 
##              Mileage 
##              -0.1227

The model shows the amount one would expect to pay for cars in various states and cities based on their mileage. The intercept reflects the expected price of a new car (0 miles) in Boston. The mileage coefficient tells us that each mile driven regardless of location subtracts 12.27 cents from the expected value. The various locations' coefficients show how much purchasing the car in each city would be expected to change the average value of the car. Philadelphia reduces the expected amount by $2763.95, Montclair reduces it by $4639.68, Princeton reduces it by $334.41, Poughkeepsie reduces it by $234.86, and St. Paul reduces it by $3583.62.