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
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.
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.
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.