$CO_2$ emissions

Estimation of carbon-dioxyde emission of motor vehicles

Alexey N
Enterpreneur

Know emissions level

Almost any modern car is rather утмшкщтьуте friendly, though emissions level may vary dependent on certain parameters, such as engine power, transmission type or its class.

The data was obtained from http://parkers.co.uk database and consists of 65 records.

The model

Algorithm is just a plain linear model with various number of predictors of your choice. It is built on the fly using eval and parse functions like this:

build.lm <- function(outcome = "CO2.Emissions", predictors = NULL) {
    lm.expr <- "lm(CO2.Emissions ~ "
    if (is.null(predictors) | length(predictors) == 0) return(NULL)
    for (i in 1:length(predictors))
        if (i != 1)
            lm.expr <- paste(lm.expr, predictors[i], sep = " + ")
        else
            lm.expr <- paste(lm.expr, predictors[i], sep = "")
        lm.expr <- paste(lm.expr, ", data = cars)", sep = "")
        eval(parse(text = lm.expr))
}

Inputs

You should choose at least one predictor to build the model. Of course, you may select them all, or try only several of your choice.

Although the cars.csv table has more than 20 fields, we use just four, since those are most influent, and anova test says they're ok (p-values are almost zero).

## Analysis of Variance Table
## 
## Model 1: CO2.Emissions ~ Brand
## Model 2: CO2.Emissions ~ Brand + Top.Speed
## Model 3: CO2.Emissions ~ Brand + Top.Speed + Power.Output
##   Res.Df     RSS Df Sum of Sq       F    Pr(>F)    
## 1     36 28948.5                                   
## 2     35 15079.5  1     13869 102.826 8.155e-12 ***
## 3     34  4585.9  1     10494  77.801 2.619e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Outputs

You'll get an estimate of emissions level based on the parameters you chose, and some additional info, like vehicle names with similar \(CO_2\) emission level.

Let's suppose estimated emission level is 120.

co2.cache <- 120
select.expr <- paste0("cars[cars$CO2.Emissions > ", co2.cache - 2,
    " & cars$CO2.Emissions <", co2.cache + 2, 
    ", c('Brand', 'Model.Name', 'CO2.Emissions')]")
eval(parse(text = select.expr))
##         Brand Model.Name CO2.Emissions
## 3  Volkswagen     Touran           121
## 8       Mazda       CX-5           119
## 11 Volkswagen     Passat           119
## 14 Volkswagen     Passat           120
## 26    Hyundai        i20           119
## 48 Volkswagen   Scirocco           119
## 64    Peugeot        508           119