Electric Vehicle Drive Clean Project 2

Introduction:

For this project I am using the NYSERDA Electric Vehicle Drive Clean Rebate Data: Beginning 2017 data set. The data come from the New York State Energy Research and Development Authority (NYSERDA) and contain completed applications for the Drive Clean Rebate program. The dataset includes information about the vehicle, transaction type, environmental reductions, and rebate amount. The data-set contains 150,328 observations and 11 variables. For this project, I will focus on Annual GHG Emissions Reductions, Annual Petroleum Reductions, EV Type, and Transaction Type. I chose this topic because electric vehicles can reduce the amount of gasoline and other petroleum products used for transportation. They can also reduce greenhouse-gas emissions compared with traditional gasoline-powered vehicles.

My research question: How is annual petroleum reduction related to annual greenhouse-gas reduction between electrical vehicles receiving a NYSERDA rebate and does the relationship differ by EV type and transaction type.

“Electric car charging,” photograph by Ivan Radic, Wikimedia Commons, CC BY 2.0, 10 December 2020

Loading Libraries:

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(plotly)

Attaching package: 'plotly'

The following object is masked from 'package:ggplot2':

    last_plot

The following object is masked from 'package:stats':

    filter

The following object is masked from 'package:graphics':

    layout

Loading Data Set:

ev_data <- readr::read_csv( "Electric_Vehicle_Drive_Clean_Rebate_2017NYSERDA.csv")
Rows: 150328 Columns: 11
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (7): Data through Date, Submitted Date, Make, Model, County, EV Type, Tr...
dbl (4): ZIP, Annual GHG Emissions Reductions (MT CO2e), Annual Petroleum Re...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(ev_data)
# A tibble: 6 × 11
  `Data through Date` `Submitted Date` Make      Model    County   ZIP `EV Type`
  <chr>               <chr>            <chr>     <chr>    <chr>  <dbl> <chr>    
1 4/30/2024           5/28/2020        Tesla     Model Y  <NA>   10509 BEV      
2 4/30/2024           8/30/2023        Chevrolet Bolt     <NA>      NA BEV      
3 4/30/2024           11/8/2023        Jeep      Grand C… <NA>   13647 PHEV     
4 4/30/2024           4/4/2024         Toyota    Prius P… <NA>   12922 PHEV     
5 4/30/2024           3/30/2017        Audi      A3 e-tr… Albany 12189 PHEV     
6 4/30/2024           3/30/2017        Toyota    Prius P… Albany 12211 PHEV     
# ℹ 4 more variables: `Transaction Type` <chr>,
#   `Annual GHG Emissions Reductions (MT CO2e)` <dbl>,
#   `Annual Petroleum Reductions (gallons)` <dbl>, `Rebate Amount (USD)` <dbl>

Data Cleaning:

I will clean the data by removing variables I am not using. I will check for missing observations in the new cleaned data set and remove missing observation for variables that are needed for my analysis. Lastly I will use function mutate to create shorter names for the variables so they are easier to use.

ev_clean <- ev_data |>
  select(
    `Annual GHG Emissions Reductions (MT CO2e)`,
    `Annual Petroleum Reductions (gallons)`,
    `EV Type`,
    `Transaction Type`,
    `Rebate Amount (USD)`
  )
colSums(is.na(ev_clean))
Annual GHG Emissions Reductions (MT CO2e) 
                                        0 
    Annual Petroleum Reductions (gallons) 
                                        0 
                                  EV Type 
                                        0 
                         Transaction Type 
                                        4 
                      Rebate Amount (USD) 
                                        0 
ev_clean <- ev_clean |>
  filter(
    !is.na(`Annual GHG Emissions Reductions (MT CO2e)`),
    !is.na(`Annual Petroleum Reductions (gallons)`),
    !is.na(`EV Type`),
    !is.na(`Transaction Type`)
  )
ev_clean <- ev_clean |>
  mutate(
    GHG = `Annual GHG Emissions Reductions (MT CO2e)`,
    Petroleum = `Annual Petroleum Reductions (gallons)`,
    EV_Type = `EV Type`,
    Transaction = `Transaction Type`,
    Rebate = `Rebate Amount (USD)`
  )
names(ev_clean)
 [1] "Annual GHG Emissions Reductions (MT CO2e)"
 [2] "Annual Petroleum Reductions (gallons)"    
 [3] "EV Type"                                  
 [4] "Transaction Type"                         
 [5] "Rebate Amount (USD)"                      
 [6] "GHG"                                      
 [7] "Petroleum"                                
 [8] "EV_Type"                                  
 [9] "Transaction"                              
[10] "Rebate"                                   

Multiple Linear Regression:

I will use a multiple linear regression to examine whether annual GHG emissions reductions are related to annual petroleum reductions.

ev_model <- lm(
  Petroleum ~ GHG + EV_Type + Transaction,
  data = ev_clean
)

summary(ev_model)

Call:
lm(formula = Petroleum ~ GHG + EV_Type + Transaction, data = ev_clean)

Residuals:
     Min       1Q   Median       3Q      Max 
-165.061  -20.806   -9.009   15.800  188.063 

Coefficients:
                     Estimate Std. Error  t value Pr(>|t|)    
(Intercept)          351.7151     0.3169 1109.718  < 2e-16 ***
GHG                   82.6959     0.1034  799.770  < 2e-16 ***
EV_TypePHEV         -120.8551     0.2190 -551.905  < 2e-16 ***
TransactionPurchase    0.6073     0.1906    3.186  0.00144 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 33.12 on 150320 degrees of freedom
Multiple R-squared:  0.939, Adjusted R-squared:  0.939 
F-statistic: 7.712e+05 on 3 and 150320 DF,  p-value: < 2.2e-16

Results and Diagnostic Plots:

The estimated regression equation is:

Petroleum = 351.715 + 82.696(GHG) - 120.855(PHEV) + 0.607(Purchase)

The model has an ajusted R-squared of 0.939. This means that approximately 93.9% of the variation in annual petroleum reductions is explained by GHG emissions reductions, EV type, and transaction type. Annual GHG emissions reductions was statistically significant it had a p-value of less than 2 × 10⁻¹⁶. The positive coefficient of 82.696 shows that higher annual GHG reductions are associated with higher annual petroleum reductions. EV type was also statistically significant, with a p-value of less than 2 × 10⁻¹⁶. The coefficient for PHEVs was −120.855, so after accounting for GHG reductions and transaction type, PHEVs had an estimated petroleum reduction about 120.855 gallons lower than the reference group BEVs. Transaction type was also statistically significant, with a p-value of 0.00144. The coefficient for purchases was 0.607, showing that purchases had a slightly higher predicted petroleum reduction than the reference group, leases, after accounting for the other variables. I created a residuals vs. Fitted values plot to check whether the residual are spread randomly around zero. Then I also created an Q-Q plot, this helped determine if the residuals are approximately normally distributed. Overall, the regression results provide strong evidence that GHG emissions reductions, EV type, and transaction type are associated with annual petroleum reductions.

Final Visualization 1:

The first visualization I am making is going to compare the average annual petroleum reduction across EV type and transaction type. Before making th visualization I will calculate the average petroleum reduction for each EV type and transaction type. The visualazation is going to be a bar chart and the colors represent the four EV and transaction groups. The different colors make it easier to compare REVs and PHEV as well as purchases and leases. The visualizations shows that the average petroleum reduction differs across these groups.

ev_type_summary <- ev_clean |>
  group_by(EV_Type, Transaction) |>
  summarize(
    Average_Petroleum = mean(Petroleum),
    .groups = "drop"
  ) |>
  mutate(
    Group = paste(EV_Type, Transaction, sep = " - ")
  )
ggplot(
  ev_type_summary,
  aes(
    x = Group,
    y = Average_Petroleum,
    fill = Group
  )
) +
  geom_col() +
  scale_fill_manual(
    values = c(
      "BEV - Lease" = "lightgrey",
      "BEV - Purchase" = "skyblue",
      "PHEV - Lease" = "lightpink",
      "PHEV - Purchase" = "forestgreen"
    )
  ) +
  labs(
    title = "Average Annual Petroleum Reduction by EV and Transaction Type",
    x = "Electric Vehicle and Transaction Type",
    y = "Average Annual Petroleum Reduction (gallons)",
    fill = "EV / Transaction",
    caption = "Source: NYSERDA Electric Vehicle Drive Clean Rebate Data: Beginning 2017"
  ) +
  annotate(
    "text",
    x = 2,
    y = max(ev_type_summary$Average_Petroleum) * 0.8,
    label = "Compare EV and transaction groups"
  ) +
  theme_minimal()

Final Visualization 2:

The second visualization examines the relationship between annual GHG reductions ans annual petroleum reductions. This visualization is going to be a scatter plot. First I will created a group that combines EV type and transaction type. The scatter plot shows a positive relationship between annual GHG emissions reductions and annual petroleum reductions.

ev_plot_data <- ev_clean |>
  mutate(
    Group = paste(EV_Type, Transaction, sep = " - ")
  )
ev_plot <- ggplot(
  ev_plot_data,
  aes(
    x = GHG,
    y = Petroleum,
    color = Group,
    shape = Transaction
  )
) +
  geom_point(alpha = 0.5) +
  scale_color_manual(
    values = c(
      "BEV - Lease" = "lightgrey",
      "BEV - Purchase" = "skyblue",
      "PHEV - Lease" = "lightpink",
      "PHEV - Purchase" = "forestgreen"
    )
  ) +
  labs(
    title = "Relationship Between Annual GHG and Petroleum Reductions",
    x = "Annual GHG Emissions Reduction (MT CO2e)",
    y = "Annual Petroleum Reduction (gallons)",
    color = "EV / Transaction",
    shape = "Transaction Type",
    caption = "Source: NYSERDA Electric Vehicle Drive Clean Rebate Data: Beginning 2017"
  ) +
  annotate(
    "text",
     x = 2.5,
     y = 500,
     label = "Positive relationship"
  ) +
  theme_minimal()
ggplotly(ev_plot)

Conclusion:

My project examined data from the NYSERDA Drive Clean Rebate program to study environmental reductions associated with electric vehicles. The project focused on annual GHG emissions reductions, annual petroleum reductions, EV type, and transaction type. The first visualization compared average petroleum reductions across EV and transaction groups. The second visualization showed the relationship between GHG reductions and petroleum reductions. The multiple linear regression found a statistically significant relationship between GHG reductions and petroleum reductions. The model had an adjusted R-squared of approximately 0.939, meaning that the variables included in the model explained a large amount of the variation in annual petroleum reductions. One interesting finding was that EV type was also statistically significant. With more time, I would examine how these environmental reductions changed over time. I would also investigate individual vehicle makes and models to determine whether certain vehicles had higher estimated environmental reductions than others.