This is an R Markdown document. Markdown is a simple formatting syntax for authoring web pages (click the MD toolbar button for help on Markdown).
When you click the Knit HTML button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
as of August 28, 2014, superceding the version of August 24. Always use the most recent version.
The Research Question: Study the effect of three factors (Transmission,drive and number of cylinders) on the city mileage of a vehicle (response variable). In order to study this problem we can formulate the null hypothesis as:
‘The variance in the type of transmission, the type of drive and the number of cylinders used in a vehicle (taken separately-main effect or two/three at a time-interaction effect) has no significant impact on the variance of its city mileage’
The alternate hypothesis is therefore stated as:‘The variance in 3 factors namely transmission, drive and number of cylinders(either one taken alone or an interaction between any two/three of them) has a significant effect on the variance in city mileage’
install.packages("fueleconomy", repos='http://cran.us.r-project.org')
## Installing package into 'C:/Users/uzma/Documents/R/win-library/3.1'
## (as 'lib' is unspecified)
## package 'fueleconomy' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\uzma\AppData\Local\Temp\RtmpGuJkZ9\downloaded_packages
library("fueleconomy", lib.loc="C:\\Users\\uzma\\Documents\\R\\win-library\\3.1")
x<-vehicles
head(x)
## id make model year class
## 1 27550 AM General DJ Po Vehicle 2WD 1984 Special Purpose Vehicle 2WD
## 2 28426 AM General DJ Po Vehicle 2WD 1984 Special Purpose Vehicle 2WD
## 3 27549 AM General FJ8c Post Office 1984 Special Purpose Vehicle 2WD
## 4 28425 AM General FJ8c Post Office 1984 Special Purpose Vehicle 2WD
## 5 1032 AM General Post Office DJ5 2WD 1985 Special Purpose Vehicle 2WD
## 6 1033 AM General Post Office DJ8 2WD 1985 Special Purpose Vehicle 2WD
## trans drive cyl displ fuel hwy cty
## 1 Automatic 3-spd 2-Wheel Drive 4 2.5 Regular 17 18
## 2 Automatic 3-spd 2-Wheel Drive 4 2.5 Regular 17 18
## 3 Automatic 3-spd 2-Wheel Drive 6 4.2 Regular 13 13
## 4 Automatic 3-spd 2-Wheel Drive 6 4.2 Regular 13 13
## 5 Automatic 3-spd Rear-Wheel Drive 4 2.5 Regular 17 16
## 6 Automatic 3-spd Rear-Wheel Drive 6 4.2 Regular 13 13
There are three factors of interest : Transmission,drive and number of cylinders. However we perform some preliminary analysis to see which factors to block on since there are various other independent variables (factors) that can have an effect on the response variable.Each factor (independent variable) has several levels and we consider all levels for this experiment.
NOTE: Only the first 600 rows from the data set were used as a sample for testing the hypothesis because the system was unable to handle more records resulting in a system ‘crash’.(Most of the conclusions from preliminary analysis were made using the entire dataset)
Deciding on blocking variables:
L<-x[1:600,]
L$make=as.factor(L$make)
L$year=as.factor(L$year)
L$fuel=as.factor(L$fuel)
L$trans=as.factor(L$trans)
L$cyl=as.factor(L$cyl)
L$drive=as.factor(L$drive)
#Boxplots for preliminary analysis only
boxplot(cty~make,data=L ,xlab="Make of the vehicle", ylab="city mileage (MPG)")
title("Boxplot 'Make'")
boxplot(cty~year,data=L,xlab="Year", ylab="city mileage (MPG)")
title("Boxplot 'Year'")
boxplot(cty~fuel,data=L,xlab="Fuel Type", ylab="city mileage (MPG)")
title("Boxplot 'Fuel'")
From the above box-plots it is clear that the within group variation in most levels for the variables ‘Make’ and ‘Fuel’ is quite less as compared to the variation between levels. Therefore these seem to be good candidates for blocking(controlling the known variability due to nuisance variables), given our requirement of focussing on three factors only (stated above).
str(L)
## Classes 'tbl_df', 'tbl' and 'data.frame': 600 obs. of 12 variables:
## $ id : int 27550 28426 27549 28425 1032 1033 3347 13309 13310 13311 ...
## $ make : Factor w/ 7 levels "Acura","Alfa Romeo",..: 3 3 3 3 3 3 5 1 1 1 ...
## $ model: chr "DJ Po Vehicle 2WD" "DJ Po Vehicle 2WD" "FJ8c Post Office" "FJ8c Post Office" ...
## $ year : Factor w/ 32 levels "1984","1985",..: 1 1 1 1 2 2 4 14 14 14 ...
## $ class: chr "Special Purpose Vehicle 2WD" "Special Purpose Vehicle 2WD" "Special Purpose Vehicle 2WD" "Special Purpose Vehicle 2WD" ...
## $ trans: Factor w/ 15 levels "Auto(AM-S6)",..: 9 9 9 9 9 9 10 10 14 10 ...
## $ drive: Factor w/ 5 levels "2-Wheel Drive",..: 1 1 1 1 5 5 5 4 4 4 ...
## $ cyl : Factor w/ 5 levels "4","5","6","8",..: 1 1 3 3 1 3 3 1 1 3 ...
## $ displ: num 2.5 2.5 4.2 4.2 2.5 4.2 3.8 2.2 2.2 3 ...
## $ fuel : Factor w/ 3 levels "Diesel","Premium",..: 3 3 3 3 3 3 2 3 3 3 ...
## $ hwy : int 17 17 13 13 17 13 21 26 28 26 ...
## $ cty : int 18 18 13 13 16 13 14 20 22 18 ...
head(L)
## id make model year class
## 1 27550 AM General DJ Po Vehicle 2WD 1984 Special Purpose Vehicle 2WD
## 2 28426 AM General DJ Po Vehicle 2WD 1984 Special Purpose Vehicle 2WD
## 3 27549 AM General FJ8c Post Office 1984 Special Purpose Vehicle 2WD
## 4 28425 AM General FJ8c Post Office 1984 Special Purpose Vehicle 2WD
## 5 1032 AM General Post Office DJ5 2WD 1985 Special Purpose Vehicle 2WD
## 6 1033 AM General Post Office DJ8 2WD 1985 Special Purpose Vehicle 2WD
## trans drive cyl displ fuel hwy cty
## 1 Automatic 3-spd 2-Wheel Drive 4 2.5 Regular 17 18
## 2 Automatic 3-spd 2-Wheel Drive 4 2.5 Regular 17 18
## 3 Automatic 3-spd 2-Wheel Drive 6 4.2 Regular 13 13
## 4 Automatic 3-spd 2-Wheel Drive 6 4.2 Regular 13 13
## 5 Automatic 3-spd Rear-Wheel Drive 4 2.5 Regular 17 16
## 6 Automatic 3-spd Rear-Wheel Drive 6 4.2 Regular 13 13
tail(L)
## id make model year class trans
## 595 26013 Audi A3 quattro 2009 Small Station Wagons Automatic (S6)
## 596 28680 Audi A3 quattro 2010 Small Station Wagons Automatic (S6)
## 597 30427 Audi A3 quattro 2011 Small Station Wagons Automatic (S6)
## 598 31590 Audi A3 quattro 2012 Small Station Wagons Automatic (S6)
## 599 32730 Audi A3 quattro 2013 Small Station Wagons Auto(AM-S6)
## 600 34710 Audi A3 quattro 2015 Subcompact Cars Auto(AM-S6)
## drive cyl displ fuel hwy cty
## 595 4-Wheel or All-Wheel Drive 6 3.2 Premium 25 18
## 596 All-Wheel Drive 4 2.0 Premium 28 21
## 597 All-Wheel Drive 4 2.0 Premium 28 21
## 598 All-Wheel Drive 4 2.0 Premium 28 21
## 599 All-Wheel Drive 4 2.0 Premium 28 21
## 600 All-Wheel Drive 4 1.8 Premium 33 24
summary(L)
## id make model
## Min. : 1 Acura :269 Length:600
## 1st Qu.: 7688 Alfa Romeo : 39 Class :character
## Median :15624 AM General : 6 Mode :character
## Mean :17063 American Motors Corporation: 27
## 3rd Qu.:27590 ASC Incorporated : 1
## Max. :34843 Aston Martin :112
## Audi :146
## year class trans
## 1987 : 33 Length:600 Manual 5-spd :172
## 2012 : 27 Class :character Automatic 4-spd: 99
## 1993 : 26 Mode :character Manual 6-spd : 84
## 1989 : 25 Automatic (S6) : 75
## 1992 : 25 Automatic (S5) : 64
## 2011 : 25 Automatic 3-spd: 62
## (Other):439 (Other) : 44
## drive cyl displ fuel
## 2-Wheel Drive : 4 4 :167 Min. :1.50 Diesel : 4
## 4-Wheel or All-Wheel Drive: 96 5 : 86 1st Qu.:2.20 Premium:370
## All-Wheel Drive : 34 6 :242 Median :2.80 Regular:226
## Front-Wheel Drive :297 8 : 46 Mean :3.17
## Rear-Wheel Drive :169 12: 59 3rd Qu.:3.70
## Max. :5.90
##
## hwy cty
## Min. : 9 Min. : 7.0
## 1st Qu.:20 1st Qu.:15.0
## Median :23 Median :16.0
## Mean :23 Mean :16.7
## 3rd Qu.:27 3rd Qu.:19.0
## Max. :42 Max. :39.0
##
The response variable i.e. city mileage is a continuous variable. Also, highway mileage for each vehicle is continuous.
City mileage (cty) measured in MPG (miles per gallon) is the only response variable.
The given data set is the fuel economy data from the EPA. It ranges from the year 1985 to 2015 for various car models and each row has a detailed specification of the vehicle. There are 74 variables and 34632 records in the original data set.
We can safely assume the data to be randomized because it is a result of vehicle testing done at the Environmental Protection Agency National Vehicle and Fuel Emissions Laboratory. Since almost every vehicle needs to clear this testing therefore data is a true representative of the population as a whole.
This is a three factor ANOVA (analysis of variance) experiment.We conduct a main effects test and an interaction effect test for all three variables (factors) in order to test the variability in the response variable as a result of the variablity in the 3 identified factors. Since there are various other independent variables present in the data set, that may have an effect on the response variable therefore we use blocking on two variables (fuel type used and make of the car)and test the within group/block variability for the factors of interest only.Through blocking we tend to minimize the effect of these nuisance variables and thus able to control their effect on the final response.
If we are able to determine the within group and between group variability on the performance of a vehicle based on certain factors, then that can be a useful study for performance enhancement.
It is a completely randomized design, given that it is survey data.
There are no repeated measures since we are using data from a study conducted by EPA.
#Create a histogram
par(mfrow=c(1,1))
hist(L$cty, xlim=c(0,100), ylab = "City Mileage (MPG)")
# Boxplots for the 3 factors
boxplot(cty~trans,data=L,xlab="Transmission", ylab="city mileage (MPG)")
title("Boxplot 'Transmission'")
boxplot(cty~cyl,data=L,xlab="Number of cylinders", ylab="city mileage (MPG)")
title("Boxplot 'Number of cylinders'")
boxplot(cty~drive,data=L,xlab="Type of drive", ylab="city mileage (MPG)")
title("Boxplot 'Drive type'")
Analysis of variance for the factor cylinder within the each block
modelcylf=aov(cty~(cyl)+fuel,data=L)
anova(modelcylf)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## cyl 4 6797 1699 473.9 <2e-16 ***
## fuel 2 446 223 62.1 <2e-16 ***
## Residuals 593 2126 4
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
modelcylm=aov(cty~(cyl)+make,data=L)
anova(modelcylm)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## cyl 4 6797 1699 451.7 <2e-16 ***
## make 6 356 59 15.8 <2e-16 ***
## Residuals 589 2216 4
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of variance for the factor transmission within each block
modeltrf=aov(cty~(trans)+fuel,data=L)
anova(modeltrf)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## trans 14 2324 166 15.2 < 2e-16 ***
## fuel 2 688 344 31.6 9.7e-14 ***
## Residuals 583 6356 11
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
modeltrm=aov(cty~(trans)+make,data=L)
anova(modeltrm)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## trans 14 2324 166 31.6 <2e-16 ***
## make 6 3998 666 126.6 <2e-16 ***
## Residuals 579 3047 5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of variance for the factor drive within each block
modeldrf=aov(cty~(drive)+fuel,data=L)
anova(modeldrf)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## drive 4 4168 1042 131.2 <2e-16 ***
## fuel 2 489 244 30.8 2e-13 ***
## Residuals 593 4712 8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
modeldrm=aov(cty~(drive)+make,data=L)
anova(modeldrm)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## drive 4 4168 1042 151.6 <2e-16 ***
## make 6 1150 192 27.9 <2e-16 ***
## Residuals 589 4050 7
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of variance for all the factors:cylinder,drive and transmission within each block and also for both the blocking variables taken together
modelallf=aov(cty~(cyl*trans*drive)+fuel,data=L)
anova(modelallf)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## cyl 4 6797 1699 1815.15 < 2e-16 ***
## trans 14 1327 95 101.27 < 2e-16 ***
## drive 4 318 80 84.93 < 2e-16 ***
## fuel 2 175 87 93.22 < 2e-16 ***
## cyl:trans 14 155 11 11.81 < 2e-16 ***
## cyl:drive 5 35 7 7.52 7.7e-07 ***
## trans:drive 11 34 3 3.30 0.00021 ***
## cyl:trans:drive 4 21 5 5.73 0.00016 ***
## Residuals 541 506 1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
modelallm=aov(cty~(cyl*trans*drive)+make,data=L)
anova(modelallm)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## cyl 4 6797 1699 1581.45 < 2e-16 ***
## trans 14 1327 95 88.23 < 2e-16 ***
## drive 4 318 80 73.99 < 2e-16 ***
## make 6 100 17 15.46 < 2e-16 ***
## cyl:trans 14 158 11 10.50 < 2e-16 ***
## cyl:drive 5 47 9 8.67 6.4e-08 ***
## trans:drive 11 40 4 3.34 0.00018 ***
## cyl:trans:drive 4 6 1 1.35 0.25131
## Residuals 537 577 1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Both blocking variables taken together
modelall=aov(cty~(cyl*trans*drive)+make+fuel,data=L)
anova(modelall)
## Analysis of Variance Table
##
## Response: cty
## Df Sum Sq Mean Sq F value Pr(>F)
## cyl 4 6797 1699 2296.56 < 2e-16 ***
## trans 14 1327 95 128.13 < 2e-16 ***
## drive 4 318 80 107.45 < 2e-16 ***
## make 6 100 17 22.45 < 2e-16 ***
## fuel 2 178 89 120.23 < 2e-16 ***
## cyl:trans 14 155 11 14.99 < 2e-16 ***
## cyl:drive 5 29 6 7.89 3.5e-07 ***
## trans:drive 11 47 4 5.82 6.0e-09 ***
## cyl:trans:drive 4 21 5 7.17 1.3e-05 ***
## Residuals 535 396 1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The results from ANOVA show that both the blocking variables have very small p-values conforming that these are valid blocking variables.
For the hypothesis testing, we see that (for our sample) there is a significant effect of all three factors in all the blocks (separate blocks or an interaction of both blocks)on the response variable. A low p value (less than 0.5) indicates that the variation in city gas mileage is caused by something other than randomization alone (so the factors have a main and interaction effect on the response variable).In conclusion we reject the null hypothesis.
In this section we check the adequacy of the ANOVA model.
# Shapiro Test
shapiro.test(L$cty)
##
## Shapiro-Wilk normality test
##
## data: L$cty
## W = 0.9453, p-value = 4.399e-14
#Diagnostics for the main effect under blocking factor fuel
#Number of cylinders
qqnorm(residuals(modelcylf),main="Normal Q-Q Plot for no. of cylinders-Fuel type blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modelcylf))
plot(fitted(modelcylf),residuals(modelcylf))
#Transmission type
qqnorm(residuals(modeltrf),main="Normal Q-Q Plot for transmission type-Fuel type blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modeltrf))
plot(fitted(modeltrf),residuals(modeltrf))
#Drive type
qqnorm(residuals(modeldrf),main="Normal Q-Q Plot for drive type-Fuel type blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modeldrf))
plot(fitted(modeldrf),residuals(modeldrf))
#Diagnostics for the main effect under blocking factor make
#Number of cylinders
qqnorm(residuals(modelcylm),main="Normal Q-Q Plot for no. of cylinders-Make type blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modelcylm))
plot(fitted(modelcylm),residuals(modelcylm))
#Transmission type
qqnorm(residuals(modeltrm),main="Normal Q-Q Plot for transmission type-Make type blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modeltrm))
plot(fitted(modeltrm),residuals(modeltrm))
#Drive type
qqnorm(residuals(modeldrm),main="Normal Q-Q Plot for drive type-Make type blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modeldrm))
plot(fitted(modeldrm),residuals(modeldrm))
#Diagnostics for the interaction effect when blocked by factor fuel
qqnorm(residuals(modelallf),main="Normal Q-Q Plot for Interaction-Fuel type blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modelallf))
plot(fitted(modelallf),residuals(modelallf))
#Diagnostics for the interaction effect when blocked by factor make
qqnorm(residuals(modelallm),main="Normal Q-Q Plot for Interaction- Make blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modelallm))
plot(fitted(modelallm),residuals(modelallm))
# Blocking
qqnorm(residuals(modelall),main="Normal Q-Q Plot for Interaction- Make and fuel blocked",ylab="Residuals-City mileage (MPG)")
qqline(residuals(modelall))
plot(fitted(modelall),residuals(modelall))
#Interaction plots
interaction.plot(L$cyl,L$trans,L$cty, xlab= "Number of cylinders", ylab="City Mileage(MPG)", main ="Interaction plot", trace.label="Transmission type")
interaction.plot(L$cyl,L$drive,L$cty, xlab= "Number of cylinders", ylab="City Mileage(MPG)", main ="Interaction plot", trace.label="Type of drive")
interaction.plot(L$drive,L$trans,L$cty, xlab= "Type of drive", ylab="City Mileage(MPG)", main ="Interaction plot", trace.label="Transmission type")
Shapiro test gives a value of p which is less than 0.1. This shows that the data is normally distributed.
Normal Q-Q Plots:All the Normal Q-Q plots confirm to the assumption of normality. There are a few deviations from the normality (for the factor-Number of cylinders). However, for most other factors as well as their interaction plots are normal for most of the data.
Scatter plots: Since the scatter plots for the residuals of ‘transmission type’ and ‘type of drive’ show some skewedness in both blocks, we can say that this model could be biased.However the residuals for the interaction model do not show any specific patterns so we can say it is a reasonable fit. The plots do depict the presence of some outliers but the data can be considered appropriate for 2-way Annova.
Interaction Plots: As expected, we can see interaction between various levels of all the factors (2 at a time).
In order to avoid the chances of discovering false positives in a multivariate statistical test we further perform a Tukey’s HSD test.We use this test to compare means of various treatment levels.
# Number of cylinders
TukeyHSD(modelcylf, ordered = FALSE, conf.level = 0.95)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = cty ~ (cyl) + fuel, data = L)
##
## $cyl
## diff lwr upr p adj
## 5-4 -4.88330 -5.5709 -4.1957 0.0000
## 6-4 -4.86745 -5.3886 -4.3462 0.0000
## 8-4 -10.20737 -11.0701 -9.3447 0.0000
## 12-4 -10.13478 -10.9194 -9.3501 0.0000
## 6-5 0.01586 -0.6346 0.6663 1.0000
## 8-5 -5.32406 -6.2705 -4.3777 0.0000
## 12-5 -5.25148 -6.1273 -4.3756 0.0000
## 8-6 -5.33992 -6.1733 -4.5066 0.0000
## 12-6 -5.26733 -6.0196 -4.5151 0.0000
## 12-8 0.07259 -0.9465 1.0916 0.9997
##
## $fuel
## diff lwr upr p adj
## Premium-Diesel -8.5542 -10.791 -6.3177 0
## Regular-Diesel -9.3964 -11.640 -7.1523 0
## Regular-Premium -0.8422 -1.218 -0.4666 0
TukeyHSD(modelcylm, ordered = FALSE, conf.level = 0.95)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = cty ~ (cyl) + make, data = L)
##
## $cyl
## diff lwr upr p adj
## 5-4 -4.88330 -5.5877 -4.1789 0.0000
## 6-4 -4.86745 -5.4013 -4.3336 0.0000
## 8-4 -10.20737 -11.0910 -9.3237 0.0000
## 12-4 -10.13478 -10.9385 -9.3311 0.0000
## 6-5 0.01586 -0.6504 0.6821 1.0000
## 8-5 -5.32406 -6.2935 -4.3547 0.0000
## 12-5 -5.25148 -6.1486 -4.3544 0.0000
## 8-6 -5.33992 -6.1935 -4.4863 0.0000
## 12-6 -5.26733 -6.0379 -4.4968 0.0000
## 12-8 0.07259 -0.9712 1.1164 0.9997
##
## $make
## diff lwr upr
## Alfa Romeo-Acura -1.4667 -2.44985 -0.483495
## AM General-Acura -3.9918 -6.36029 -1.623226
## American Motors Corporation-Acura -1.8706 -3.02899 -0.712227
## ASC Incorporated-Acura -2.7247 -8.47340 3.024005
## Aston Martin-Acura -0.6794 -1.32471 -0.034169
## Audi-Acura -0.2290 -0.81882 0.360860
## AM General-Alfa Romeo -2.5251 -5.04139 -0.008784
## American Motors Corporation-Alfa Romeo -0.4039 -1.84049 1.032616
## ASC Incorporated-Alfa Romeo -1.2580 -7.06918 4.553119
## Aston Martin-Alfa Romeo 0.7872 -0.27964 1.854102
## Audi-Alfa Romeo 1.2377 0.20340 2.271976
## American Motors Corporation-AM General 2.1211 -0.46864 4.710932
## ASC Incorporated-AM General 1.2671 -4.93074 7.464858
## Aston Martin-AM General 3.3123 0.90784 5.716794
## Audi-AM General 3.7628 1.37257 6.152972
## ASC Incorporated-American Motors Corporation -0.8541 -6.69743 4.989253
## Aston Martin-American Motors Corporation 1.1912 -0.03904 2.421385
## Audi-American Motors Corporation 1.6416 0.43956 2.843695
## Aston Martin-ASC Incorporated 2.0453 -3.71835 7.808869
## Audi-ASC Incorporated 2.4957 -3.26195 8.253383
## Audi-Aston Martin 0.4505 -0.27030 1.171213
## p adj
## Alfa Romeo-Acura 0.0002
## AM General-Acura 0.0000
## American Motors Corporation-Acura 0.0000
## ASC Incorporated-Acura 0.8006
## Aston Martin-Acura 0.0315
## Audi-Acura 0.9126
## AM General-Alfa Romeo 0.0485
## American Motors Corporation-Alfa Romeo 0.9816
## ASC Incorporated-Alfa Romeo 0.9954
## Aston Martin-Alfa Romeo 0.3063
## Audi-Alfa Romeo 0.0078
## American Motors Corporation-AM General 0.1907
## ASC Incorporated-AM General 0.9967
## Aston Martin-AM General 0.0010
## Audi-AM General 0.0001
## ASC Incorporated-American Motors Corporation 0.9995
## Aston Martin-American Motors Corporation 0.0649
## Audi-American Motors Corporation 0.0012
## Aston Martin-ASC Incorporated 0.9420
## Audi-ASC Incorporated 0.8599
## Audi-Aston Martin 0.5153
# Drive type
TukeyHSD(modeldrf, ordered = FALSE, conf.level = 0.95)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = cty ~ (drive) + fuel, data = L)
##
## $drive
## diff lwr upr p adj
## 4-Wheel or All-Wheel Drive-2-Wheel Drive 0.3958 -3.5401 4.332 0.9987
## All-Wheel Drive-2-Wheel Drive 2.5294 -1.5475 6.606 0.4362
## Front-Wheel Drive-2-Wheel Drive 3.5539 -0.3284 7.436 0.0909
## Rear-Wheel Drive-2-Wheel Drive -2.5651 -6.4668 1.337 0.3752
## All-Wheel Drive-4-Wheel or All-Wheel Drive 2.1336 0.5943 3.673 0.0015
## Front-Wheel Drive-4-Wheel or All-Wheel Drive 3.1580 2.2525 4.064 0.0000
## Rear-Wheel Drive-4-Wheel or All-Wheel Drive -2.9609 -3.9466 -1.975 0.0000
## Front-Wheel Drive-All-Wheel Drive 1.0245 -0.3719 2.421 0.2636
## Rear-Wheel Drive-All-Wheel Drive -5.0945 -6.5442 -3.645 0.0000
## Rear-Wheel Drive-Front-Wheel Drive -6.1190 -6.8621 -5.376 0.0000
##
## $fuel
## diff lwr upr p adj
## Premium-Diesel -10.965 -14.2944 -7.6356 0.0000
## Regular-Diesel -11.109 -14.4497 -7.7682 0.0000
## Regular-Premium -0.144 -0.7031 0.4152 0.8175
TukeyHSD(modeldrm, ordered = FALSE, conf.level = 0.95)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = cty ~ (drive) + make, data = L)
##
## $drive
## diff lwr upr
## 4-Wheel or All-Wheel Drive-2-Wheel Drive 0.3958 -3.26562 4.057
## All-Wheel Drive-2-Wheel Drive 2.5294 -1.26323 6.322
## Front-Wheel Drive-2-Wheel Drive 3.5539 -0.05768 7.165
## Rear-Wheel Drive-2-Wheel Drive -2.5651 -6.19477 1.065
## All-Wheel Drive-4-Wheel or All-Wheel Drive 2.1336 0.70167 3.565
## Front-Wheel Drive-4-Wheel or All-Wheel Drive 3.1580 2.31567 4.000
## Rear-Wheel Drive-4-Wheel or All-Wheel Drive -2.9609 -3.87791 -2.044
## Front-Wheel Drive-All-Wheel Drive 1.0245 -0.27456 2.323
## Rear-Wheel Drive-All-Wheel Drive -5.0945 -6.44310 -3.746
## Rear-Wheel Drive-Front-Wheel Drive -6.1190 -6.81030 -5.428
## p adj
## 4-Wheel or All-Wheel Drive-2-Wheel Drive 0.9983
## All-Wheel Drive-2-Wheel Drive 0.3601
## Front-Wheel Drive-2-Wheel Drive 0.0562
## Rear-Wheel Drive-2-Wheel Drive 0.3006
## All-Wheel Drive-4-Wheel or All-Wheel Drive 0.0005
## Front-Wheel Drive-4-Wheel or All-Wheel Drive 0.0000
## Rear-Wheel Drive-4-Wheel or All-Wheel Drive 0.0000
## Front-Wheel Drive-All-Wheel Drive 0.1974
## Rear-Wheel Drive-All-Wheel Drive 0.0000
## Rear-Wheel Drive-Front-Wheel Drive 0.0000
##
## $make
## diff lwr upr
## Alfa Romeo-Acura 1.1878 -0.1414 2.51709
## AM General-Acura -0.0595 -3.2618 3.14278
## American Motors Corporation-Acura -0.1807 -1.7469 1.38541
## ASC Incorporated-Acura 0.4839 -7.2884 8.25621
## Aston Martin-Acura -2.3911 -3.2635 -1.51869
## Audi-Acura -0.8389 -1.6364 -0.04147
## AM General-Alfa Romeo -1.2473 -4.6494 2.15474
## American Motors Corporation-Alfa Romeo -1.3686 -3.3108 0.57368
## ASC Incorporated-Alfa Romeo -0.7039 -8.5607 7.15280
## Aston Martin-Alfa Romeo -3.5789 -5.0214 -2.13652
## Audi-Alfa Romeo -2.0268 -3.4251 -0.62840
## American Motors Corporation-AM General -0.1212 -3.6227 3.38019
## ASC Incorporated-AM General 0.5434 -7.8361 8.92289
## Aston Martin-AM General -2.3316 -5.5825 0.91927
## Audi-AM General -0.7794 -4.0110 2.45213
## ASC Incorporated-American Motors Corporation 0.6646 -7.2356 8.56489
## Aston Martin-American Motors Corporation -2.2104 -3.8736 -0.54711
## Audi-American Motors Corporation -0.6582 -2.2834 0.96700
## Aston Martin-ASC Incorporated -2.8750 -10.6675 4.91746
## Audi-ASC Incorporated -1.3228 -9.1073 6.46159
## Audi-Aston Martin 1.5522 0.5777 2.52663
## p adj
## Alfa Romeo-Acura 0.1150
## AM General-Acura 1.0000
## American Motors Corporation-Acura 0.9999
## ASC Incorporated-Acura 1.0000
## Aston Martin-Acura 0.0000
## Audi-Acura 0.0318
## AM General-Alfa Romeo 0.9325
## American Motors Corporation-Alfa Romeo 0.3631
## ASC Incorporated-Alfa Romeo 1.0000
## Aston Martin-Alfa Romeo 0.0000
## Audi-Alfa Romeo 0.0004
## American Motors Corporation-AM General 1.0000
## ASC Incorporated-AM General 1.0000
## Aston Martin-AM General 0.3410
## Audi-AM General 0.9918
## ASC Incorporated-American Motors Corporation 1.0000
## Aston Martin-American Motors Corporation 0.0018
## Audi-American Motors Corporation 0.8948
## Aston Martin-ASC Incorporated 0.9305
## Audi-ASC Incorporated 0.9988
## Audi-Aston Martin 0.0001
# Transmission
TukeyHSD(modeltrf, ordered = FALSE, conf.level = 0.95)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = cty ~ (trans) + fuel, data = L)
##
## $trans
## diff lwr upr p adj
## Auto(AM6)-Auto(AM-S6) -9.800e+00 -18.0132 -1.58684 0.0049
## Auto(AM7)-Auto(AM-S6) -9.800e+00 -16.3852 -3.21482 0.0001
## Auto(AV-S7)-Auto(AM-S6) 1.520e+01 5.7906 24.60936 0.0000
## Automatic (S4)-Auto(AM-S6) -8.400e+00 -15.5128 -1.28719 0.0057
## Automatic (S5)-Auto(AM-S6) -5.066e+00 -10.2879 0.15666 0.0682
## Automatic (S6)-Auto(AM-S6) -7.347e+00 -12.5411 -2.15221 0.0002
## Automatic (S7)-Auto(AM-S6) 4.200e+00 -8.1197 16.51974 0.9980
## Automatic 3-spd-Auto(AM-S6) -8.897e+00 -14.1252 -3.66839 0.0000
## Automatic 4-spd-Auto(AM-S6) -6.901e+00 -12.0560 -1.74605 0.0006
## Automatic 5-spd-Auto(AM-S6) -1.063e+01 -16.6197 -4.64701 0.0000
## Automatic 6-spd-Auto(AM-S6) -1.280e+01 -25.1197 -0.48026 0.0327
## Manual 4-spd-Auto(AM-S6) -6.550e+00 -12.9614 -0.13860 0.0396
## Manual 5-spd-Auto(AM-S6) -6.498e+00 -11.5998 -1.39558 0.0016
## Manual 6-spd-Auto(AM-S6) -8.431e+00 -13.6080 -3.25391 0.0000
## Auto(AM7)-Auto(AM6) -1.954e-14 -7.7607 7.76071 1.0000
## Auto(AV-S7)-Auto(AM6) 2.500e+01 14.7335 35.26645 0.0000
## Automatic (S4)-Auto(AM6) 1.400e+00 -6.8132 9.61316 1.0000
## Automatic (S5)-Auto(AM6) 4.734e+00 -1.9091 11.37789 0.4955
## Automatic (S6)-Auto(AM6) 2.453e+00 -4.1683 9.07500 0.9953
## Automatic (S7)-Auto(AM6) 1.400e+01 1.0138 26.98615 0.0209
## Automatic 3-spd-Auto(AM6) 9.032e-01 -5.7451 7.55154 1.0000
## Automatic 4-spd-Auto(AM6) 2.899e+00 -3.6917 9.48971 0.9762
## Automatic 5-spd-Auto(AM6) -8.333e-01 -8.0928 6.42615 1.0000
## Automatic 6-spd-Auto(AM6) -3.000e+00 -15.9862 9.98615 1.0000
## Manual 4-spd-Auto(AM6) 3.250e+00 -4.3638 10.86381 0.9818
## Manual 5-spd-Auto(AM6) 3.302e+00 -3.2471 9.85178 0.9273
## Manual 6-spd-Auto(AM6) 1.369e+00 -5.2390 7.97705 1.0000
## Auto(AV-S7)-Auto(AM7) 2.500e+01 15.9829 34.01713 0.0000
## Automatic (S4)-Auto(AM7) 1.400e+00 -5.1852 7.98518 1.0000
## Automatic (S5)-Auto(AM7) 4.734e+00 0.2572 9.21152 0.0265
## Automatic (S6)-Auto(AM7) 2.453e+00 -1.9913 6.89799 0.8624
## Automatic (S7)-Auto(AM7) 1.400e+01 1.9772 26.02284 0.0071
## Automatic 3-spd-Auto(AM7) 9.032e-01 -3.5810 5.38749 1.0000
## Automatic 4-spd-Auto(AM7) 2.899e+00 -1.4994 7.29742 0.6320
## Automatic 5-spd-Auto(AM7) -8.333e-01 -6.1820 4.51537 1.0000
## Automatic 6-spd-Auto(AM7) -3.000e+00 -15.0228 9.02284 0.9999
## Manual 4-spd-Auto(AM7) 3.250e+00 -2.5705 9.07053 0.8517
## Manual 5-spd-Auto(AM7) 3.302e+00 -1.0340 7.63868 0.3761
## Manual 6-spd-Auto(AM7) 1.369e+00 -3.0552 5.79333 0.9993
## Automatic (S4)-Auto(AV-S7) -2.360e+01 -33.0094 -14.19064 0.0000
## Automatic (S5)-Auto(AV-S7) -2.027e+01 -28.3413 -12.18996 0.0000
## Automatic (S6)-Auto(AV-S7) -2.255e+01 -30.6044 -14.48897 0.0000
## Automatic (S7)-Auto(AV-S7) -1.100e+01 -24.7739 2.77389 0.2953
## Automatic 3-spd-Auto(AV-S7) -2.410e+01 -32.1764 -16.01717 0.0000
## Automatic 4-spd-Auto(AV-S7) -2.210e+01 -30.1333 -14.06872 0.0000
## Automatic 5-spd-Auto(AV-S7) -2.583e+01 -34.4229 -17.24380 0.0000
## Automatic 6-spd-Auto(AV-S7) -2.800e+01 -41.7739 -14.22611 0.0000
## Manual 4-spd-Auto(AV-S7) -2.175e+01 -30.6410 -12.85899 0.0000
## Manual 5-spd-Auto(AV-S7) -2.170e+01 -29.6961 -13.69921 0.0000
## Manual 6-spd-Auto(AV-S7) -2.363e+01 -31.6774 -15.58448 0.0000
## Automatic (S5)-Automatic (S4) 3.334e+00 -1.8879 8.55666 0.6830
## Automatic (S6)-Automatic (S4) 1.053e+00 -4.1411 6.24779 1.0000
## Automatic (S7)-Automatic (S4) 1.260e+01 0.2803 24.91974 0.0391
## Automatic 3-spd-Automatic (S4) -4.968e-01 -5.7252 4.73161 1.0000
## Automatic 4-spd-Automatic (S4) 1.499e+00 -3.6560 6.65395 0.9997
## Automatic 5-spd-Automatic (S4) -2.233e+00 -8.2197 3.75299 0.9950
## Automatic 6-spd-Automatic (S4) -4.400e+00 -16.7197 7.91974 0.9968
## Manual 4-spd-Automatic (S4) 1.850e+00 -4.5614 8.26140 0.9997
## Manual 5-spd-Automatic (S4) 1.902e+00 -3.1998 7.00442 0.9950
## Manual 6-spd-Automatic (S4) -3.095e-02 -5.2080 5.14609 1.0000
## Automatic (S6)-Automatic (S5) -2.281e+00 -4.1948 -0.36724 0.0050
## Automatic (S7)-Automatic (S5) 9.266e+00 -2.0682 20.59948 0.2582
## Automatic 3-spd-Automatic (S5) -3.831e+00 -5.8352 -1.82709 0.0000
## Automatic 4-spd-Automatic (S5) -1.835e+00 -3.6392 -0.03155 0.0414
## Automatic 5-spd-Automatic (S5) -5.568e+00 -9.1055 -2.02988 0.0000
## Automatic 6-spd-Automatic (S5) -7.734e+00 -19.0682 3.59948 0.5727
## Manual 4-spd-Automatic (S5) -1.484e+00 -5.7018 2.73300 0.9973
## Manual 5-spd-Automatic (S5) -1.432e+00 -3.0787 0.21464 0.1719
## Manual 6-spd-Automatic (S5) -3.365e+00 -5.2313 -1.49932 0.0000
## Automatic (S7)-Automatic (S6) 1.155e+01 0.2256 22.86773 0.0404
## Automatic 3-spd-Automatic (S6) -1.550e+00 -3.4805 0.38028 0.2864
## Automatic 4-spd-Automatic (S6) 4.457e-01 -1.2760 2.16728 0.9999
## Automatic 5-spd-Automatic (S6) -3.287e+00 -6.7833 0.20996 0.0916
## Automatic 6-spd-Automatic (S6) -5.453e+00 -16.7744 5.86773 0.9490
## Manual 4-spd-Automatic (S6) 7.967e-01 -3.3862 4.97954 1.0000
## Manual 5-spd-Automatic (S6) 8.490e-01 -0.7072 2.40519 0.8726
## Manual 6-spd-Automatic (S6) -1.084e+00 -2.8709 0.70236 0.7563
## Automatic 3-spd-Automatic (S7) -1.310e+01 -24.4334 -1.76010 0.0080
## Automatic 4-spd-Automatic (S7) -1.110e+01 -22.4040 0.20198 0.0603
## Automatic 5-spd-Automatic (S7) -1.483e+01 -26.5389 -3.12778 0.0017
## Automatic 6-spd-Automatic (S7) -1.700e+01 -32.9047 -1.09528 0.0232
## Manual 4-spd-Automatic (S7) -1.075e+01 -22.6785 1.17854 0.1311
## Manual 5-spd-Automatic (S7) -1.070e+01 -21.9767 0.58131 0.0844
## Manual 6-spd-Automatic (S7) -1.263e+01 -23.9440 -1.31787 0.0131
## Automatic 4-spd-Automatic 3-spd 1.996e+00 0.1743 3.81719 0.0169
## Automatic 5-spd-Automatic 3-spd -1.737e+00 -5.2834 1.81027 0.9420
## Automatic 6-spd-Automatic 3-spd -3.903e+00 -15.2399 7.43344 0.9978
## Manual 4-spd-Automatic 3-spd 2.347e+00 -1.8782 6.57170 0.8566
## Manual 5-spd-Automatic 3-spd 2.399e+00 0.7332 4.06504 0.0001
## Manual 6-spd-Automatic 3-spd 4.658e-01 -1.4172 2.34883 1.0000
## Automatic 5-spd-Automatic 4-spd -3.732e+00 -7.1700 -0.29465 0.0190
## Automatic 6-spd-Automatic 4-spd -5.899e+00 -17.2020 5.40400 0.9063
## Manual 4-spd-Automatic 4-spd 3.510e-01 -3.7827 4.48472 1.0000
## Manual 5-spd-Automatic 4-spd 4.033e-01 -1.0154 1.82211 0.9997
## Manual 6-spd-Automatic 4-spd -1.530e+00 -3.1983 0.13838 0.1136
## Automatic 6-spd-Automatic 5-spd -2.167e+00 -13.8722 9.53889 1.0000
## Manual 4-spd-Automatic 5-spd 4.083e+00 -1.0499 9.21656 0.3017
## Manual 5-spd-Automatic 5-spd 4.136e+00 0.7778 7.49354 0.0029
## Manual 6-spd-Automatic 5-spd 2.202e+00 -1.2683 5.67308 0.6924
## Manual 4-spd-Automatic 6-spd 6.250e+00 -5.6785 18.17854 0.9037
## Manual 5-spd-Automatic 6-spd 6.302e+00 -4.9767 17.58131 0.8510
## Manual 6-spd-Automatic 6-spd 4.369e+00 -6.9440 15.68213 0.9930
## Manual 5-spd-Manual 4-spd 5.233e-02 -4.0153 4.11992 1.0000
## Manual 6-spd-Manual 4-spd -1.881e+00 -6.0422 2.28026 0.9699
## Manual 6-spd-Manual 5-spd -1.933e+00 -3.4303 -0.43626 0.0012
##
## $fuel
## diff lwr upr p adj
## Premium-Diesel -12.0539 -15.95412 -8.154 0.000
## Regular-Diesel -11.3542 -15.26766 -7.441 0.000
## Regular-Premium 0.6997 0.04471 1.355 0.033
TukeyHSD(modeltrm, ordered = FALSE, conf.level = 0.95)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = cty ~ (trans) + make, data = L)
##
## $trans
## diff lwr upr p adj
## Auto(AM6)-Auto(AM-S6) -9.800e+00 -15.5061 -4.0939 0.0000
## Auto(AM7)-Auto(AM-S6) -9.800e+00 -14.3750 -5.2250 0.0000
## Auto(AV-S7)-Auto(AM-S6) 1.520e+01 8.6629 21.7371 0.0000
## Automatic (S4)-Auto(AM-S6) -8.400e+00 -13.3416 -3.4584 0.0000
## Automatic (S5)-Auto(AM-S6) -5.066e+00 -8.6938 -1.4375 0.0002
## Automatic (S6)-Auto(AM-S6) -7.347e+00 -10.9555 -3.7378 0.0000
## Automatic (S7)-Auto(AM-S6) 4.200e+00 -4.3591 12.7591 0.9409
## Automatic 3-spd-Auto(AM-S6) -8.897e+00 -12.5292 -5.2644 0.0000
## Automatic 4-spd-Auto(AM-S6) -6.901e+00 -10.4824 -3.3196 0.0000
## Automatic 5-spd-Auto(AM-S6) -1.063e+01 -14.7923 -6.4743 0.0000
## Automatic 6-spd-Auto(AM-S6) -1.280e+01 -21.3591 -4.2409 0.0000
## Manual 4-spd-Auto(AM-S6) -6.550e+00 -11.0043 -2.0957 0.0001
## Manual 5-spd-Auto(AM-S6) -6.498e+00 -10.0423 -2.9530 0.0000
## Manual 6-spd-Auto(AM-S6) -8.431e+00 -12.0277 -4.8342 0.0000
## Auto(AM7)-Auto(AM6) -1.954e-14 -5.3917 5.3917 1.0000
## Auto(AV-S7)-Auto(AM6) 2.500e+01 17.8674 32.1326 0.0000
## Automatic (S4)-Auto(AM6) 1.400e+00 -4.3061 7.1061 1.0000
## Automatic (S5)-Auto(AM6) 4.734e+00 0.1188 9.3499 0.0379
## Automatic (S6)-Auto(AM6) 2.453e+00 -2.1471 7.0537 0.8909
## Automatic (S7)-Auto(AM6) 1.400e+01 4.9779 23.0221 0.0000
## Automatic 3-spd-Auto(AM6) 9.032e-01 -3.7157 5.5221 1.0000
## Automatic 4-spd-Auto(AM6) 2.899e+00 -1.6799 7.4779 0.6958
## Automatic 5-spd-Auto(AM6) -8.333e-01 -5.8768 4.2102 1.0000
## Automatic 6-spd-Auto(AM6) -3.000e+00 -12.0221 6.0221 0.9985
## Manual 4-spd-Auto(AM6) 3.250e+00 -2.0397 8.5397 0.7395
## Manual 5-spd-Auto(AM6) 3.302e+00 -1.2479 7.8525 0.4624
## Manual 6-spd-Auto(AM6) 1.369e+00 -3.2219 5.9599 0.9996
## Auto(AV-S7)-Auto(AM7) 2.500e+01 18.7354 31.2646 0.0000
## Automatic (S4)-Auto(AM7) 1.400e+00 -3.1750 5.9750 0.9994
## Automatic (S5)-Auto(AM7) 4.734e+00 1.6239 7.8449 0.0000
## Automatic (S6)-Auto(AM7) 2.453e+00 -0.6346 5.5413 0.3037
## Automatic (S7)-Auto(AM7) 1.400e+01 5.6472 22.3528 0.0000
## Automatic 3-spd-Auto(AM7) 9.032e-01 -2.2122 4.0187 0.9997
## Automatic 4-spd-Auto(AM7) 2.899e+00 -0.1568 5.9548 0.0842
## Automatic 5-spd-Auto(AM7) -8.333e-01 -4.5493 2.8827 1.0000
## Automatic 6-spd-Auto(AM7) -3.000e+00 -11.3528 5.3528 0.9966
## Manual 4-spd-Auto(AM7) 3.250e+00 -0.7938 7.2938 0.2850
## Manual 5-spd-Auto(AM7) 3.302e+00 0.2897 6.3150 0.0168
## Manual 6-spd-Auto(AM7) 1.369e+00 -1.7047 4.4428 0.9735
## Automatic (S4)-Auto(AV-S7) -2.360e+01 -30.1371 -17.0629 0.0000
## Automatic (S5)-Auto(AV-S7) -2.027e+01 -25.8762 -14.6551 0.0000
## Automatic (S6)-Auto(AV-S7) -2.255e+01 -28.1447 -16.9486 0.0000
## Automatic (S7)-Auto(AV-S7) -1.100e+01 -20.5694 -1.4306 0.0087
## Automatic 3-spd-Auto(AV-S7) -2.410e+01 -29.7101 -18.4835 0.0000
## Automatic 4-spd-Auto(AV-S7) -2.210e+01 -27.6814 -16.5206 0.0000
## Automatic 5-spd-Auto(AV-S7) -2.583e+01 -31.8009 -19.8658 0.0000
## Automatic 6-spd-Auto(AV-S7) -2.800e+01 -37.5694 -18.4306 0.0000
## Manual 4-spd-Auto(AV-S7) -2.175e+01 -27.9270 -15.5730 0.0000
## Manual 5-spd-Auto(AV-S7) -2.170e+01 -27.2546 -16.1408 0.0000
## Manual 6-spd-Auto(AV-S7) -2.363e+01 -29.2212 -18.0407 0.0000
## Automatic (S5)-Automatic (S4) 3.334e+00 -0.2938 6.9625 0.1115
## Automatic (S6)-Automatic (S4) 1.053e+00 -2.5555 4.6622 0.9997
## Automatic (S7)-Automatic (S4) 1.260e+01 4.0409 21.1591 0.0001
## Automatic 3-spd-Automatic (S4) -4.968e-01 -4.1292 3.1356 1.0000
## Automatic 4-spd-Automatic (S4) 1.499e+00 -2.0824 5.0804 0.9848
## Automatic 5-spd-Automatic (S4) -2.233e+00 -6.3923 1.9257 0.8856
## Automatic 6-spd-Automatic (S4) -4.400e+00 -12.9591 4.1591 0.9160
## Manual 4-spd-Automatic (S4) 1.850e+00 -2.6043 6.3043 0.9859
## Manual 5-spd-Automatic (S4) 1.902e+00 -1.6423 5.4470 0.8860
## Manual 6-spd-Automatic (S4) -3.095e-02 -3.6277 3.5658 1.0000
## Automatic (S6)-Automatic (S5) -2.281e+00 -3.6107 -0.9514 0.0000
## Automatic (S7)-Automatic (S5) 9.266e+00 1.3914 17.1398 0.0061
## Automatic 3-spd-Automatic (S5) -3.831e+00 -5.2235 -2.4388 0.0000
## Automatic 4-spd-Automatic (S5) -1.835e+00 -3.0886 -0.5822 0.0001
## Automatic 5-spd-Automatic (S5) -5.568e+00 -8.0256 -3.1098 0.0000
## Automatic 6-spd-Automatic (S5) -7.734e+00 -15.6086 0.1398 0.0602
## Manual 4-spd-Automatic (S5) -1.484e+00 -4.4144 1.4456 0.9246
## Manual 5-spd-Automatic (S5) -1.432e+00 -2.5761 -0.2880 0.0022
## Manual 6-spd-Automatic (S5) -3.365e+00 -4.6617 -2.0689 0.0000
## Automatic (S7)-Automatic (S6) 1.155e+01 3.6814 19.4120 0.0001
## Automatic 3-spd-Automatic (S6) -1.550e+00 -2.8912 -0.2090 0.0080
## Automatic 4-spd-Automatic (S6) 4.457e-01 -0.7504 1.6417 0.9951
## Automatic 5-spd-Automatic (S6) -3.287e+00 -5.7159 -0.8574 0.0005
## Automatic 6-spd-Automatic (S6) -5.453e+00 -13.3186 2.4120 0.5446
## Manual 4-spd-Automatic (S6) 7.967e-01 -2.1094 3.7027 0.9998
## Manual 5-spd-Automatic (S6) 8.490e-01 -0.2322 1.9302 0.3232
## Manual 6-spd-Automatic (S6) -1.084e+00 -2.3256 0.1570 0.1664
## Automatic 3-spd-Automatic (S7) -1.310e+01 -20.9729 -5.2206 0.0000
## Automatic 4-spd-Automatic (S7) -1.110e+01 -18.9537 -3.2483 0.0002
## Automatic 5-spd-Automatic (S7) -1.483e+01 -22.9657 -6.7009 0.0000
## Automatic 6-spd-Automatic (S7) -1.700e+01 -28.0498 -5.9502 0.0000
## Manual 4-spd-Automatic (S7) -1.075e+01 -19.0373 -2.4627 0.0011
## Manual 5-spd-Automatic (S7) -1.070e+01 -18.5337 -2.8616 0.0004
## Manual 6-spd-Automatic (S7) -1.263e+01 -20.4907 -4.7712 0.0000
## Automatic 4-spd-Automatic 3-spd 1.996e+00 0.7303 3.2612 0.0000
## Automatic 5-spd-Automatic 3-spd -1.737e+00 -4.2007 0.7276 0.5155
## Automatic 6-spd-Automatic 3-spd -3.903e+00 -11.7794 3.9729 0.9362
## Manual 4-spd-Automatic 3-spd 2.347e+00 -0.5885 5.2820 0.2934
## Manual 5-spd-Automatic 3-spd 2.399e+00 1.2417 3.5565 0.0000
## Manual 6-spd-Automatic 3-spd 4.658e-01 -0.8424 1.7740 0.9969
## Automatic 5-spd-Automatic 4-spd -3.732e+00 -6.1206 -1.3440 0.0000
## Automatic 6-spd-Automatic 4-spd -5.899e+00 -13.7517 1.9537 0.4004
## Manual 4-spd-Automatic 4-spd 3.510e-01 -2.5209 3.2229 1.0000
## Manual 5-spd-Automatic 4-spd 4.033e-01 -0.5824 1.3890 0.9877
## Manual 6-spd-Automatic 4-spd -1.530e+00 -2.6890 -0.3709 0.0008
## Automatic 6-spd-Automatic 5-spd -2.167e+00 -10.2991 5.9657 0.9999
## Manual 4-spd-Automatic 5-spd 4.083e+00 0.5170 7.6496 0.0092
## Manual 5-spd-Automatic 5-spd 4.136e+00 1.8028 6.4685 0.0000
## Manual 6-spd-Automatic 5-spd 2.202e+00 -0.2089 4.6136 0.1175
## Manual 4-spd-Automatic 6-spd 6.250e+00 -2.0373 14.5373 0.3933
## Manual 5-spd-Automatic 6-spd 6.302e+00 -1.5337 14.1384 0.2838
## Manual 6-spd-Automatic 6-spd 4.369e+00 -3.4907 12.2288 0.8559
## Manual 5-spd-Manual 4-spd 5.233e-02 -2.7736 2.8783 1.0000
## Manual 6-spd-Manual 4-spd -1.881e+00 -4.7719 1.0100 0.6531
## Manual 6-spd-Manual 5-spd -1.933e+00 -2.9733 -0.8932 0.0000
##
## $make
## diff lwr upr
## Alfa Romeo-Acura -1.3510 -2.5139 -0.1880
## AM General-Acura -1.1112 -3.9128 1.6904
## American Motors Corporation-Acura -1.5655 -2.9356 -0.1953
## ASC Incorporated-Acura -4.2736 -11.0734 2.5261
## Aston Martin-Acura -5.9335 -6.6967 -5.1702
## Audi-Acura -0.3722 -1.0699 0.3255
## AM General-Alfa Romeo 0.2398 -2.7366 3.2161
## American Motors Corporation-Alfa Romeo -0.2145 -1.9137 1.4847
## ASC Incorporated-Alfa Romeo -2.9227 -9.7963 3.9510
## Aston Martin-Alfa Romeo -4.5825 -5.8444 -3.3206
## Audi-Alfa Romeo 0.9788 -0.2446 2.2022
## American Motors Corporation-AM General -0.4543 -3.5175 2.6090
## ASC Incorporated-AM General -3.1624 -10.4934 4.1685
## Aston Martin-AM General -4.8223 -7.6664 -1.9782
## Audi-AM General 0.7390 -2.0882 3.5662
## ASC Incorporated-American Motors Corporation -2.7082 -9.6199 4.2035
## Aston Martin-American Motors Corporation -4.3680 -5.8231 -2.9129
## Audi-American Motors Corporation 1.1933 -0.2286 2.6151
## Aston Martin-ASC Incorporated -1.6598 -8.4772 5.1576
## Audi-ASC Incorporated 3.9014 -2.9089 10.7118
## Audi-Aston Martin 5.5613 4.7087 6.4138
## p adj
## Alfa Romeo-Acura 0.0112
## AM General-Acura 0.9039
## American Motors Corporation-Acura 0.0136
## ASC Incorporated-Acura 0.5082
## Aston Martin-Acura 0.0000
## Audi-Acura 0.6963
## AM General-Alfa Romeo 1.0000
## American Motors Corporation-Alfa Romeo 0.9998
## ASC Incorporated-Alfa Romeo 0.8706
## Aston Martin-Alfa Romeo 0.0000
## Audi-Alfa Romeo 0.2146
## American Motors Corporation-AM General 0.9995
## ASC Incorporated-AM General 0.8626
## Aston Martin-AM General 0.0000
## Audi-AM General 0.9874
## ASC Incorporated-American Motors Corporation 0.9089
## Aston Martin-American Motors Corporation 0.0000
## Audi-American Motors Corporation 0.1673
## Aston Martin-ASC Incorporated 0.9913
## Audi-ASC Incorporated 0.6197
## Audi-Aston Martin 0.0000
# Plot the results
f1 = TukeyHSD(modelcylf, which="cyl", ordered = FALSE)
f2 = TukeyHSD(modeldrf, which="drive",ordered = FALSE)
f3= TukeyHSD(modeltrf, which="trans",ordered = FALSE)
plot(f1)
plot(f2)
plot(f3)
m1 = TukeyHSD(modelcylm, which="cyl", ordered = FALSE)
m2 = TukeyHSD(modeldrm, which="drive",ordered = FALSE)
m3= TukeyHSD(modeltrm, which="trans",ordered = FALSE)
plot(m1)
plot(m2)
plot(m3)
There is a significant difference in mean between almost all levels of ‘number of cylinders’ except for just 2 pairs that have negligible difference in means. For the factor ‘drive’ there are just 3 pairs that have significant difference in means, rest all other pairs have not much difference.Transmission type also shows that there is no significant difference in means for most of the pairs. However there is are some levels for ‘Automatic’ transmission types that do deviate from other levels with a significant difference.
In conclusion, there exists a significant difference in many pairs of the treatment levels for all three factors.However, the number of pairs that do not show a significant difference in means are more, therefore we can conclude that our testing is appropriate.
The data from the fueleconomy data set is available at https://github.com/hadley/fueleconomy.