Is there a significant difference in average highway miles per gallon (MPG) among different car manufacturers?
Throughout the whole existence of the world, there has always been a need for transportation to get from one place to another. Some of the older methods included traveling by foot, riding animals, or using wagons and carriages. But in 1886, the Benz Patent-Motorwagen designed by Karl Benz became the first modern motorcar. With a top speed of ten miles per hour, it started the beginning of automobile innovations that soon became a popular trend and made transportation much faster and easier compared to traditional methods.
Many different countries have their own car manufacturers, such as Germany’s BMW and Volkswagen, Japan’s Toyota and Honda, and the United States’ Chevrolet and Ford. Ever since 1886, cars have required gasoline to power their engines. Gasoline comes from refined crude oil (a fossil fuel), and when mixed with air, it becomes a combustible mixture that makes the car run. So overall, without gas, an internal combustion engine (ICE) is worthless. Different manufacturers’ vehicles have different miles per gallon depending on engine size, weight, and technology. This led me to my main question: “Is there a significant difference in average highway miles per gallon (MPG) among different car manufacturers?”
The U.S. Environmental Protection Agency (EPA) is a government agency that tests cars using a dynamometer to estimate how many miles a car can drive on one gallon of gasoline (MPG), both in the city and on the highway. The EPA also rates each vehicle’s fuel economy and emissions. The dataset I’m using to answer my question is called “epa2021” which comes from fueleconomy.gov, provided by the EPA and posted on OpenIntro. “epa2021” contains cars made in 2021 and their fuel-economy data. My dataset has 1,108 observations and 28 variables. The variables I am focusing on are “mfr_name”which is the manufacturer name, and “hwy_mpg”, which represents how many miles per gallon the car can achieve on the highway.
The reason why I chose this topic is because ever since I was a little kid, I would always look out the car window and stare at all the luxury cars that I could only dream of driving one day. In my free time during the summer, when the weather is nice, I go to car meets and just admire the beauty of different car models. Even though I’m not very knowledgeable yet about the internal workings of a car, I still admire the exterior. My dad, on the other hand, taught himself how to fix cars in his free time and understands how everything works on the inside. I hope I can eventually reach that level of knowledge too. So when I found this dataset, I knew it would be the best option for my final project for this class, since it includes the specifications of each car model and gives me the chance to learn more about cars.
For this project, I started my data analysis by opening the libraries I needed, importing my dataset, and then getting the names of the columns in my dataset so I could get an overview of it. I then created a new dataset called cars and used the function select() to choose the variables that I would be using to answer my research question. After creating the new dataset, I checked if there were any NA values in it using the colSums(is.na()) function, and to my luck, there weren’t any.
Next, I used summary() to get the five-number summary for my highway miles per gallon in order to gain some initial insight into the data. I then renamed my variables so they would be clearer to both me and the audience, for example, I changed “hwy_mpg” to “highway_mpg.”
After that, I used the function count() and sort = TRUE to see how many cars each manufacturer has in this dataset in descending order. I did this to check whether any manufacturer had a noticeably larger number of vehicles in the dataset, which could influence the comparison of average highway MPG. Then I used unique() to see all the different possible highway MPG values.
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 4.0.0 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.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(RColorBrewer)
epa <- read.csv('epa2021.csv')
colnames(epa)
## [1] "model_yr" "mfr_name" "division"
## [4] "carline" "mfr_code" "model_type_index"
## [7] "engine_displacement" "no_cylinders" "transmission_speed"
## [10] "city_mpg" "hwy_mpg" "comb_mpg"
## [13] "guzzler" "air_aspir_method" "air_aspir_method_desc"
## [16] "transmission" "transmission_desc" "no_gears"
## [19] "trans_lockup" "trans_creeper_gear" "drive_sys"
## [22] "drive_desc" "fuel_usage" "fuel_usage_desc"
## [25] "class" "car_truck" "release_date"
## [28] "fuel_cell"
cars <- epa |>
select(mfr_name,hwy_mpg)
head(cars)
## mfr_name hwy_mpg
## 1 Honda 22
## 2 aston martin 21
## 3 aston martin 24
## 4 Volkswagen Group of 20
## 5 Volkswagen Group of 23
## 6 Volkswagen Group of 20
colSums(is.na(cars))
## mfr_name hwy_mpg
## 0 0
summary(cars)
## mfr_name hwy_mpg
## Length:1108 Min. :13.0
## Class :character 1st Qu.:23.0
## Mode :character Median :27.0
## Mean :27.3
## 3rd Qu.:31.0
## Max. :60.0
cars1 <- cars |>
rename(car_make = mfr_name,
highway_mpg = hwy_mpg)
head(cars1)
## car_make highway_mpg
## 1 Honda 22
## 2 aston martin 21
## 3 aston martin 24
## 4 Volkswagen Group of 20
## 5 Volkswagen Group of 23
## 6 Volkswagen Group of 20
cars1 |>
count(car_make, sort = TRUE)
## car_make n
## 1 General Motors 182
## 2 BMW 110
## 3 Toyota 96
## 4 FCA US LLC 89
## 5 Mercedes-Benz 84
## 6 Volkswagen Group of 84
## 7 Ford Motor Company 80
## 8 Porsche 63
## 9 Hyundai 55
## 10 Nissan 48
## 11 Honda 39
## 12 Kia 36
## 13 Jaguar Land Rover L 32
## 14 MAZDA 29
## 15 Subaru 20
## 16 Volvo 17
## 17 Maserati 11
## 18 Rolls-Royce 10
## 19 Mitsubishi Motors Co 8
## 20 Ferrari 7
## 21 aston martin 6
## 22 Lotus 2
unique(cars1$highway_mpg)
## [1] 22 21 24 20 23 31 30 32 14 13 27 15 16 18 19 26 35 34 25 37 33 28 29 38 36
## [26] 45 41 39 40 43 52 42 49 56 44 53 47 50 48 60 51 54 46 17
For my question comparing the means of a quantitative variable such as highway_mpg across different car manufacturers (categorical variable) like Honda, Aston Martin, and BMW, I will use an ANOVA statistical analysis. The Analysis of Variance (ANOVA) test determines whether the differences in averages are statistically significant and examines the relationship between a categorical variable and a quantitative variable.
I will first use the aov() function to obtain the sums of squares and degrees of freedom. Then I will use the summary() function on my ANOVA results to get the p-value and determine whether I should reject or fail to reject my null hypothesis. After that, I will use Tukey’s Honestly Significant Difference (HSD) test to see the differences in means between highway MPG and car manufacturers, along with the confidence interval bounds and p-values.
Finally, I am going to create a boxplot so I can visually compare the different car manufacturers and see how their average highway MPG values compare to one another.
\(H_0\): \(\mu_A\) = \(\mu_B\) = \(\mu_C\)
\(H_a\): not all \(\mu_i\) are equal
anova_result <- aov(highway_mpg ~ car_make, data = cars1)
anova_result
## Call:
## aov(formula = highway_mpg ~ car_make, data = cars1)
##
## Terms:
## car_make Residuals
## Sum of Squares 12891.39 32741.92
## Deg. of Freedom 21 1086
##
## Residual standard error: 5.49082
## Estimated effects may be unbalanced
summary(anova_result)
## Df Sum Sq Mean Sq F value Pr(>F)
## car_make 21 12891 613.9 20.36 <2e-16 ***
## Residuals 1086 32742 30.1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The p-value is extremely small 0.0000000000000002, indicating strong evidence against the null hypothesis. Overall, this test suggests that there are significant differences in highway miles per gallon among different car manufacturers.
TukeyHSD(anova_result)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = highway_mpg ~ car_make, data = cars1)
##
## $car_make
## diff lwr upr
## BMW-aston martin 6.64848485 -1.643494554 14.9404643
## FCA US LLC-aston martin 3.50374532 -4.838680661 11.8461713
## Ferrari-aston martin -2.54761905 -13.551559176 8.4563211
## Ford Motor Company-aston martin 3.90416667 -4.467844419 12.2761778
## General Motors-aston martin 2.66666667 -5.540037781 10.8733711
## Honda-aston martin 10.91025641 2.236653893 19.5838589
## Hyundai-aston martin 10.89393939 2.390215800 19.3976630
## Jaguar Land Rover L-aston martin 1.85416667 -6.945016775 10.6533501
## Kia-aston martin 10.44444444 1.722788360 19.1661005
## Lotus-aston martin 3.16666667 -12.982702346 19.3160357
## Maserati-aston martin 0.53030303 -9.507846962 10.5684530
## MAZDA-aston martin 10.61494253 1.744187506 19.4856976
## Mercedes-Benz-aston martin 4.33333333 -4.024759187 12.6914259
## Mitsubishi Motors Co-aston martin 13.29166667 2.609863107 23.9734702
## Nissan-aston martin 7.33333333 -1.231162922 15.8978296
## Porsche-aston martin 1.37301587 -7.077434065 9.8234658
## Rolls-Royce-aston martin -2.83333333 -13.047091104 7.3804244
## Subaru-aston martin 9.16666667 -0.039890173 18.3732235
## Toyota-aston martin 9.72916667 1.405972388 18.0523609
## Volkswagen Group of-aston martin 3.64285714 -4.715235378 12.0009497
## Volvo-aston martin 8.93137255 -0.460777450 18.3235225
## FCA US LLC-BMW -3.14473953 -5.964656883 -0.3248222
## Ferrari-BMW -9.19610390 -16.906004090 -1.4862037
## Ford Motor Company-BMW -2.74431818 -5.650592821 0.1619565
## General Motors-BMW -3.98181818 -6.370512502 -1.5931239
## Honda-BMW 4.26177156 0.575683759 7.9478594
## Hyundai-BMW 4.24545455 0.979083835 7.5118253
## Jaguar Land Rover L-BMW -4.79431818 -8.766910772 -0.8217256
## Kia-BMW 3.79595960 -0.001822325 7.5937415
## Lotus-BMW -3.48181818 -17.594152580 10.6305162
## Maserati-BMW -6.11818182 -12.372805542 0.1364419
## MAZDA-BMW 3.96645768 -0.162241551 8.0951569
## Mercedes-Benz-BMW -2.31515152 -5.181084739 0.5507817
## Mitsubishi Motors Co-BMW 6.64318182 -0.599524164 13.8858878
## Nissan-BMW 0.68484848 -2.736621780 4.1063187
## Porsche-BMW -5.27546898 -8.400523665 -2.1504143
## Rolls-Royce-BMW -9.48181818 -16.014559602 -2.9490768
## Subaru-BMW 2.51818182 -2.289785684 7.3261493
## Toyota-BMW 3.08068182 0.318178306 5.8431853
## Volkswagen Group of-BMW -3.00562771 -5.871560930 -0.1396945
## Volvo-BMW 2.28288770 -2.871561277 7.4373367
## Ferrari-FCA US LLC -6.05136437 -13.815494054 1.7127653
## Ford Motor Company-FCA US LLC 0.40042135 -2.646803796 3.4476465
## General Motors-FCA US LLC -0.83707865 -3.395400242 1.7212429
## Honda-FCA US LLC 7.40651109 3.608302028 11.2047202
## Hyundai-FCA US LLC 7.39019408 3.997801643 10.7825865
## Jaguar Land Rover L-FCA US LLC -1.64957865 -5.726420652 2.4272633
## Kia-FCA US LLC 6.94069913 3.034000223 10.8473980
## Lotus-FCA US LLC -0.33707865 -14.479112840 13.8049555
## Maserati-FCA US LLC -2.97344229 -9.294792360 3.3479078
## MAZDA-FCA US LLC 7.11119721 2.882094925 11.3402995
## Mercedes-Benz-FCA US LLC 0.82958801 -2.179186162 3.8383622
## Mitsubishi Motors Co-FCA US LLC 9.78792135 2.487514596 17.0883281
## Nissan-FCA US LLC 3.82958801 0.287610096 7.3715659
## Porsche-FCA US LLC -2.13072945 -5.387279094 1.1258202
## Rolls-Royce-FCA US LLC -6.33707865 -12.933733809 0.2595765
## Subaru-FCA US LLC 5.66292135 0.768465270 10.5573774
## Toyota-FCA US LLC 6.22542135 3.314996215 9.1358465
## Volkswagen Group of-FCA US LLC 0.13911182 -2.869662352 3.1478860
## Volvo-FCA US LLC 5.42762723 0.192410610 10.6628439
## Ford Motor Company-Ferrari 6.45178571 -1.344123996 14.2476954
## General Motors-Ferrari 5.21428571 -2.403826682 12.8323981
## Honda-Ferrari 13.45787546 5.338945774 21.5768051
## Hyundai-Ferrari 13.44155844 5.504370429 21.3787465
## Jaguar Land Rover L-Ferrari 4.40178571 -3.851169382 12.6547408
## Kia-Ferrari 12.99206349 4.821817263 21.1623097
## Lotus-Ferrari 5.71428571 -10.144079842 21.5726513
## Maserati-Ferrari 3.07792208 -6.485032165 12.6408763
## MAZDA-Ferrari 13.16256158 4.833339928 21.4917832
## Mercedes-Benz-Ferrari 6.88095238 -0.900008304 14.6619131
## Mitsubishi Motors Co-Ferrari 15.83928571 5.602754765 26.0758167
## Nissan-Ferrari 9.88095238 1.878688032 17.8832167
## Porsche-Ferrari 3.92063492 -3.959450278 11.8007201
## Rolls-Royce-Ferrari -0.28571429 -10.032841370 9.4614128
## Subaru-Ferrari 11.71428571 3.028301174 20.4002703
## Toyota-Ferrari 12.27678571 4.533323854 20.0202476
## Volkswagen Group of-Ferrari 6.19047619 -1.590484494 13.9714369
## Volvo-Ferrari 11.47899160 2.596530215 20.3614530
## General Motors-Ford Motor Company -1.23750000 -3.890707071 1.4157071
## Honda-Ford Motor Company 7.00608974 3.143332892 10.8688466
## Hyundai-Ford Motor Company 6.98977273 3.525263409 10.4542820
## Jaguar Land Rover L-Ford Motor Company -2.05000000 -6.187044729 2.0870447
## Kia-Ford Motor Company 6.54027778 2.570794849 10.5097607
## Lotus-Ford Motor Company -0.73750000 -14.897006679 13.4220067
## Maserati-Ford Motor Company -3.37386364 -9.734206798 2.9864795
## MAZDA-Ford Motor Company 6.71077586 2.423608435 10.9979433
## Mercedes-Benz-Ford Motor Company 0.42916667 -2.660691008 3.5190243
## Mitsubishi Motors Co-Ford Motor Company 9.38750000 2.053303578 16.7216964
## Nissan-Ford Motor Company 3.42916667 -0.181942024 7.0402754
## Porsche-Ford Motor Company -2.53115079 -5.862759116 0.8004575
## Rolls-Royce-Ford Motor Company -6.73750000 -13.371530273 -0.1034697
## Subaru-Ford Motor Company 5.26250000 0.317785781 10.2072142
## Toyota-Ford Motor Company 5.82500000 2.830826849 8.8191732
## Volkswagen Group of-Ford Motor Company -0.26130952 -3.351167198 2.8285482
## Volvo-Ford Motor Company 5.02720588 -0.255027685 10.3094394
## Honda-General Motors 8.24358974 4.753558402 11.7336211
## Hyundai-General Motors 8.22727273 5.183877732 11.2706677
## Jaguar Land Rover L-General Motors -0.81250000 -4.603880668 2.9788807
## Kia-General Motors 7.77777778 4.169977479 11.3855781
## Lotus-General Motors 0.50000000 -13.562398716 14.5623987
## Maserati-General Motors -2.13636364 -8.277486775 4.0047595
## MAZDA-General Motors 7.94827586 3.993628871 11.9029229
## Mercedes-Benz-General Motors 1.66666667 -0.942288819 4.2756222
## Mitsubishi Motors Co-General Motors 10.62500000 3.480081146 17.7699189
## Nissan-General Motors 4.66666667 1.457377921 7.8759554
## Porsche-General Motors -1.29365079 -4.184851633 1.5975500
## Rolls-Royce-General Motors -5.50000000 -11.924156438 0.9241564
## Subaru-General Motors 6.50000000 1.840640926 11.1593591
## Toyota-General Motors 7.06250000 4.567604985 9.5573950
## Volkswagen Group of-General Motors 0.97619048 -1.632765009 3.5851460
## Volvo-General Motors 6.26470588 1.248589881 11.2808219
## Hyundai-Honda -0.01631702 -4.156804407 4.1241704
## Jaguar Land Rover L-Honda -9.05608974 -13.773710977 -4.3384685
## Kia-Honda -0.46581197 -5.037201878 4.1055779
## Lotus-Honda -7.74358974 -22.083479575 6.5963001
## Maserati-Honda -10.37995338 -17.132343782 -3.6275630
## MAZDA-Honda -0.29531388 -5.145119605 4.5544918
## Mercedes-Benz-Honda -6.57692308 -10.409419842 -2.7444263
## Mitsubishi Motors Co-Honda 2.38141026 -5.295258823 10.0580793
## Nissan-Honda -3.57692308 -7.840831728 0.6869856
## Porsche-Honda -9.53724054 -13.567181607 -5.5072995
## Rolls-Royce-Honda -13.74358974 -20.754379191 -6.7328003
## Subaru-Honda -1.74358974 -7.183351661 3.6961722
## Toyota-Honda -1.18108974 -4.936869805 2.5746903
## Volkswagen Group of-Honda -7.26739927 -11.099896033 -3.4349025
## Volvo-Honda -1.97888386 -7.727170778 3.7694031
## Jaguar Land Rover L-Hyundai -9.03977273 -13.437258876 -4.6422866
## Kia-Hyundai -0.44949495 -4.689723724 3.7907338
## Lotus-Hyundai -7.72727273 -21.965052565 6.5105071
## Maserati-Hyundai -10.36363636 -16.896377784 -3.8308949
## MAZDA-Hyundai -0.27899687 -4.818000047 4.2600063
## Mercedes-Benz-Hyundai -6.56060606 -9.991344434 -3.1298677
## Mitsubishi Motors Co-Hyundai 2.39772727 -5.086468241 9.8819228
## Nissan-Hyundai -3.56060606 -7.467375994 0.3461639
## Porsche-Hyundai -9.52092352 -13.170904254 -5.8709428
## Rolls-Royce-Hyundai -13.72727273 -20.526765576 -6.9277799
## Subaru-Hyundai -1.72727273 -6.891858291 3.4373128
## Toyota-Hyundai -1.16477273 -4.509592333 2.1800469
## Volkswagen Group of-Hyundai -7.25108225 -10.681820624 -3.8203439
## Volvo-Hyundai -1.96256684 -7.451167468 3.5260338
## Kia-Jaguar Land Rover L 8.59027778 3.784879321 13.3956762
## Lotus-Jaguar Land Rover L 1.31250000 -13.103695372 15.7286954
## Maserati-Jaguar Land Rover L -1.32386364 -8.236824271 5.5890970
## MAZDA-Jaguar Land Rover L 8.76077586 3.689793299 13.8317584
## Mercedes-Benz-Jaguar Land Rover L 2.47916667 -1.629638520 6.5879719
## Mitsubishi Motors Co-Jaguar Land Rover L 11.43750000 3.619220345 19.2557797
## Nissan-Jaguar Land Rover L 5.47916667 0.965280803 9.9930525
## Porsche-Jaguar Land Rover L -0.48115079 -4.774712675 3.8124111
## Rolls-Royce-Jaguar Land Rover L -4.68750000 -11.853071665 2.4780717
## Subaru-Jaguar Land Rover L 7.31250000 1.674658364 12.9503416
## Toyota-Jaguar Land Rover L 7.87500000 3.837657747 11.9123423
## Volkswagen Group of-Jaguar Land Rover L 1.78869048 -2.320114710 5.8974957
## Volvo-Jaguar Land Rover L 7.07720588 1.141125435 13.0132863
## Lotus-Kia -7.27777778 -21.646784167 7.0912286
## Maserati-Kia -9.91414141 -16.728147605 -3.1001352
## MAZDA-Kia 0.17049808 -4.764734411 5.1057306
## Mercedes-Benz-Kia -6.11111111 -10.051153711 -2.1710685
## Mitsubishi Motors Co-Kia 2.84722222 -4.883699611 10.5781441
## Nissan-Kia -3.11111111 -7.471939153 1.2497169
## Porsche-Kia -9.07142857 -13.203780112 -4.9390770
## Rolls-Royce-Kia -13.27777778 -20.347931447 -6.2076241
## Subaru-Kia -1.27777778 -6.793837417 4.2382819
## Toyota-Kia -0.71527778 -4.580738694 3.1501831
## Volkswagen Group of-Kia -6.80158730 -10.741629901 -2.8615447
## Volvo-Kia -1.51307190 -7.333613683 4.3074699
## Maserati-Lotus -2.63636364 -17.840491860 12.5677646
## MAZDA-Lotus 7.44827586 -7.011715647 21.9082674
## Mercedes-Benz-Lotus 1.16666667 -12.984614913 15.3179482
## Mitsubishi Motors Co-Lotus 10.12500000 -5.511559310 25.7615593
## Nissan-Lotus 4.16666667 -10.107493760 18.4408271
## Porsche-Lotus -1.79365079 -15.999676414 12.4123748
## Rolls-Royce-Lotus -6.00000000 -21.320636657 9.3206367
## Subaru-Lotus 6.00000000 -8.668392843 20.6683928
## Toyota-Lotus 6.56250000 -7.568197886 20.6931979
## Volkswagen Group of-Lotus 0.47619048 -13.675091103 14.6274721
## Volvo-Lotus 5.76470588 -9.020879712 20.5502915
## MAZDA-Maserati 10.08463950 3.080805535 17.0884735
## Mercedes-Benz-Maserati 3.80303030 -2.538980900 10.1450415
## Mitsubishi Motors Co-Maserati 12.76136364 3.570916270 21.9518110
## Nissan-Maserati 6.80303030 0.191374563 13.4146860
## Porsche-Maserati 0.84271284 -5.620529352 7.3059550
## Rolls-Royce-Maserati -3.36363636 -12.005640953 5.2783682
## Subaru-Maserati 8.63636364 1.211804097 16.0609232
## Toyota-Maserati 9.19886364 2.902915852 15.4948114
## Volkswagen Group of-Maserati 3.11255411 -3.229457090 9.4545653
## Volvo-Maserati 8.40106952 0.747581614 16.0545574
## Mercedes-Benz-MAZDA -6.28160920 -10.541532376 -2.0216860
## Mitsubishi Motors Co-MAZDA 2.67672414 -5.222020206 10.5754685
## Nissan-MAZDA -3.28160920 -7.933472375 1.3702540
## Porsche-MAZDA -9.24192666 -13.680320405 -4.8035329
## Rolls-Royce-MAZDA -13.44827586 -20.701556687 -6.1949950
## Subaru-MAZDA -1.44827586 -7.197182173 4.3006304
## Toyota-MAZDA -0.88577586 -5.076813672 3.3052619
## Volkswagen Group of-MAZDA -6.97208539 -11.232008567 -2.7121622
## Volvo-MAZDA -1.68356998 -7.725235025 4.3580951
## Mitsubishi Motors Co-Mercedes-Benz 8.95833333 1.640029014 16.2766377
## Nissan-Mercedes-Benz 3.00000000 -0.578721411 6.5787214
## Porsche-Mercedes-Benz -2.96031746 -6.256793606 0.3361587
## Rolls-Royce-Mercedes-Benz -7.16666667 -13.783123319 -0.5502100
## Subaru-Mercedes-Benz 4.83333333 -0.087778296 9.7544450
## Toyota-Mercedes-Benz 5.39583333 2.440801384 8.3508653
## Volkswagen Group of-Mercedes-Benz -0.69047619 -3.742420065 2.3614677
## Volvo-Mercedes-Benz 4.59803922 -0.662106450 9.8581849
## Nissan-Mitsubishi Motors Co -5.95833333 -13.511509066 1.5948424
## Porsche-Mitsubishi Motors Co -11.91865079 -19.342259868 -4.4950417
## Rolls-Royce-Mitsubishi Motors Co -16.12500000 -25.506935586 -6.7430644
## Subaru-Mitsubishi Motors Co -4.12500000 -12.399089459 4.1490895
## Toyota-Mitsubishi Motors Co -3.56250000 -10.840922255 3.7159223
## Volkswagen Group of-Mitsubishi Motors Co -9.64880952 -16.967113843 -2.3305052
## Volvo-Mitsubishi Motors Co -4.36029412 -12.840409042 4.1198208
## Porsche-Nissan -5.96031746 -9.749729091 -2.1709058
## Rolls-Royce-Nissan -10.16666667 -17.042012779 -3.2913206
## Subaru-Nissan 1.83333333 -3.430716932 7.0973836
## Toyota-Nissan 2.39583333 -1.100607622 5.8922743
## Volkswagen Group of-Nissan -3.69047619 -7.269197602 -0.1117548
## Volvo-Nissan 1.59803922 -3.984255828 7.1803343
## Rolls-Royce-Porsche -4.20634921 -10.939096952 2.5263985
## Subaru-Porsche 7.79365079 2.717261010 12.8700406
## Toyota-Porsche 8.35615079 5.149188463 11.5631131
## Volkswagen Group of-Porsche 2.26984127 -1.026634876 5.5663174
## Volvo-Porsche 7.55835668 2.152662826 12.9640505
## Subaru-Rolls-Royce 12.00000000 4.339681672 19.6603183
## Toyota-Rolls-Royce 12.56250000 5.990182977 19.1348170
## Volkswagen Group of-Rolls-Royce 6.47619048 -0.140266176 13.0926471
## Volvo-Rolls-Royce 11.76470588 3.882303352 19.6471084
## Toyota-Subaru 0.56250000 -4.299103859 5.4241039
## Volkswagen Group of-Subaru -5.52380952 -10.444921153 -0.6026979
## Volvo-Subaru -0.23529412 -6.760024816 6.2894366
## Volkswagen Group of-Toyota -6.08630952 -9.041341473 -3.1312776
## Volvo-Toyota -0.79779412 -6.002309930 4.4067217
## Volvo-Volkswagen Group of 5.28851541 0.028369740 10.5486611
## p adj
## BMW-aston martin 0.3360278
## FCA US LLC-aston martin 0.9969965
## Ferrari-aston martin 0.9999998
## Ford Motor Company-aston martin 0.9886503
## General Motors-aston martin 0.9999337
## Honda-aston martin 0.0013406
## Hyundai-aston martin 0.0009188
## Jaguar Land Rover L-aston martin 1.0000000
## Kia-aston martin 0.0034476
## Lotus-aston martin 1.0000000
## Maserati-aston martin 1.0000000
## MAZDA-aston martin 0.0034954
## Mercedes-Benz-aston martin 0.9629111
## Mitsubishi Motors Co-aston martin 0.0016651
## Nissan-aston martin 0.2178863
## Porsche-aston martin 1.0000000
## Rolls-Royce-aston martin 0.9999953
## Subaru-aston martin 0.0526020
## Toyota-aston martin 0.0052903
## Volkswagen Group of-aston martin 0.9951088
## Volvo-aston martin 0.0868645
## FCA US LLC-BMW 0.0114085
## Ferrari-BMW 0.0037057
## Ford Motor Company-BMW 0.0932768
## General Motors-BMW 0.0000006
## Honda-BMW 0.0063753
## Hyundai-BMW 0.0006742
## Jaguar Land Rover L-BMW 0.0029904
## Kia-BMW 0.0502826
## Lotus-BMW 0.9999994
## Maserati-BMW 0.0643059
## MAZDA-BMW 0.0781284
## Mercedes-Benz-BMW 0.3214791
## Mitsubishi Motors Co-BMW 0.1233187
## Nissan-BMW 1.0000000
## Porsche-BMW 0.0000004
## Rolls-Royce-BMW 0.0000456
## Subaru-BMW 0.9588341
## Toyota-BMW 0.0114102
## Volkswagen Group of-BMW 0.0275603
## Volvo-BMW 0.9939932
## Ferrari-FCA US LLC 0.3929537
## Ford Motor Company-FCA US LLC 1.0000000
## General Motors-FCA US LLC 0.9999258
## Honda-FCA US LLC 0.0000000
## Hyundai-FCA US LLC 0.0000000
## Jaguar Land Rover L-FCA US LLC 0.9981933
## Kia-FCA US LLC 0.0000001
## Lotus-FCA US LLC 1.0000000
## Maserati-FCA US LLC 0.9874207
## MAZDA-FCA US LLC 0.0000004
## Mercedes-Benz-FCA US LLC 0.9999958
## Mitsubishi Motors Co-FCA US LLC 0.0003358
## Nissan-FCA US LLC 0.0180886
## Porsche-FCA US LLC 0.7392259
## Rolls-Royce-FCA US LLC 0.0781744
## Subaru-FCA US LLC 0.0062988
## Toyota-FCA US LLC 0.0000000
## Volkswagen Group of-FCA US LLC 1.0000000
## Volvo-FCA US LLC 0.0320426
## Ford Motor Company-Ferrari 0.2762130
## General Motors-Ferrari 0.6590693
## Honda-Ferrari 0.0000007
## Hyundai-Ferrari 0.0000003
## Jaguar Land Rover L-Ferrari 0.9505936
## Kia-Ferrari 0.0000030
## Lotus-Ferrari 0.9996648
## Maserati-Ferrari 0.9999432
## MAZDA-Ferrari 0.0000037
## Mercedes-Benz-Ferrari 0.1694329
## Mitsubishi Motors Co-Ferrari 0.0000071
## Nissan-Ferrari 0.0019372
## Porsche-Ferrari 0.9761098
## Rolls-Royce-Ferrari 1.0000000
## Subaru-Ferrari 0.0002928
## Toyota-Ferrari 0.0000033
## Volkswagen Group of-Ferrari 0.3513695
## Volvo-Ferrari 0.0007630
## General Motors-Ford Motor Company 0.9886267
## Honda-Ford Motor Company 0.0000000
## Hyundai-Ford Motor Company 0.0000000
## Jaguar Land Rover L-Ford Motor Company 0.9771555
## Kia-Ford Motor Company 0.0000009
## Lotus-Ford Motor Company 1.0000000
## Maserati-Ford Motor Company 0.9532036
## MAZDA-Ford Motor Company 0.0000050
## Mercedes-Benz-Ford Motor Company 1.0000000
## Mitsubishi Motors Co-Ford Motor Company 0.0009358
## Nissan-Ford Motor Company 0.0881086
## Porsche-Ford Motor Company 0.4460102
## Rolls-Royce-Ford Motor Company 0.0415279
## Subaru-Ford Motor Company 0.0225862
## Toyota-Ford Motor Company 0.0000000
## Volkswagen Group of-Ford Motor Company 1.0000000
## Volvo-Ford Motor Company 0.0861388
## Honda-General Motors 0.0000000
## Hyundai-General Motors 0.0000000
## Jaguar Land Rover L-General Motors 1.0000000
## Kia-General Motors 0.0000000
## Lotus-General Motors 1.0000000
## Maserati-General Motors 0.9998046
## MAZDA-General Motors 0.0000000
## Mercedes-Benz-General Motors 0.7770828
## Mitsubishi Motors Co-General Motors 0.0000232
## Nissan-General Motors 0.0000434
## Porsche-General Motors 0.9931661
## Rolls-Royce-General Motors 0.2180827
## Subaru-General Motors 0.0001287
## Toyota-General Motors 0.0000000
## Volkswagen Group of-General Motors 0.9994109
## Volvo-General Motors 0.0015476
## Hyundai-Honda 1.0000000
## Jaguar Land Rover L-Honda 0.0000000
## Kia-Honda 1.0000000
## Lotus-Honda 0.9442283
## Maserati-Honda 0.0000087
## MAZDA-Honda 1.0000000
## Mercedes-Benz-Honda 0.0000002
## Mitsubishi Motors Co-Honda 0.9999689
## Nissan-Honda 0.2521623
## Porsche-Honda 0.0000000
## Rolls-Royce-Honda 0.0000000
## Subaru-Honda 0.9999469
## Toyota-Honda 0.9999611
## Volkswagen Group of-Honda 0.0000000
## Volvo-Honda 0.9998340
## Jaguar Land Rover L-Hyundai 0.0000000
## Kia-Hyundai 1.0000000
## Lotus-Hyundai 0.9414524
## Maserati-Hyundai 0.0000032
## MAZDA-Hyundai 1.0000000
## Mercedes-Benz-Hyundai 0.0000000
## Mitsubishi Motors Co-Hyundai 0.9999473
## Nissan-Hyundai 0.1306932
## Porsche-Hyundai 0.0000000
## Rolls-Royce-Hyundai 0.0000000
## Subaru-Hyundai 0.9998947
## Toyota-Hyundai 0.9998015
## Volkswagen Group of-Hyundai 0.0000000
## Volvo-Hyundai 0.9997018
## Kia-Jaguar Land Rover L 0.0000000
## Lotus-Jaguar Land Rover L 1.0000000
## Maserati-Jaguar Land Rover L 1.0000000
## MAZDA-Jaguar Land Rover L 0.0000002
## Mercedes-Benz-Jaguar Land Rover L 0.8528528
## Mitsubishi Motors Co-Jaguar Land Rover L 0.0000367
## Nissan-Jaguar Land Rover L 0.0026851
## Porsche-Jaguar Land Rover L 1.0000000
## Rolls-Royce-Jaguar Land Rover L 0.7395312
## Subaru-Jaguar Land Rover L 0.0007054
## Toyota-Jaguar Land Rover L 0.0000000
## Volkswagen Group of-Jaguar Land Rover L 0.9951832
## Volvo-Jaguar Land Rover L 0.0037355
## Lotus-Kia 0.9710022
## Maserati-Kia 0.0000427
## MAZDA-Kia 1.0000000
## Mercedes-Benz-Kia 0.0000066
## Mitsubishi Motors Co-Kia 0.9995344
## Nissan-Kia 0.5772979
## Porsche-Kia 0.0000000
## Rolls-Royce-Kia 0.0000000
## Subaru-Kia 0.9999998
## Toyota-Kia 1.0000000
## Volkswagen Group of-Kia 0.0000002
## Volvo-Kia 0.9999985
## Maserati-Lotus 1.0000000
## MAZDA-Lotus 0.9653397
## Mercedes-Benz-Lotus 1.0000000
## Mitsubishi Motors Co-Lotus 0.7561128
## Nissan-Lotus 0.9999888
## Porsche-Lotus 1.0000000
## Rolls-Royce-Lotus 0.9988582
## Subaru-Lotus 0.9979010
## Toyota-Lotus 0.9891990
## Volkswagen Group of-Lotus 1.0000000
## Volvo-Lotus 0.9989286
## MAZDA-Maserati 0.0000566
## Mercedes-Benz-Maserati 0.8598170
## Mitsubishi Motors Co-Maserati 0.0001447
## Nissan-Maserati 0.0352954
## Porsche-Maserati 1.0000000
## Rolls-Royce-Maserati 0.9989545
## Subaru-Maserati 0.0057530
## Toyota-Maserati 0.0000380
## Volkswagen Group of-Maserati 0.9794744
## Volvo-Maserati 0.0145025
## Mercedes-Benz-MAZDA 0.0000294
## Mitsubishi Motors Co-MAZDA 0.9998703
## Nissan-MAZDA 0.6000885
## Porsche-MAZDA 0.0000000
## Rolls-Royce-MAZDA 0.0000000
## Subaru-MAZDA 0.9999992
## Toyota-MAZDA 1.0000000
## Volkswagen Group of-MAZDA 0.0000011
## Volvo-MAZDA 0.9999950
## Mitsubishi Motors Co-Mercedes-Benz 0.0022900
## Nissan-Mercedes-Benz 0.2533957
## Porsche-Mercedes-Benz 0.1488854
## Rolls-Royce-Mercedes-Benz 0.0176244
## Subaru-Mercedes-Benz 0.0614658
## Toyota-Mercedes-Benz 0.0000000
## Volkswagen Group of-Mercedes-Benz 0.9999999
## Volvo-Mercedes-Benz 0.1860450
## Nissan-Mitsubishi Motors Co 0.3684217
## Porsche-Mitsubishi Motors Co 0.0000022
## Rolls-Royce-Mitsubishi Motors Co 0.0000002
## Subaru-Mitsubishi Motors Co 0.9755731
## Toyota-Mitsubishi Motors Co 0.9800873
## Volkswagen Group of-Mitsubishi Motors Co 0.0004920
## Volvo-Mitsubishi Motors Co 0.9659801
## Porsche-Nissan 0.0000043
## Rolls-Royce-Nissan 0.0000272
## Subaru-Nissan 0.9998011
## Toyota-Nissan 0.6569629
## Volkswagen Group of-Nissan 0.0343158
## Volvo-Nissan 0.9999920
## Rolls-Royce-Porsche 0.8091146
## Subaru-Porsche 0.0000090
## Toyota-Porsche 0.0000000
## Volkswagen Group of-Porsche 0.6476734
## Volvo-Porsche 0.0001215
## Subaru-Rolls-Royce 0.0000048
## Toyota-Rolls-Royce 0.0000000
## Volkswagen Group of-Rolls-Royce 0.0638597
## Volvo-Rolls-Royce 0.0000209
## Toyota-Subaru 1.0000000
## Volkswagen Group of-Subaru 0.0103088
## Volvo-Subaru 1.0000000
## Volkswagen Group of-Toyota 0.0000000
## Volvo-Toyota 1.0000000
## Volvo-Volkswagen Group of 0.0469160
The Tukey HSD test showed several significant differences in average highway MPG between car manufacturers. Brands such as Honda, Toyota, Hyundai, Kia, Mazda, and Subaru, which are marketed as fuel-efficient brands, had significantly higher average highway MPG than many luxury manufacturers such as BMW, Mercedes-Benz, Jaguar, Maserati, Rolls-Royce, Aston Martin, Ferrari, and Porsche.
In general, the results show a clear pattern: economy-focused manufacturers tend to have higher highway MPG, and luxury manufacturers tend to have lower highway MPG.
When Tukey compared the manufacturers two at a time, many of those comparisons showed statistically significant differences. This confirms that, statistically several manufacturers have different average highway MPG.
boxplot <- cars1 |>
ggplot(aes(x = highway_mpg,
y = car_make,
fill = car_make)) +
geom_boxplot(show.legend = FALSE) +
labs(
title = "Highway MPG by Manufacturer",
x = "Highway Miles Per Gallon",
y = "Manufacturer",
caption = "Source: fueleconomy.gov"
)
boxplot
The boxplot shows the minimum, first quartile, median, third quartile, maximum, and any outliers of the highway miles per gallon for each car manufacturer. The minimum represents the lowest MPG value that is not considered an outlier, while the maximum represents the highest non-outlier MPG value. The first quartile (Q1) show the point where 25% of the data fall below it, and the third quartile (Q3) marks the point where 75% of the data fall below it. The median (Q2) is the middle value of the data, showing the typical highway MPG for a manufacturer. Outliers are individual points that are far outside the normal range of the data, and they represent unusually high or low MPG values.
This boxplot supports the results of the Tukey HSD test, with Hyundai and Toyota having some of the highest highway MPG values. Meanwhile, manufacturers such as Ferrari and Aston Martin have the lowest MPG on the highway.
In conclusion, the results of my analysis show that there are statistically significant differences in average highway miles per gallon among different car manufacturers. The ANOVA test gave us an extremely small p-value, which provided strong evidence for us to reject the null hypothesis and confirmed that not all manufacturers have the same average highway MPG. The Tukey HSD post-hoc test revealed how specific manufacturers differed from each other, showing a clear pattern that economy-focused brands such as Honda, Toyota, Hyundai, Kia, Mazda, and Subaru generally have higher highway MPG, while luxury brands like BMW, Mercedes-Benz, Jaguar, Maserati, Ferrari, and Aston Martin tend to have lower MPG. The boxplot supported these findings by visually showing the differences in fuel efficiency across manufacturers.
These results are relevant to my research question because they show that the car manufacturer plays a meaningful role in highway fuel efficiency. This information can be helpful for consumers who prefer fuel-efficient vehicles over flashy models, as well as for manufacturers looking to see where they stand compared to competitors based on fuel efficiency .
For future research, it would be interesting to compare trends across multiple years to see how manufacturers’ fuel efficiency has changed over time. Another possible direction would be performing similar tests for city MPG to see if the results are consistent with the findings for highway MPG.
“Download Fuel Economy Data.” Www.fueleconomy.gov, www.fueleconomy.gov/feg/download.shtml.
History.com Editors. “Automobile History.” HISTORY, 26 Apr. 2010, www.history.com/articles/automobiles#When-Were-Cars-Invented.
Melosi, Martin. “Automobile and the Environment in American History: Energy Use and the Internal Combustion Engine.” Umich.edu, 2025, autolife.umd.umich.edu/Environment/E_Overview/E_Overview3.htm.
Reiland, Ben. “Oil Check: How Is Gasoline Made? A General Overview.” Motus, 4 Apr. 2023, www.motus.com/blog/how-is-gasoline-made/.
US EPA, OAR. “Fuel Economy and EV Range Testing.” Www.epa.gov, 31 Aug. 2015, www.epa.gov/greenvehicles/fuel-economy-and-ev-range-testing.
Wikipedia Contributors. “Big Three (Automobile Manufacturers).” Wikipedia, Wikimedia Foundation, 27 July 2019, en.wikipedia.org/wiki/Big_Three_(automobile_manufacturers).